Skip to content

Commit c4b53af

Browse files
committed
Issue python#28046: Remove platform-specific directories from sys.path
1 parent b44aceb commit c4b53af

File tree

10 files changed

+24
-37
lines changed

10 files changed

+24
-37
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Doc/venv/
2121
Lib/distutils/command/*.pdb
2222
Lib/lib2to3/*.pickle
2323
Lib/test/data/*
24-
Lib/plat-mac/errors.rsrc.df.rsrc
2524
Makefile
2625
Makefile.pre
2726
Misc/python.pc

.hgignore

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ python-config$
2626
python-config.py$
2727
reflog.txt$
2828
tags$
29-
Lib/plat-mac/errors.rsrc.df.rsrc
3029
Misc/python.pc
3130
Misc/python-config.sh$
3231
Modules/Setup$

Lib/sysconfig.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ def get_makefile_filename():
341341
config_dir_name += '-%s' % sys.implementation._multiarch
342342
return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
343343

344+
345+
def _get_sysconfigdata_name():
346+
return '_sysconfigdata_{abi}_{platform}_{multiarch}'.format(
347+
abi=sys.abiflags,
348+
platform=sys.platform,
349+
multiarch=getattr(sys.implementation, '_multiarch', ''),
350+
)
351+
352+
344353
def _generate_posix_vars():
345354
"""Generate the Python module containing build-time variables."""
346355
import pprint
@@ -381,7 +390,7 @@ def _generate_posix_vars():
381390
# _sysconfigdata module manually and populate it with the build vars.
382391
# This is more than sufficient for ensuring the subsequent call to
383392
# get_platform() succeeds.
384-
name = '_sysconfigdata_' + sys.abiflags
393+
name = _get_sysconfigdata_name()
385394
if 'darwin' in sys.platform:
386395
import types
387396
module = types.ModuleType(name)
@@ -407,7 +416,7 @@ def _generate_posix_vars():
407416
def _init_posix(vars):
408417
"""Initialize the module as appropriate for POSIX systems."""
409418
# _sysconfigdata is generated at build time, see _generate_posix_vars()
410-
name = '_sysconfigdata_' + sys.abiflags
419+
name = _get_sysconfigdata_name()
411420
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
412421
build_time_vars = _temp.build_time_vars
413422
vars.update(build_time_vars)

Mac/BuildScript/build-installer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,8 @@ def buildPython():
12921292

12931293
import pprint
12941294
if getVersionMajorMinor() >= (3, 6):
1295-
path = os.path.join(path_to_lib, 'plat-darwin', '_sysconfigdata_m.py')
1295+
# XXX this is extra-fragile
1296+
path = os.path.join(path_to_lib, '_sysconfigdata_m_darwin_darwin.py')
12961297
else:
12971298
path = os.path.join(path_to_lib, '_sysconfigdata.py')
12981299
fp = open(path, 'r')

Makefile.pre.in

+5-13
Original file line numberDiff line numberDiff line change
@@ -1178,8 +1178,6 @@ maninstall: altmaninstall
11781178
(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python3.1)
11791179

11801180
# Install the library
1181-
PLATDIR= @PLATDIR@
1182-
MACHDEPS= $(PLATDIR)
11831181
XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
11841182
LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
11851183
tkinter/test/test_ttk site-packages test \
@@ -1238,8 +1236,8 @@ LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
12381236
multiprocessing multiprocessing/dummy \
12391237
unittest unittest/test unittest/test/testmock \
12401238
venv venv/scripts venv/scripts/posix \
1241-
curses pydoc_data $(MACHDEPS)
1242-
libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
1239+
curses pydoc_data
1240+
libinstall: build_all $(srcdir)/Modules/xxmodule.c
12431241
@for i in $(SCRIPTDIR) $(LIBDEST); \
12441242
do \
12451243
if test ! -d $(DESTDIR)$$i; then \
@@ -1294,10 +1292,10 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
12941292
esac; \
12951293
done; \
12961294
done
1297-
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS).py \
1298-
$(DESTDIR)$(LIBDEST)/$(PLATDIR); \
1295+
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
1296+
$(DESTDIR)$(LIBDEST); \
12991297
echo $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS).py \
1300-
$(LIBDEST)/$(PLATDIR)
1298+
$(LIBDEST)
13011299
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
13021300
if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
13031301
$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
@@ -1335,9 +1333,6 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
13351333
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
13361334
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
13371335

1338-
$(srcdir)/Lib/$(PLATDIR):
1339-
mkdir $(srcdir)/Lib/$(PLATDIR)
1340-
13411336
python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
13421337
# Substitution happens here, as the completely-expanded BINDIR
13431338
# is not available in configure
@@ -1614,9 +1609,6 @@ clobber: clean profile-removal
16141609
-rm -rf build platform
16151610
-rm -rf $(PYTHONFRAMEWORKDIR)
16161611
-rm -f python-config.py python-config
1617-
if [ -n "$(MULTIARCH)" ]; then \
1618-
rm -rf $(srcdir)/Lib/$(PLATDIR); \
1619-
fi
16201612

16211613
# Make things extra clean, before making a distribution:
16221614
# remove all generated files, even Makefile[.pre]

Misc/NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 1
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #28046: Remove platform-specific directories from sys.path.
14+
1315
- Issue #25758: Prevents zipimport from unnecessarily encoding a filename
1416
(patch by Eryk Sun)
1517

PC/getpathp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
is set, we believe it. Otherwise, we use the path of our host .EXE's
2727
to try and locate on of our "landmarks" and deduce our home.
2828
- If we DO have a Python Home: The relevant sub-directories (Lib,
29-
plat-win, etc) are based on the Python Home
29+
DLLs, etc) are based on the Python Home
3030
- If we DO NOT have a Python Home, the core Python Path is
3131
loaded from the registry. This is the main PythonPath key,
3232
and both HKLM and HKCU are combined to form the path)
3333
3434
* Iff - we can not locate the Python Home, have not had a PYTHONPATH
3535
specified, and can't locate any Registry entries (ie, we have _nothing_
3636
we can assume is a good path), a default path with relative entries is
37-
used (eg. .\Lib;.\plat-win, etc)
37+
used (eg. .\Lib;.\DLLs, etc)
3838
3939
4040
If a sys.path file exists adjacent to python.exe, it must contain a

Tools/msi/make_zip.py

-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ def include_in_lib(p):
6767
if p.is_dir():
6868
if name in EXCLUDE_FROM_LIBRARY:
6969
return False
70-
if name.startswith('plat-'):
71-
return False
7270
if name == 'test' and p.parts[-2].lower() == 'lib':
7371
return False
7472
if name in {'test', 'tests'} and p.parts[-3].lower() == 'lib':

configure

+1-8
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ EGREP
712712
NO_AS_NEEDED
713713
MULTIARCH_CPPFLAGS
714714
PLATFORM_TRIPLET
715-
PLATDIR
716715
MULTIARCH
717716
ac_ct_CXX
718717
MAINCC
@@ -2929,7 +2928,7 @@ $as_echo_n "checking for python interpreter for cross build... " >&6; }
29292928
fi
29302929
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
29312930
$as_echo "$interp" >&6; }
2932-
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
2931+
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib '$interp
29332932
fi
29342933
# Used to comment out stuff for rebuilding generated files
29352934
GENERATED_COMMENT='#'
@@ -5361,12 +5360,6 @@ if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
53615360
elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
53625361
MULTIARCH=$PLATFORM_TRIPLET
53635362
fi
5364-
if test x$PLATFORM_TRIPLET = x; then
5365-
PLATDIR=plat-$MACHDEP
5366-
else
5367-
PLATDIR=plat-$PLATFORM_TRIPLET
5368-
fi
5369-
53705363

53715364
if test x$MULTIARCH != x; then
53725365
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""

configure.ac

+1-7
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ if test "$cross_compiling" = yes; then
7878
AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
7979
fi
8080
AC_MSG_RESULT($interp)
81-
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
81+
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib '$interp
8282
fi
8383
# Used to comment out stuff for rebuilding generated files
8484
GENERATED_COMMENT='#'
@@ -910,12 +910,6 @@ if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
910910
elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
911911
MULTIARCH=$PLATFORM_TRIPLET
912912
fi
913-
if test x$PLATFORM_TRIPLET = x; then
914-
PLATDIR=plat-$MACHDEP
915-
else
916-
PLATDIR=plat-$PLATFORM_TRIPLET
917-
fi
918-
AC_SUBST(PLATDIR)
919913
AC_SUBST(PLATFORM_TRIPLET)
920914
if test x$MULTIARCH != x; then
921915
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""

0 commit comments

Comments
 (0)