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

Daniel Holth dholth at gmail.com
Tue Nov 20 20:13:12 CET 2012


On Tue, Nov 20, 2012 at 1:21 PM, Philipp Hagemeister <phihag at phihag.de>wrote:

> Currently, there are the following methods for installing dependencies:
>
> · Use the distribution's packaging (ignored here, all further points
> refer to setup.py/distutils)
> · Install them system-wide (default). This requires superuser rights and
> is basically guaranteed to conflict with some other application,
> especially if applications are choosy about the versions of Python
> packages they like.
> · Install them user-wide (--user), with pretty much the same downsides,
> plus that the application is now bound to the user installing it.
> · Manually invoke distutils with another path (error-prone and
> non-standard).
> · Give up and use virtualenv. While this works fine, it's a little bit
> heavy-handed to modify one's shell just to launch a potentially trivial
> application.
>
> Therefore, I'd like to suggest a new alternative location (--here =
> --root "./python_modules", intended to become default in Python 5),
> modeled after node's packaging system (http://goo.gl/dMRTC).
>
> The obvious advantage of installing all dependencies into a directory in
> the application root is that the application will work for every user,
> never conflict with any other application, and it is both easy to
> package dependencies (say, for an sftp-only rollout) and to delete all
> dependencies. Of course, this is not sufficient to replace virtualenv,
> but I believe a large majority of applications will (or at least should)
> run under any common python interpreter.
>
> Aside from the new flag in distutils, the site module should
> automatically look into ./python_modules , as if it were a second
> USER_SITE.
>
> In node, this scheme works so well that virtually nobody bothers to use
> system-wide installation, except when they want a binary to be available
> in the PATH for all users.
>
> This suggestion seems so obvious that it probably has been discussed
> before, but my google-fu is too weak to find it. If it has, I'd be glad
> to get a link to the old discussion. Thanks!
>
> - Philipp


You wouldn't need stdlib support to do this. I believe setuptools'
pkg_resources can look in a directory full of eggs, adding the required
ones to PYTHONPATH based on requirements as specified in a wrapper script.
Gem uses a directory full of versioned packages like
~/.gem/ruby/1.8/gems/sinatra-1.3.3/.

The feature is something like having a dynamic linker. It is a useful thing
to have.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121120/f5ea6d4f/attachment.html>


More information about the Python-ideas mailing list