Search code examples
pythonconfigpy2apppackage-management

Python app built with py2app missing _sysconfigdata


I am trying to build a standalone Python 2.7 application on MacOS (it relies on some old code) using py2app. My program relies on a number of packages, including pyne. The program uses a conda environment for package management (which is located in a separate directory), and I am trying to build the program with that environment. The application gets built just fine by py2app, but when I run it through the terminal it throws the following error:

  File "material.pyx", line 28, in init pyne.material
  File "tables/__init__.pyc", line 142, in <module>
  File "tables/tests/__init__.pyc", line 22, in <module>
  File "tables/tests/common.pyc", line 27, in <module>
  File "pkg_resources/__init__.pyc", line 959, in <module>
  File "pkg_resources/__init__.pyc", line 963, in Environment
  File "pkg_resources/__init__.pyc", line 190, in get_supported_platform
  File "pkg_resources/__init__.pyc", line 395, in get_build_platform
  File "sysconfig.pyc", line 618, in get_platform
  File "sysconfig.pyc", line 482, in get_config_vars
  File "sysconfig.pyc", line 365, in _init_posix
ImportError: No module named _sysconfigdata

Looking around in my system, it looks like the _sysconfigdata file in question is located in

/anaconda3/envs/ENVIRONMENT_NAME/lib/python2.7/_sysconfigdata.py

My setup.py file looks like this:

    from setuptools import setup

    APP = ['app.py']
    DATA_FILES = ["file1.csv", "folder1"]
    PACKAGES = ["pyne"]
    OPTIONS = {"packages": PACKAGES}

    setup(
        app=APP,
        data_files=DATA_FILES,
        options={'py2app': OPTIONS},
        setup_requires=['py2app'],
        name="NAME",
        include_package_data=True,
    )

I am still fairly new to using py2app, and I'm having trouble figuring out how to include this _sysconfigdata file in the program. Adding it to the DATA_FILES does not seem to help. What is the best way to resolve this issue?


Solution

  • I discovered that this issue went away if I edited the PACKAGES list to

    PACKAGES = PACKAGES = ["pyne", "_sysconfigdata"]
    

    I guess py2app wasn't otherwise aware that _sysconfigdata was an important module.