11 changes: 9 additions & 2 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,8 +2739,6 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
return _PyStatus_ERR("can't initialize sys module");
}

#undef SET_SYS_FROM_STRING

/* Updating the sys namespace, returning integer error codes */
#define SET_SYS_FROM_STRING_INT_RESULT(key, value) \
do { \
Expand Down Expand Up @@ -2844,6 +2842,13 @@ _PySys_InitMain(PyThreadState *tstate)
SET_SYS_FROM_WSTR("base_prefix", config->base_prefix);
SET_SYS_FROM_WSTR("exec_prefix", config->exec_prefix);
SET_SYS_FROM_WSTR("base_exec_prefix", config->base_exec_prefix);
{
PyObject *str = PyUnicode_FromString(PLATLIBDIR);
if (str == NULL) {
return -1;
}
SET_SYS_FROM_STRING("platlibdir", str);
}

if (config->pycache_prefix != NULL) {
SET_SYS_FROM_WSTR("pycache_prefix", config->pycache_prefix);
Expand All @@ -2864,6 +2869,7 @@ _PySys_InitMain(PyThreadState *tstate)
#undef COPY_LIST
#undef SET_SYS_FROM_WSTR


/* Set flags to their final values */
SET_SYS_FROM_STRING_INT_RESULT("flags", make_flags(tstate));
/* prevent user from creating new instances */
Expand Down Expand Up @@ -2897,6 +2903,7 @@ _PySys_InitMain(PyThreadState *tstate)
return -1;
}

#undef SET_SYS_FROM_STRING
#undef SET_SYS_FROM_STRING_BORROW
#undef SET_SYS_FROM_STRING_INT_RESULT

Expand Down
53 changes: 38 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ SRCDIRS
THREADHEADERS
LIBPL
PY_ENABLE_SHARED
PLATLIBDIR
LIBPYTHON
EXT_SUFFIX
ALT_SOABI
Expand Down Expand Up @@ -782,7 +783,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -840,6 +840,7 @@ with_dtrace
with_libm
with_libc
enable_big_digits
with_platlibdir
with_computed_gotos
with_ensurepip
with_openssl
Expand Down Expand Up @@ -897,7 +898,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -1150,15 +1150,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1296,7 +1287,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1449,7 +1440,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -1571,6 +1561,8 @@ Optional Packages:
system-dependent)
--with-libc=STRING override libc C library to STRING (default is
system-dependent)
--with-platlibdir=DIRNAME
Python library directory name (default is "lib")
--with-computed-gotos enable computed gotos in evaluation loop (enabled by
default on supported compilers)
--with-ensurepip[=install|upgrade|no]
Expand Down Expand Up @@ -15258,10 +15250,41 @@ else
fi


# Check for --with-libdir-name
# /usr/$LIDIRNAME/python$VERSION

PLATLIBDIR="lib"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-platlibdir" >&5
$as_echo_n "checking for --with-platlibdir... " >&6; }

# Check whether --with-platlibdir was given.
if test "${with_platlibdir+set}" = set; then :
withval=$with_platlibdir;
# ignore 3 options:
# --with-platlibdir
# --with-platlibdir=
# --without-platlibdir
if test -n "$withval" -a "$withval" != yes -a "$withval" != no
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
PLATLIBDIR="$withval"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi




if test x$PLATFORM_TRIPLET = x; then
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
else
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
fi


Expand Down
28 changes: 26 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4723,12 +4723,36 @@ else
LIBPYTHON=''
fi


# Check for --with-libdir-name
# /usr/$LIDIRNAME/python$VERSION
AC_SUBST(PLATLIBDIR)
PLATLIBDIR="lib"
AC_MSG_CHECKING(for --with-platlibdir)
AC_ARG_WITH(platlibdir,
AS_HELP_STRING([--with-platlibdir=DIRNAME],
[Python library directory name (default is "lib")]),
[
# ignore 3 options:
# --with-platlibdir
# --with-platlibdir=
# --without-platlibdir
if test -n "$withval" -a "$withval" != yes -a "$withval" != no
then
AC_MSG_RESULT(yes)
PLATLIBDIR="$withval"
else
AC_MSG_RESULT(no)
fi],
[AC_MSG_RESULT(no)])


dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
AC_SUBST(PY_ENABLE_SHARED)
if test x$PLATFORM_TRIPLET = x; then
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}"
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
else
LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
fi
AC_SUBST(LIBPL)

Expand Down