diff options
author | Sandro Mani <manisandro@gmail.com> | 2020-06-08 15:28:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 15:28:11 (GMT) |
commit | 8f023a2f664f902a3d0b7a6f64d63afc0d1c15ae (patch) | |
tree | 8aa9027476167eca69c0e17ba8712f624bdb8e15 /Modules | |
parent | c6b292cdeee689f0bfac6c1e2c2d4e4e01fa8d9e (diff) | |
download | cpython-8f023a2f664f902a3d0b7a6f64d63afc0d1c15ae.zip cpython-8f023a2f664f902a3d0b7a6f64d63afc0d1c15ae.tar.gz cpython-8f023a2f664f902a3d0b7a6f64d63afc0d1c15ae.tar.bz2 |
bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var (GH-20605)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/getpath.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index d9829f8..469c9ca 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(); @@ -1297,7 +1297,7 @@ calculate_zip_path(PyCalculatePath *calculate) PyStatus res; /* Path: <PLATLIBDIR> / "pythonXY.zip" */ - wchar_t *path = joinpath2(calculate->platlibdir_macro, L"python" Py_STRINGIFY(PY_MAJOR_VERSION) Py_STRINGIFY(PY_MINOR_VERSION) L".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(); } @@ -1451,10 +1451,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) { @@ -1463,6 +1459,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(); } @@ -1475,7 +1472,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); |