Kaydet (Commit) 9e82b17e authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Issue #21711: support for "site-python" directories has now been removed from…

Issue #21711: support for "site-python" directories has now been removed from the site module (it was deprecated in 3.4).
üst b6cf631f
...@@ -26,24 +26,23 @@ additions, call the :func:`site.main` function. ...@@ -26,24 +26,23 @@ additions, call the :func:`site.main` function.
:option:`-S`. :option:`-S`.
.. index:: .. index::
pair: site-python; directory
pair: site-packages; directory pair: site-packages; directory
It starts by constructing up to four directories from a head and a tail part. It starts by constructing up to four directories from a head and a tail part.
For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads For the head part, it uses ``sys.prefix`` and ``sys.exec_prefix``; empty heads
are skipped. For the tail part, it uses the empty string and then are skipped. For the tail part, it uses the empty string and then
:file:`lib/site-packages` (on Windows) or :file:`lib/site-packages` (on Windows) or
:file:`lib/python{X.Y}/site-packages` and then :file:`lib/site-python` (on :file:`lib/python{X.Y}/site-packages` (on Unix and Macintosh). For each
Unix and Macintosh). For each of the distinct head-tail combinations, it sees of the distinct head-tail combinations, it sees if it refers to an existing
if it refers to an existing directory, and if so, adds it to ``sys.path`` and directory, and if so, adds it to ``sys.path`` and also inspects the newly
also inspects the newly added path for configuration files. added path for configuration files.
.. deprecated-removed:: 3.4 3.5 .. versionchanged:: 3.5
Support for the "site-python" directory will be removed in 3.5. Support for the "site-python" directory has been removed.
If a file named "pyvenv.cfg" exists one directory above sys.executable, If a file named "pyvenv.cfg" exists one directory above sys.executable,
sys.prefix and sys.exec_prefix are set to that directory and sys.prefix and sys.exec_prefix are set to that directory and
it is also checked for site-packages and site-python (sys.base_prefix and it is also checked for site-packages (sys.base_prefix and
sys.base_exec_prefix will always be the "real" prefixes of the Python sys.base_exec_prefix will always be the "real" prefixes of the Python
installation). If "pyvenv.cfg" (a bootstrap configuration file) contains installation). If "pyvenv.cfg" (a bootstrap configuration file) contains
the key "include-system-site-packages" set to anything other than "false" the key "include-system-site-packages" set to anything other than "false"
...@@ -195,8 +194,7 @@ Module contents ...@@ -195,8 +194,7 @@ Module contents
.. function:: getsitepackages() .. function:: getsitepackages()
Return a list containing all global site-packages directories (and possibly Return a list containing all global site-packages directories.
site-python).
.. versionadded:: 3.2 .. versionadded:: 3.2
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
This will append site-specific paths to the module search path. On This will append site-specific paths to the module search path. On
Unix (including Mac OSX), it starts with sys.prefix and Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python. lib/python<version>/site-packages.
On other platforms (such as Windows), it tries each of the On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended. The prefixes directly, as well as with lib/site-packages appended. The
resulting directories, if they exist, are appended to sys.path, and resulting directories, if they exist, are appended to sys.path, and
...@@ -15,7 +15,7 @@ also inspected for path configuration files. ...@@ -15,7 +15,7 @@ also inspected for path configuration files.
If a file named "pyvenv.cfg" exists one directory above sys.executable, If a file named "pyvenv.cfg" exists one directory above sys.executable,
sys.prefix and sys.exec_prefix are set to that directory and sys.prefix and sys.exec_prefix are set to that directory and
it is also checked for site-packages and site-python (sys.base_prefix and it is also checked for site-packages (sys.base_prefix and
sys.base_exec_prefix will always be the "real" prefixes of the Python sys.base_exec_prefix will always be the "real" prefixes of the Python
installation). If "pyvenv.cfg" (a bootstrap configuration file) contains installation). If "pyvenv.cfg" (a bootstrap configuration file) contains
the key "include-system-site-packages" set to anything other than "false" the key "include-system-site-packages" set to anything other than "false"
...@@ -285,8 +285,7 @@ def addusersitepackages(known_paths): ...@@ -285,8 +285,7 @@ def addusersitepackages(known_paths):
return known_paths return known_paths
def getsitepackages(prefixes=None): def getsitepackages(prefixes=None):
"""Returns a list containing all global site-packages directories """Returns a list containing all global site-packages directories.
(and possibly site-python).
For each directory present in ``prefixes`` (or the global ``PREFIXES``), For each directory present in ``prefixes`` (or the global ``PREFIXES``),
this function will find its `site-packages` subdirectory depending on the this function will find its `site-packages` subdirectory depending on the
...@@ -307,7 +306,6 @@ def getsitepackages(prefixes=None): ...@@ -307,7 +306,6 @@ def getsitepackages(prefixes=None):
sitepackages.append(os.path.join(prefix, "lib", sitepackages.append(os.path.join(prefix, "lib",
"python" + sys.version[:3], "python" + sys.version[:3],
"site-packages")) "site-packages"))
sitepackages.append(os.path.join(prefix, "lib", "site-python"))
else: else:
sitepackages.append(prefix) sitepackages.append(prefix)
sitepackages.append(os.path.join(prefix, "lib", "site-packages")) sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
...@@ -323,14 +321,9 @@ def getsitepackages(prefixes=None): ...@@ -323,14 +321,9 @@ def getsitepackages(prefixes=None):
return sitepackages return sitepackages
def addsitepackages(known_paths, prefixes=None): def addsitepackages(known_paths, prefixes=None):
"""Add site-packages (and possibly site-python) to sys.path""" """Add site-packages to sys.path"""
for sitedir in getsitepackages(prefixes): for sitedir in getsitepackages(prefixes):
if os.path.isdir(sitedir): if os.path.isdir(sitedir):
if "site-python" in sitedir:
import warnings
warnings.warn('"site-python" directories will not be '
'supported in 3.5 anymore',
DeprecationWarning)
addsitedir(sitedir, known_paths) addsitedir(sitedir, known_paths)
return known_paths return known_paths
......
...@@ -235,20 +235,18 @@ class HelperFunctionsTests(unittest.TestCase): ...@@ -235,20 +235,18 @@ class HelperFunctionsTests(unittest.TestCase):
# OS X framework builds # OS X framework builds
site.PREFIXES = ['Python.framework'] site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages() dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3) self.assertEqual(len(dirs), 2)
wanted = os.path.join('/Library', wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"), sysconfig.get_config_var("PYTHONFRAMEWORK"),
sys.version[:3], sys.version[:3],
'site-packages') 'site-packages')
self.assertEqual(dirs[2], wanted) self.assertEqual(dirs[1], wanted)
elif os.sep == '/': elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc # OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 2) self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages') 'site-packages')
self.assertEqual(dirs[0], wanted) self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else: else:
# other platforms # other platforms
self.assertEqual(len(dirs), 2) self.assertEqual(len(dirs), 2)
......
...@@ -92,7 +92,10 @@ Core and Builtins ...@@ -92,7 +92,10 @@ Core and Builtins
Library Library
------- -------
- Issue 17552: new socket.sendfile() method allowing to send a file over a - Issue #21711: support for "site-python" directories has now been removed
from the site module (it was deprecated in 3.4).
- Issue #17552: new socket.sendfile() method allowing to send a file over a
socket by using high-performance os.sendfile() on UNIX. socket by using high-performance os.sendfile() on UNIX.
Patch by Giampaolo Rodola'. Patch by Giampaolo Rodola'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment