[Python-ideas] python_modules as default directory for dependencies in distutils

Nick Coghlan ncoghlan at gmail.com
Wed Nov 21 14:38:39 CET 2012

On Wed, Nov 21, 2012 at 7:50 PM, Philipp Hagemeister <phihag at phihag.de>wrote:

> On 11/21/2012 04:27 AM, Nick Coghlan wrote:
> > Or install them all in a single directory, add a __main__.py file to that
> > directory and then just pass that directory name on the command line
> > instead of a script name. The directory will be added as sys.path[0] and
> > the __main__.py file will be executed as the main module (If your
> > additional application dependencies are all pure Python files, you can
> even
> > zip up that directory and pass that on the command line instead).
> I'm well-aware of that approach, but didn't apply it to dependencies,
> and am still not sure how to. Can you describe how a hypothetical
> helloworld application with one dependency would look like? And wouldn't
> one sacrifice the ability to seamlessly import from the application's
> code itself.

One directory containing:

           (with content as described for your main.py)

Execute "python runthis" (via a +x shell script if you prefer). Note the
lack of -m: you're executing the directory contents, not a package. You can
also bundle it all into a zip file, but that only works if you don't need C
extension support (since zipimport can't handle the necessary step of
extracting the shared libraries out to separate files so the OS can load


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121121/62d35ac5/attachment.html>

More information about the Python-ideas mailing list