Skip to content

Commit 3b2f0f0

Browse files
committed
Issue #19375: The site module adding a "site-python" directory to sys.path, if it exists, is now deprecated.
1 parent 79aa68d commit 3b2f0f0

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

Doc/library/site.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Unix and Macintosh). For each of the distinct head-tail combinations, it sees
3838
if it refers to an existing directory, and if so, adds it to ``sys.path`` and
3939
also inspects the newly added path for configuration files.
4040

41+
.. deprecated:: 3.4
42+
Support for the "site-python" directory will be removed in 3.5.
43+
4144
If a file named "pyvenv.cfg" exists one directory above sys.executable,
4245
sys.prefix and sys.exec_prefix are set to that directory and
4346
it is also checked for site-packages and site-python (sys.base_prefix and

Doc/whatsnew/3.4.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ Deprecated functions and types of the C API
685685
Deprecated features
686686
-------------------
687687

688-
* No feature deprecations are planned for Python 3.4.
688+
* The site module adding a "site-python" directory to sys.path, if it
689+
exists, is deprecated (:issue:`19375`).
689690

690691

691692
Porting to Python 3.4

Lib/site.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ def addsitepackages(known_paths, prefixes=None):
326326
"""Add site-packages (and possibly site-python) to sys.path"""
327327
for sitedir in getsitepackages(prefixes):
328328
if os.path.isdir(sitedir):
329+
if "site-python" in sitedir:
330+
import warnings
331+
warnings.warn('"site-python" directories will not be '
332+
'supported in 3.5 anymore',
333+
DeprecationWarning)
329334
addsitedir(sitedir, known_paths)
330335

331336
return known_paths

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Core and Builtins
2727
Library
2828
-------
2929

30+
- Issue #19375: The site module adding a "site-python" directory to sys.path,
31+
if it exists, is now deprecated.
32+
3033
- Issue #19379: Lazily import linecache in the warnings module, to make
3134
startup with warnings faster until a warning gets printed.
3235

0 commit comments

Comments
 (0)