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

Philipp Hagemeister phihag at phihag.de
Wed Nov 21 10:50:57 CET 2012


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.

As far as I understand, you suggest a setup like

./main.py (with content:
  import lxml.etree
  import myapp
  myapp.hello(lxml.etree.fromstring('<foo/>'))")
)
./myapp/__init__.py
./python_modules/__main__.py -> ../main.py
./python_modules/myapp -> ../myapp  # Or a path fixup in main
./python_modules/lxml/...   # or equivalent .pth
./myapp.sh (chmod +x, with content:
  python -m python_modules
)

which strikes me as really complex (and would still benefit from a
--here option to distutils). And how would the setup.py in . look to set
up all the symlinks?

- Philipp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121121/d2a91925/attachment.pgp>


More information about the Python-ideas mailing list