|
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" |
@@ -586,6 +591,7 @@ PyConfig_Clear(PyConfig *config) |
586 | 591 | CLEAR(config->base_prefix); |
587 | 592 | CLEAR(config->exec_prefix); |
588 | 593 | CLEAR(config->base_exec_prefix); |
| 594 | + CLEAR(config->platlibdir); |
589 | 595 |
|
590 | 596 | CLEAR(config->filesystem_encoding); |
591 | 597 | CLEAR(config->filesystem_errors); |
@@ -822,6 +828,7 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2) |
822 | 828 | COPY_WSTR_ATTR(base_prefix); |
823 | 829 | COPY_WSTR_ATTR(exec_prefix); |
824 | 830 | COPY_WSTR_ATTR(base_exec_prefix); |
| 831 | + COPY_WSTR_ATTR(platlibdir); |
825 | 832 |
|
826 | 833 | COPY_ATTR(site_import); |
827 | 834 | COPY_ATTR(bytes_warning); |
@@ -925,6 +932,7 @@ config_as_dict(const PyConfig *config) |
925 | 932 | SET_ITEM_WSTR(base_prefix); |
926 | 933 | SET_ITEM_WSTR(exec_prefix); |
927 | 934 | SET_ITEM_WSTR(base_exec_prefix); |
| 935 | + SET_ITEM_WSTR(platlibdir); |
928 | 936 | SET_ITEM_INT(site_import); |
929 | 937 | SET_ITEM_INT(bytes_warning); |
930 | 938 | 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)) { |
@@ -2560,6 +2584,7 @@ PyConfig_Read(PyConfig *config) |
2560 | 2584 | assert(config->exec_prefix != NULL); |
2561 | 2585 | assert(config->base_exec_prefix != NULL); |
2562 | 2586 | } |
| 2587 | + assert(config->platlibdir != NULL); |
2563 | 2588 | assert(config->filesystem_encoding != NULL); |
2564 | 2589 | assert(config->filesystem_errors != NULL); |
2565 | 2590 | assert(config->stdio_encoding != NULL); |
@@ -2710,6 +2735,7 @@ _Py_DumpPathConfig(PyThreadState *tstate) |
2710 | 2735 | DUMP_SYS(_base_executable); |
2711 | 2736 | DUMP_SYS(base_prefix); |
2712 | 2737 | DUMP_SYS(base_exec_prefix); |
| 2738 | + DUMP_SYS(platlibdir); |
2713 | 2739 | DUMP_SYS(executable); |
2714 | 2740 | DUMP_SYS(prefix); |
2715 | 2741 | DUMP_SYS(exec_prefix); |
|
0 commit comments