Skip to content

Commit 62793c2

Browse files
committed
support lib-vs-lib64 distinction
Originally from Fedora, now clearly not the same as eb5f8e0 in this repo. Patch: python-3.6.0-multilib-new.patch
1 parent 0c9d233 commit 62793c2

File tree

11 files changed

+65
-26
lines changed

11 files changed

+65
-26
lines changed

Lib/distutils/command/install.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
INSTALL_SCHEMES = {
3131
'unix_prefix': {
3232
'purelib': '$base/lib/python$py_version_short/site-packages',
33-
'platlib': '$platbase/lib/python$py_version_short/site-packages',
33+
'platlib': '$platbase/$platlibdir/python$py_version_short/site-packages',
3434
'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
3535
'scripts': '$base/bin',
3636
'data' : '$base',
@@ -284,7 +284,7 @@ def finalize_options(self):
284284
# about needing recursive variable expansion (shudder).
285285

286286
py_version = sys.version.split()[0]
287-
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
287+
(prefix, exec_prefix, platlibdir) = get_config_vars('prefix', 'exec_prefix', 'platlibdir')
288288
try:
289289
abiflags = sys.abiflags
290290
except AttributeError:
@@ -301,6 +301,7 @@ def finalize_options(self):
301301
'sys_exec_prefix': exec_prefix,
302302
'exec_prefix': exec_prefix,
303303
'abiflags': abiflags,
304+
'platlibdir': platlibdir,
304305
}
305306

306307
if HAS_USER_SITE:

Lib/distutils/sysconfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
129129
prefix = plat_specific and EXEC_PREFIX or PREFIX
130130

131131
if os.name == "posix":
132+
libdir = plat_specific and get_config_var("platlibdir") or "lib"
132133
libpython = os.path.join(prefix,
133-
"lib", "python" + get_python_version())
134+
libdir, "python" + get_python_version())
134135
if standard_lib:
135136
return libpython
136137
else:

Lib/pydoc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class or function within a module or module in a package. If the
6363
import platform
6464
import re
6565
import sys
66+
import sysconfig
6667
import time
6768
import tokenize
6869
import urllib.parse
@@ -395,9 +396,7 @@ def fail(self, object, name=None, *args):
395396

396397
docmodule = docclass = docroutine = docother = docproperty = docdata = fail
397398

398-
def getdocloc(self, object,
399-
basedir=os.path.join(sys.base_exec_prefix, "lib",
400-
"python%d.%d" % sys.version_info[:2])):
399+
def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')):
401400
"""Return the location of module docs or None"""
402401

403402
try:

Lib/site.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,15 @@ def getsitepackages(prefixes=None):
304304
seen.add(prefix)
305305

306306
if os.sep == '/':
307-
sitepackages.append(os.path.join(prefix, "lib",
307+
from sysconfig import get_config_var
308+
platlibdir = get_config_var("platlibdir")
309+
sitepackages.append(os.path.join(prefix, platlibdir,
308310
"python%d.%d" % sys.version_info[:2],
309311
"site-packages"))
312+
if platlibdir != "lib":
313+
sitepackages.append(os.path.join(prefix, "lib",
314+
"python%d.%d" % sys.version_info[:2],
315+
"site-packages"))
310316
else:
311317
sitepackages.append(prefix)
312318
sitepackages.append(os.path.join(prefix, "lib", "site-packages"))

Lib/sysconfig.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
_INSTALL_SCHEMES = {
2222
'posix_prefix': {
23-
'stdlib': '{installed_base}/lib/python{py_version_short}',
24-
'platstdlib': '{platbase}/lib/python{py_version_short}',
23+
'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}',
24+
'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}',
2525
'purelib': '{base}/lib/python{py_version_short}/site-packages',
26-
'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
26+
'platlib': '{platbase}/{platlibdir}/python{py_version_short}/site-packages',
2727
'include':
2828
'{installed_base}/include/python{py_version_short}{abiflags}',
2929
'platinclude':

Lib/test/test_site.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ def test_getsitepackages(self):
264264
self.assertEqual(dirs[1], wanted)
265265
elif os.sep == '/':
266266
# OS X non-framework builds, Linux, FreeBSD, etc
267-
self.assertEqual(len(dirs), 1)
268-
wanted = os.path.join('xoxo', 'lib',
267+
platlibdir = sysconfig.get_config_var('platlibdir')
268+
self.assertTrue(len(dirs) in (1,2))
269+
wanted = os.path.join('xoxo', platlibdir,
269270
'python%d.%d' % sys.version_info[:2],
270271
'site-packages')
271272
self.assertEqual(dirs[0], wanted)

Lib/test/test_sysconfig.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def test_user_similar(self):
279279
# is similar to the global posix_prefix one
280280
base = get_config_var('base')
281281
user = get_config_var('userbase')
282+
platlibdir = get_config_var("platlibdir")
282283
# the global scheme mirrors the distinction between prefix and
283284
# exec-prefix but not the user scheme, so we have to adapt the paths
284285
# before comparing (issue #9100)
@@ -293,8 +294,19 @@ def test_user_similar(self):
293294
# before comparing
294295
global_path = global_path.replace(sys.base_prefix, sys.prefix)
295296
base = base.replace(sys.base_prefix, sys.prefix)
297+
298+
if platlibdir != "lib":
299+
platbase = os.path.join(base, platlibdir)
300+
purebase = os.path.join(base, "lib")
301+
userlib = os.path.join(user, "lib")
302+
# replace platbase first because usually purebase is a prefix of platbase
303+
# /usr/lib is prefix of /usr/lib64 and would get replaced first
304+
modified_path = global_path.replace(platbase, userlib, 1).replace(purebase, userlib, 1)
305+
else:
306+
modified_path = global_path.replace(base, user, 1)
307+
296308
user_path = get_path(name, 'posix_user')
297-
self.assertEqual(user_path, global_path.replace(base, user, 1))
309+
self.assertEqual(user_path, modified_path)
298310

299311
def test_main(self):
300312
# just making sure _main() runs and returns things in the stdout

Lib/trace.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import os
5454
import re
5555
import sys
56+
import sysconfig
5657
import token
5758
import tokenize
5859
import inspect
@@ -670,9 +671,8 @@ def main():
670671
opts = parser.parse_args()
671672

672673
if opts.ignore_dir:
673-
rel_path = 'lib', 'python{0.major}.{0.minor}'.format(sys.version_info)
674-
_prefix = os.path.join(sys.base_prefix, *rel_path)
675-
_exec_prefix = os.path.join(sys.base_exec_prefix, *rel_path)
674+
_prefix = sysconfig.get_path("stdlib")
675+
_exec_prefix = sysconfig.get_path("platstdlib")
676676

677677
def parse_ignore_dir(s):
678678
s = os.path.expanduser(os.path.expandvars(s))

Makefile.pre.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@ exec_prefix= @exec_prefix@
133133
# Install prefix for data files
134134
datarootdir= @datarootdir@
135135

136+
# Name of "lib" directory under prefix
137+
platlibdir= @platlibdir@
138+
136139
# Expanded directories
137140
BINDIR= @bindir@
138141
LIBDIR= @libdir@
139142
MANDIR= @mandir@
140143
INCLUDEDIR= @includedir@
141144
CONFINCLUDEDIR= $(exec_prefix)/include
142-
SCRIPTDIR= $(prefix)/lib
145+
SCRIPTDIR= @libdir@
143146
ABIFLAGS= @ABIFLAGS@
144147

145148
# Detailed destination directories
@@ -746,6 +749,7 @@ Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
746749
-DEXEC_PREFIX='"$(exec_prefix)"' \
747750
-DVERSION='"$(VERSION)"' \
748751
-DVPATH='"$(VPATH)"' \
752+
-DPLATLIBDIR='"$(platlibdir)"' \
749753
-o $@ $(srcdir)/Modules/getpath.c
750754

751755
Programs/python.o: $(srcdir)/Programs/python.c

Modules/getpath.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@
5151
* pybuilddir.txt. If the landmark is found, we're done.
5252
*
5353
* For the remaining steps, the prefix landmark will always be
54-
* lib/python$VERSION/os.py and the exec_prefix will always be
55-
* lib/python$VERSION/lib-dynload, where $VERSION is Python's version
56-
* number as supplied by the Makefile. Note that this means that no more
54+
* $lib/python$VERSION/os.py and the exec_prefix will always be
55+
* $lib/python$VERSION/lib-dynload, where $VERSION is Python's version
56+
* number and $lib is PLATLIBDIR as supplied by the Makefile. (usually
57+
* "lib", "lib32" or "lib64"). Note that this means that no more
5758
* build directory checking is performed; if the first step did not find
5859
* the landmarks, the assumption is that python is running from an
5960
* installed setup.
@@ -82,7 +83,7 @@
8283
* containing the shared library modules is appended. The environment
8384
* variable $PYTHONPATH is inserted in front of it all. Finally, the
8485
* prefix and exec_prefix globals are tweaked so they reflect the values
85-
* expected by other code, by stripping the "lib/python$VERSION/..." stuff
86+
* expected by other code, by stripping the "$lib/python$VERSION/..." stuff
8687
* off. If either points to the build directory, the globals are reset to
8788
* the corresponding preprocessor variables (so sys.prefix will reflect the
8889
* installation location, even though sys.path points into the build
@@ -101,8 +102,8 @@
101102
#endif
102103

103104

104-
#if !defined(PREFIX) || !defined(EXEC_PREFIX) || !defined(VERSION) || !defined(VPATH)
105-
#error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined"
105+
#if !defined(PREFIX) || !defined(EXEC_PREFIX) || !defined(VERSION) || !defined(VPATH) || !defined(PLATLIBDIR)
106+
#error "PREFIX, EXEC_PREFIX, VERSION, VPATH and PLATLIBDIR must be constant defined"
106107
#endif
107108

108109
#ifndef LANDMARK
@@ -494,7 +495,7 @@ calculate_path(void)
494495
_pythonpath = Py_DecodeLocale(PYTHONPATH, NULL);
495496
_prefix = Py_DecodeLocale(PREFIX, NULL);
496497
_exec_prefix = Py_DecodeLocale(EXEC_PREFIX, NULL);
497-
lib_python = Py_DecodeLocale("lib/python" VERSION, NULL);
498+
lib_python = Py_DecodeLocale(PLATLIBDIR "/python" VERSION, NULL);
498499

499500
if (!_pythonpath || !_prefix || !_exec_prefix || !lib_python) {
500501
Py_FatalError(

configure.ac

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4768,12 +4768,26 @@ AC_MSG_CHECKING(LDVERSION)
47684768
LDVERSION='$(VERSION)$(ABIFLAGS)'
47694769
AC_MSG_RESULT($LDVERSION)
47704770

4771+
# platlibdir must be defined before LIBPL definition
4772+
AC_MSG_CHECKING(for custom platlibdir)
4773+
AC_ARG_WITH(custom-platlibdir,
4774+
[AS_HELP_STRING([--with-custom-platlibdir=<libdirname>],
4775+
[set the platlibdir name to a custom string])],
4776+
[],
4777+
[with_custom_platlibdir=yes])
4778+
AS_CASE($with_custom_platlibdir,
4779+
[yes],[platlibdir=`basename ${libdir}`],
4780+
[no],[platlibdir=lib],
4781+
[platlibdir=$with_custom_platlibdir])
4782+
AC_MSG_RESULT($platlibdir)
4783+
AC_SUBST(platlibdir)
4784+
47714785
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
47724786
AC_SUBST(PY_ENABLE_SHARED)
47734787
if test x$PLATFORM_TRIPLET = x; then
4774-
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
4788+
LIBPL='$(prefix)'"/${platlibdir}/python${VERSION}/config-${LDVERSION}"
47754789
else
4776-
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
4790+
LIBPL='$(prefix)'"/${platlibdir}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
47774791
fi
47784792
AC_SUBST(LIBPL)
47794793

0 commit comments

Comments
 (0)