ronaldoussoren / py2app

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.
Other
341 stars 36 forks source link

--extra-scripts=bar/bar.py does not find dependencies in bar #71

Open ronaldoussoren opened 11 years ago

ronaldoussoren commented 11 years ago

Original report by Andrew Barnert (Bitbucket: abarnert, GitHub: abarnert).


After the fix for #68, you can now pass --extra-scripts=bar/bar.py and it properly builds the app.

However, it apparently looks for dependencies in bar/bar.py in . instead of bar, which means it ultimately silently fails to copy in necessary dependencies.

In the attached test project, foo.py properly pulls qux.py into python33.zip, but bar/bar.py does not pull bar/baz.py in, so you get an import error on attempting to run the packaged bar.

ronaldoussoren commented 11 years ago

Original comment by Ronald Oussoren (Bitbucket: ronaldoussoren, GitHub: ronaldoussoren).


Fixing this for the general case could be hard. In particular, the current bundle and zipfile structure won't work when two scripts in different directories both import a module with the same name, but in their respective directories. In your test project: when both foo.py and bar.py import qux.py and qux.py is both at the toplevel and in 'bar/'.

Doing the right thing for your test project should be easier, but detecting cross-contamination would be hard.

In the longer run py2app should calculate a new module graph for every directory containing scripts and merge them. This would do the right thing for the test project, and would detect naming conflicts between modules used in the different script directories.

BTW. "silently fails to copy dependencies" is a known issue, not only here but also in more basic cases. The verbose output of py2app probably already contains the needed data, but in a fairly useless manner (way to verbose), it should be fairly easy to print a short report at the end that mentions which dependencies weren't copied into the bundle.