0

Can py2app be set up such that the typical contents of a user's sys.path (when running python, not a py2app .app) are appended at the end of the path that py2app sets up?

I am bundling an application with an interactive python prompt -- I would like other users to be able to use modules they have built, but which are not provided in the main .app. If they try to import something that is bundled with py2app, I'd prefer that the py2app version be used.

The --use-pythonpath and --site-packages options to py2app don't seem to add all the directories that regular python does.

ChrisB
  • 4,628
  • 7
  • 29
  • 41
  • I think those options only work if you were to launch the executable from a terminal. Shell environment settings from the user wouldn't get passed when it is launched from the `.app` – jdi Sep 13 '12 at 22:34
  • I am launching the executable (dist/MyApplication.app/Contents/MacOS/MyApplication) from the terminal. It adds some, but not all, of the sys.path items I find when I launch python – ChrisB Sep 14 '12 at 00:34
  • The `sys.path` manipulation happens in the generated `__boot__.py` file, but the env variables it depends on are set up in the MyApplication wrapper executable. You can first hack up `__boot__.py` to print out what it's getting from the wrapper, then write the appropriate code to use that together with the user's normal path. But this sounds like a huge pain. – abarnert Oct 06 '12 at 03:28
  • One quick question: This is a semi-standalone build, not a standalone, right? With a standalone build, you're not using the same Python as any of the user's existing installations, so you can't safely use their modules. With a semi-standalone build for, say, /usr/bin/python2.7, you should be able to. – abarnert Oct 06 '12 at 03:29
  • It's a standalone build. However, my understanding is that any python executable from a fixed version can import and use a module, regardless of which executable it was installed with – ChrisB Oct 06 '12 at 18:57

0 Answers0