summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-08 17:36:13 (GMT)
committerGitHub <noreply@github.com>2020-06-08 17:36:13 (GMT)
commit817506432dd1908cd154500ef18dc276b8dd7071 (patch)
treea52e893c973a14557ff2078b074b184d4b6f418a /Modules
parent298c8c895f0d4fdd23a16f959efac83039fa1d19 (diff)
downloadcpython-817506432dd1908cd154500ef18dc276b8dd7071.zip
cpython-817506432dd1908cd154500ef18dc276b8dd7071.tar.gz
cpython-817506432dd1908cd154500ef18dc276b8dd7071.tar.bz2
bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var (GH-20605) (GH-20725)
(cherry picked from commit 8f023a2f664f902a3d0b7a6f64d63afc0d1c15ae) Co-authored-by: Sandro Mani <manisandro@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/getpath.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 94e06b3..2a7971d 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -105,8 +105,8 @@ extern "C" {
#if (!defined(PREFIX) || !defined(EXEC_PREFIX) \
- || !defined(VERSION) || !defined(VPATH) || !defined(PLATLIBDIR))
-#error "PREFIX, EXEC_PREFIX, VERSION, VPATH and PLATLIBDIR macros must be defined"
+ || !defined(VERSION) || !defined(VPATH))
+#error "PREFIX, EXEC_PREFIX, VERSION and VPATH macros must be defined"
#endif
#ifndef LANDMARK
@@ -128,7 +128,6 @@ typedef struct {
wchar_t *pythonpath_macro; /* PYTHONPATH macro */
wchar_t *prefix_macro; /* PREFIX macro */
wchar_t *exec_prefix_macro; /* EXEC_PREFIX macro */
- wchar_t *platlibdir_macro; /* PLATLIBDIR macro */
wchar_t *vpath_macro; /* VPATH macro */
wchar_t *lib_python; /* "lib/pythonX.Y" */
@@ -138,6 +137,7 @@ typedef struct {
int warnings;
const wchar_t *pythonpath_env;
+ const wchar_t *platlibdir;
wchar_t *argv0_path;
wchar_t *zip_path;
@@ -811,7 +811,7 @@ calculate_exec_prefix(PyCalculatePath *calculate, _PyPathConfig *pathconfig)
}
/* <PLATLIBDIR> / "lib-dynload" */
- wchar_t *lib_dynload = joinpath2(calculate->platlibdir_macro,
+ wchar_t *lib_dynload = joinpath2(calculate->platlibdir,
L"lib-dynload");
if (lib_dynload == NULL) {
return _PyStatus_NO_MEMORY();
@@ -1296,8 +1296,8 @@ calculate_zip_path(PyCalculatePath *calculate)
{
PyStatus res;
- /* Path: <PLATLIBDIR> / "python00.zip" */
- wchar_t *path = joinpath2(calculate->platlibdir_macro, L"python00.zip");
+ /* Path: <PLATLIBDIR> / "pythonXY.zip" */
+ wchar_t *path = joinpath2(calculate->platlibdir, L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) L".zip");
if (path == NULL) {
return _PyStatus_NO_MEMORY();
}
@@ -1456,10 +1456,6 @@ calculate_init(PyCalculatePath *calculate, const PyConfig *config)
if (!calculate->vpath_macro) {
return DECODE_LOCALE_ERR("VPATH macro", len);
}
- calculate->platlibdir_macro = Py_DecodeLocale(PLATLIBDIR, &len);
- if (!calculate->platlibdir_macro) {
- return DECODE_LOCALE_ERR("PLATLIBDIR macro", len);
- }
calculate->lib_python = Py_DecodeLocale(PLATLIBDIR "/python" VERSION, &len);
if (!calculate->lib_python) {
@@ -1468,6 +1464,7 @@ calculate_init(PyCalculatePath *calculate, const PyConfig *config)
calculate->warnings = config->pathconfig_warnings;
calculate->pythonpath_env = config->pythonpath_env;
+ calculate->platlibdir = config->platlibdir;
return _PyStatus_OK();
}
@@ -1480,7 +1477,6 @@ calculate_free(PyCalculatePath *calculate)
PyMem_RawFree(calculate->prefix_macro);
PyMem_RawFree(calculate->exec_prefix_macro);
PyMem_RawFree(calculate->vpath_macro);
- PyMem_RawFree(calculate->platlibdir_macro);
PyMem_RawFree(calculate->lib_python);
PyMem_RawFree(calculate->path_env);
PyMem_RawFree(calculate->zip_path);