|
24 | 24 | # endif |
25 | 25 | #endif |
26 | 26 |
|
| 27 | +#ifndef PLATLIBDIR |
| 28 | +# error "PLATLIBDIR macro must be defined" |
| 29 | +#endif |
| 30 | + |
27 | 31 |
|
28 | 32 | /* --- Command line options --------------------------------------- */ |
29 | 33 |
|
@@ -110,6 +114,7 @@ PYTHONPATH : '%lc'-separated list of directories prefixed to the\n\ |
110 | 114 | static const char usage_5[] = |
111 | 115 | "PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n" |
112 | 116 | " The default module search path uses %s.\n" |
| 117 | +"PYTHONPLATLIBDIR : override sys.platlibdir.\n" |
113 | 118 | "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n" |
114 | 119 | "PYTHONUTF8: if set to 1, enable the UTF-8 mode.\n" |
115 | 120 | "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n" |
@@ -588,6 +593,7 @@ PyConfig_Clear(PyConfig *config) |
588 | 593 | CLEAR(config->base_prefix); |
589 | 594 | CLEAR(config->exec_prefix); |
590 | 595 | CLEAR(config->base_exec_prefix); |
| 596 | + CLEAR(config->platlibdir); |
591 | 597 |
|
592 | 598 | CLEAR(config->filesystem_encoding); |
593 | 599 | CLEAR(config->filesystem_errors); |
@@ -824,6 +830,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2) |
824 | 830 | COPY_WSTR_ATTR(base_prefix); |
825 | 831 | COPY_WSTR_ATTR(exec_prefix); |
826 | 832 | COPY_WSTR_ATTR(base_exec_prefix); |
| 833 | + COPY_WSTR_ATTR(platlibdir); |
827 | 834 |
|
828 | 835 | COPY_ATTR(site_import); |
829 | 836 | COPY_ATTR(bytes_warning); |
@@ -926,6 +933,7 @@ config_as_dict(const PyConfig *config) |
926 | 933 | SET_ITEM_WSTR(base_prefix); |
927 | 934 | SET_ITEM_WSTR(exec_prefix); |
928 | 935 | SET_ITEM_WSTR(base_exec_prefix); |
| 936 | + SET_ITEM_WSTR(platlibdir); |
929 | 937 | SET_ITEM_INT(site_import); |
930 | 938 | SET_ITEM_INT(bytes_warning); |
931 | 939 | SET_ITEM_INT(inspect); |
@@ -1336,6 +1344,14 @@ config_read_env_vars(PyConfig *config) |
1336 | 1344 | } |
1337 | 1345 | } |
1338 | 1346 |
|
| 1347 | + if(config->platlibdir == NULL) { |
| 1348 | + status = CONFIG_GET_ENV_DUP(config, &config->platlibdir, |
| 1349 | + L"PYTHONPLATLIBDIR", "PYTHONPLATLIBDIR"); |
| 1350 | + if (_PyStatus_EXCEPTION(status)) { |
| 1351 | + return status; |
| 1352 | + } |
| 1353 | + } |
| 1354 | + |
1339 | 1355 | if (config->use_hash_seed < 0) { |
1340 | 1356 | status = config_init_hash_seed(config); |
1341 | 1357 | if (_PyStatus_EXCEPTION(status)) { |
@@ -1731,6 +1747,14 @@ config_read(PyConfig *config) |
1731 | 1747 | } |
1732 | 1748 | } |
1733 | 1749 |
|
| 1750 | + if(config->platlibdir == NULL) { |
| 1751 | + status = CONFIG_SET_BYTES_STR(config, &config->platlibdir, PLATLIBDIR, |
| 1752 | + "PLATLIBDIR macro"); |
| 1753 | + if (_PyStatus_EXCEPTION(status)) { |
| 1754 | + return status; |
| 1755 | + } |
| 1756 | + } |
| 1757 | + |
1734 | 1758 | if (config->_install_importlib) { |
1735 | 1759 | status = _PyConfig_InitPathConfig(config); |
1736 | 1760 | if (_PyStatus_EXCEPTION(status)) { |
@@ -2554,6 +2578,7 @@ PyConfig_Read(PyConfig *config) |
2554 | 2578 | assert(config->exec_prefix != NULL); |
2555 | 2579 | assert(config->base_exec_prefix != NULL); |
2556 | 2580 | } |
| 2581 | + assert(config->platlibdir != NULL); |
2557 | 2582 | assert(config->filesystem_encoding != NULL); |
2558 | 2583 | assert(config->filesystem_errors != NULL); |
2559 | 2584 | assert(config->stdio_encoding != NULL); |
@@ -2704,6 +2729,7 @@ _Py_DumpPathConfig(PyThreadState *tstate) |
2704 | 2729 | DUMP_SYS(_base_executable); |
2705 | 2730 | DUMP_SYS(base_prefix); |
2706 | 2731 | DUMP_SYS(base_exec_prefix); |
| 2732 | + DUMP_SYS(platlibdir); |
2707 | 2733 | DUMP_SYS(executable); |
2708 | 2734 | DUMP_SYS(prefix); |
2709 | 2735 | DUMP_SYS(exec_prefix); |
|
0 commit comments