PEP 250, Using site-packages on All Platforms, Paul Moore
This commit is contained in:
parent
5bcbd85500
commit
723eab0480
|
@ -0,0 +1,106 @@
|
|||
PEP: 250
|
||||
Title: Using site-packages on All Platforms
|
||||
Version $Revision$
|
||||
Author: gustav@morpheus.demon.co.uk (Paul Moore)
|
||||
Status: Draft
|
||||
Type: Standards Track
|
||||
Created: 2001-03-30
|
||||
Python-Version: 2.2
|
||||
Post-History:
|
||||
|
||||
|
||||
Abstract
|
||||
|
||||
The standard Python distribution includes a directory
|
||||
Lib/site-packages, which is used on Unix platforms to hold
|
||||
locally-installed modules and packages. The site.py module
|
||||
distributed with Python includes support for locating other
|
||||
modules in the site-packages directory.
|
||||
|
||||
This PEP proposes that the site-packages directory should be used
|
||||
uniformly across all platforms for locally installed modules.
|
||||
|
||||
|
||||
Motivation
|
||||
|
||||
On Windows platforms, the default setting for sys.path does not
|
||||
include a directory suitable for users to install locally
|
||||
developed modules. The "expected" location appears to be the
|
||||
directory containing the Python executable itself. Including
|
||||
locally developed code in the same directory as installed
|
||||
executables is not good practice.
|
||||
|
||||
Clearly, users can manipulate sys.path, either in a locally
|
||||
modified site.py, or in a suitable sitecustomize.py, or even via
|
||||
.pth files. However, there should be a standard location for such
|
||||
files, rather than relying on every individual site having to set
|
||||
their own policy.
|
||||
|
||||
In addition, with distutils becoming more prevalent as a means of
|
||||
distributing modules, the need for a standard install location for
|
||||
distributed modules will become more common. It would be better
|
||||
to define such a standard now, rather than later when more
|
||||
distutils-based packages exist which will need rebuilding.
|
||||
|
||||
It is relevant to note that prior to Python 2.1, the site-packages
|
||||
directory was not included in sys.path for Macintosh platforms.
|
||||
This has been changed in 2.1, and Macintosh includes sys.path now,
|
||||
leaving Windows as the only major platform with no site-specific
|
||||
modules directory.
|
||||
|
||||
|
||||
Implementation
|
||||
|
||||
The implementation of this feature is fairly trivial. All that
|
||||
would be required is a change to site.py, to change the section
|
||||
setting sitedirs. The Python 2.1 version has
|
||||
|
||||
if os.sep == '/':
|
||||
sitedirs = [makepath(prefix,
|
||||
"lib",
|
||||
"python" + sys.version[:3],
|
||||
"site-packages"),
|
||||
makepath(prefix, "lib", "site-python")]
|
||||
elif os.sep == ':':
|
||||
sitedirs = [makepath(prefix, "lib", "site-packages")]
|
||||
else:
|
||||
sitedirs = [prefix]
|
||||
|
||||
A suitable change would be to simply replace the last 4 lines with
|
||||
|
||||
else:
|
||||
sitedirs == [makepath(prefix, "lib", "site-packages")]
|
||||
|
||||
Changes would also be required to distutils, in the sysconfig.py
|
||||
file. It is worth noting that this file does not seem to have
|
||||
been updated in line with the change of policy on the Macintosh,
|
||||
as of this writing.
|
||||
|
||||
|
||||
Notes
|
||||
|
||||
1. It would be better if this change could be included in Python
|
||||
2.1, as changing something of this nature is better done
|
||||
sooner, rather than later, to reduce the backward-compatibility
|
||||
burden. This is extremely unlikely to happen at this late stage
|
||||
in the release cycle, however.
|
||||
|
||||
2. This change does not preclude packages using the current
|
||||
location -- the change only adds a directory to sys.path, it
|
||||
does not remove anything.
|
||||
|
||||
3. In the Windows distribution of Python 2.1 (beta 1), the
|
||||
Lib\site-packages directory has been removed. It would need to
|
||||
be reinstated.
|
||||
|
||||
|
||||
Copyright
|
||||
|
||||
This document has been placed in the public domain.
|
||||
|
||||
|
||||
|
||||
Local Variables:
|
||||
mode: indented-text
|
||||
indent-tabs-mode: nil
|
||||
End:
|
Loading…
Reference in New Issue