Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minimal example of pyinstaller --onefile .so conflict

Minimal example to reproduce pyinstaller issue #1105

Problem with conflicting .so files https://github.com/pyinstaller/pyinstaller/issues/1105

To reproduce:

  1. Download the gist

  2. Gist doesn't support directories, so manually create the submodule:

    $ mkdir submodule
    $ mv __init__.py _random.pyx submodule/
    
  3. Use cython to compile the .so:

    $ python setup.py build_ext --inplace
    
  4. Run normally, it works:

    $ python pyi_so_conflict.py
    success!
    
  5. Run through pyinstaller --onedir, it works:

    $ pyinstaller --onedir --name=onedir pyi_so_conflict.py
    [...]
    $ dist/onedir/onedir
    success!
    
  6. Run through pyinstaller --onefile, it fails:

    $ pyinstaller --onefile --name=onefile pyi_so_conflict.py
    [...]
    $ dist/onefile
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "/usr/local/lib/python2.7/site-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
        exec(bytecode, module.__dict__)
      File "/Users/ronen/test/pyi_so_conflict/build/onefile/out00-PYZ.pyz/submodule", line 1, in <module>
    ImportError: cannot import name subfunc
    

Platform details:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.10.1
BuildVersion:	14B25
$ python --version
Python 2.7.9
$ pyinstaller --version
2.1
from ._random import subfunc
def subfunc():
return True
import random
import submodule
if random.random() and submodule.subfunc():
print "success!"
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = 'pyinstaller .so collision example',
ext_modules = cythonize("submodule/_random.pyx"),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment