summaryrefslogtreecommitdiffstats
path: root/PC/python_uwp.cpp
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-24 22:31:48 (GMT)
committerGitHub <noreply@github.com>2019-07-24 22:31:48 (GMT)
commit4b7ce105ff80467bf4d79c413d7adc256b824153 (patch)
treebf7343a25f58d5f47ada3d52d965d68963aa7853 /PC/python_uwp.cpp
parent0cdb21d6eb3428abe50a55f9291ca0e9728654d9 (diff)
downloadcpython-4b7ce105ff80467bf4d79c413d7adc256b824153.zip
cpython-4b7ce105ff80467bf4d79c413d7adc256b824153.tar.gz
cpython-4b7ce105ff80467bf4d79c413d7adc256b824153.tar.bz2
bpo-37672: Switch Windows Store package to use pip.ini for user mode (GH-14939)
(cherry picked from commit 123536fdab7b8def15c859aa70232bc55ec73096) Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'PC/python_uwp.cpp')
-rw-r--r--PC/python_uwp.cpp75
1 files changed, 42 insertions, 33 deletions
diff --git a/PC/python_uwp.cpp b/PC/python_uwp.cpp
index 2352f45..06c1dd3 100644
--- a/PC/python_uwp.cpp
+++ b/PC/python_uwp.cpp
@@ -122,6 +122,12 @@ set_process_name(PyConfig *config)
break;
}
}
+ size_t i = executable.find_last_of(L"/\\");
+ if (i == std::wstring::npos) {
+ executable = PROGNAME;
+ } else {
+ executable.replace(i + 1, std::wstring::npos, PROGNAME);
+ }
}
if (!home.empty()) {
@@ -163,10 +169,29 @@ wmain(int argc, wchar_t **argv)
PyPreConfig preconfig;
PyConfig config;
+ const wchar_t *moduleName = NULL;
+ const wchar_t *p = wcsrchr(argv[0], L'\\');
+ if (!p) {
+ p = argv[0];
+ }
+ if (p) {
+ if (*p == L'\\') {
+ p++;
+ }
+
+ if (wcsnicmp(p, L"pip", 3) == 0) {
+ moduleName = L"pip";
+ } else if (wcsnicmp(p, L"idle", 4) == 0) {
+ moduleName = L"idlelib";
+ }
+ }
+
PyPreConfig_InitPythonConfig(&preconfig);
- status = Py_PreInitializeFromArgs(&preconfig, argc, argv);
- if (PyStatus_Exception(status)) {
- goto fail_without_config;
+ if (!moduleName) {
+ status = Py_PreInitializeFromArgs(&preconfig, argc, argv);
+ if (PyStatus_Exception(status)) {
+ goto fail_without_config;
+ }
}
status = PyConfig_InitPythonConfig(&config);
@@ -178,48 +203,32 @@ wmain(int argc, wchar_t **argv)
if (PyStatus_Exception(status)) {
goto fail;
}
+ if (moduleName) {
+ config.parse_argv = 0;
+ }
status = set_process_name(&config);
if (PyStatus_Exception(status)) {
goto fail;
}
- const wchar_t *p = _wgetenv(L"PYTHONUSERBASE");
+ p = _wgetenv(L"PYTHONUSERBASE");
if (!p || !*p) {
_wputenv_s(L"PYTHONUSERBASE", get_user_base().c_str());
}
- p = wcsrchr(argv[0], L'\\');
- if (!p) {
- p = argv[0];
- }
- if (p) {
- if (*p == L'\\') {
- p++;
+ if (moduleName) {
+ status = PyConfig_SetString(&config, &config.run_module, moduleName);
+ if (PyStatus_Exception(status)) {
+ goto fail;
}
-
- const wchar_t *moduleName = NULL;
- if (wcsnicmp(p, L"pip", 3) == 0) {
- moduleName = L"pip";
- /* No longer required when pip 19.1 is added */
- _wputenv_s(L"PIP_USER", L"true");
- } else if (wcsnicmp(p, L"idle", 4) == 0) {
- moduleName = L"idlelib";
+ status = PyConfig_SetString(&config, &config.run_filename, NULL);
+ if (PyStatus_Exception(status)) {
+ goto fail;
}
-
- if (moduleName) {
- status = PyConfig_SetString(&config, &config.run_module, moduleName);
- if (PyStatus_Exception(status)) {
- goto fail;
- }
- status = PyConfig_SetString(&config, &config.run_filename, NULL);
- if (PyStatus_Exception(status)) {
- goto fail;
- }
- status = PyConfig_SetString(&config, &config.run_command, NULL);
- if (PyStatus_Exception(status)) {
- goto fail;
- }
+ status = PyConfig_SetString(&config, &config.run_command, NULL);
+ if (PyStatus_Exception(status)) {
+ goto fail;
}
}