@@ -33,7 +33,7 @@ pl_python_group_prelude (void)
3333 chef_prep_this (pl_python_group, gsr);
3434
3535 chef_set_recipe_created_on (this, "2023-09-03");
36- chef_set_recipe_last_updated (this, "2025-12 -31");
36+ chef_set_recipe_last_updated (this, "2026-03 -31");
3737 chef_set_sources_last_updated (this, "2025-09-30");
3838
3939 chef_set_chef (this, "@happy-game");
@@ -105,6 +105,13 @@ pl_python_get_py_program_name (char **prog_name)
105105 */
106106 py_exist = chsrc_check_program ("python3");
107107
108+ bool python3_is_winstore_placeholder = false;
109+
110+ const int winstore_python_status_code = 9009;
111+
112+ const char *winstore_placeholder_cn = "是微软商店的占位符,并非真正可用的 Python";
113+ const char *winstore_placeholder_en = "a placeholder of Microsoft Store, not the real Python";
114+
108115 if (py_exist)
109116 {
110117 *prog_name = "python3";
@@ -113,16 +120,19 @@ pl_python_get_py_program_name (char **prog_name)
113120 if (xy.on_windows)
114121 {
115122 int status = xy_run_get_status ("python3 --version");
116- if (status == 9009 )
123+ if (status == winstore_python_status_code )
117124 {
118- chsrc_error2 (CHINESE ? "用户环境中的 `python3` 命令,是微软商店的占位符,并非真正可用的 Python。请安装真正的 Python 后重试!"
119- : "`python3` in your environment is a placeholder of Microsoft Store, not the real Python which can be used, please install the real Python and try again!");
120- exit (Exit_UserCause);
125+ python3_is_winstore_placeholder = true;
126+ *prog_name = NULL;
127+ // https://github.com/RubyMetric/chsrc/issues/351
128+ // 仅警告,不要直接退出,因为用户环境中还可能存在真正的 `python` 命令
129+ chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python3` 命令,", winstore_placeholder_cn)
130+ : xy_2strcat ("`python3` in your environment is ", winstore_placeholder_en));
121131 }
122132 }
123-
124133 }
125- else
134+
135+ if (!py_exist || python3_is_winstore_placeholder)
126136 {
127137 /**
128138 * 不要直接:
@@ -134,7 +144,22 @@ pl_python_get_py_program_name (char **prog_name)
134144 */
135145 py_exist = chsrc_check_program ("python");
136146
137- if (py_exist) *prog_name = "python";
147+ if (py_exist)
148+ {
149+ if (xy.on_windows)
150+ {
151+ int status = xy_run_get_status ("python --version");
152+ if (status == winstore_python_status_code)
153+ {
154+ chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python` 命令,也", winstore_placeholder_cn)
155+ : xy_2strcat ("`python` in your environment is also ", winstore_placeholder_en));
156+ chsrc_error (CHINESE ? "请安装真正的 Python 后重试!"
157+ : "Please install the real Python and try again!");
158+ exit (Exit_UserCause);
159+ }
160+ }
161+ *prog_name = "python";
162+ }
138163 else
139164 {
140165 chsrc_error ("未找到 Python 相关命令,请检查是否存在");
0 commit comments