[Python-Dev] Python install layout and the PATH on win32 (Rationale part 1: Regularizing the layout)

Nick Coghlan ncoghlan at gmail.com
Sat Mar 24 13:19:27 CET 2012


On Sat, Mar 24, 2012 at 4:35 AM, PJ Eby <pje at telecommunity.com> wrote:
> Just dumping things in a directory adjacent to the corresponding scripts is
> the original virtualenv, and it still works just dandy -- most people just
> don't *know* this.  (And again, if there are tools out there that *don't*
> support single-directory virtualenvs, the best answer is probably to fix
> them.)

Not to mention that CPython gained native support for that layout in
2.6 via __main__.py files (although I stuffed up and forgot to add it
to the What's New before the release).

I'll chime in on the -1 side here as well. If you want *easy*
cross-platform execution of __main__, use the -m switch. I'm obviously
biased, since I'm the original author and primary maintainer of that
switch, but it just makes all these problems with cross-platform
questions and running from an installed copy vs running from source
*go away*. Indeed, avoiding such cross-platform  inconsistencies with
regards to the location of stdlib modules was one of the major
arguments in favour of adding the original incarnation of the switch
way back in Python 2.4.

To run the main clients (one for repo management, one for Django site
management) in my current work project, I use "python -m
pulpdist.manage_repos" and "python -m pulpdist.manage_site". It works
from a source checkout (so long as I cd into src/ first), on an
installed version, in a virtualenv, anywhere. I can easily run it on a
different Python version just by changing the version I invoke. The
commands would probably also work on at least Mac OS X and maybe even
Windows (although I've never actually tried either of those, since
PulpDist is targeted specifically at Linux systems).

I may get around to installing at least the repo management client as
a real script some day (since it will be more convenient for system
administrators that way), but direct execution will never be the main
way of executing it from a source checkout.

So Van's proposal still smacks too much to me of change for change's
sake. If you want an execution mechanism that is completely consistent
across platforms (including virtual environments), then "-m" already
exists. For direct execution, the proposal trades cross-version
inconsistencies for cross-platform consistency. When we *already have*
a consistent cross-platform mechanism in -m, the inevitable disruption
involved in changing the Windows layout seems very hard to justify.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list