Skip to content

Commit ee92d1f

Browse files
committed
Windows 上额外检测 python3 命令是否为微软商店占位符
[GitHub #327]
1 parent 528c64e commit ee92d1f

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

src/recipe/lang/Python/Python.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** ------------------------------------------------------------
22
* SPDX-License-Identifier: GPL-3.0-or-later
33
* -------------------------------------------------------------
4-
* File Authors : Aoran Zeng <[email protected]>
5-
* Contributors : happy game <[email protected]>
4+
* File Authors : @ccmywish
5+
* Contributors : @happy-game
66
* |
77
* Created On : <2023-09-03>
8-
* Last Modified : <2025-07-14>
8+
* Last Modified : <2025-12-31>
99
* ------------------------------------------------------------*/
1010

1111
void

src/recipe/lang/Python/common.h

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def_target(pl_python_group, "python/pypi/py");
99
/**
1010
* @note 测速链接的这个前缀是 ${host}/pipi/web/pacakges/56/e4....
1111
* 下面有几个镜像站微调了这个路径,我们只要确认能找到 packages 目录就好
12-
* @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的
12+
*
13+
* @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的文件
1314
*
1415
* @warning 2025-09-29 Sjtug 需要特殊处理
1516
*/
@@ -32,7 +33,7 @@ pl_python_group_prelude (void)
3233
chef_prep_this (pl_python_group, gsr);
3334

3435
chef_set_created_on (this, "2023-09-03");
35-
chef_set_last_updated (this, "2025-09-30");
36+
chef_set_last_updated (this, "2025-12-31");
3637
chef_set_sources_last_updated (this, "2025-09-30");
3738

3839
chef_set_chef (this, "@happy-game");
@@ -99,11 +100,33 @@ pl_python_get_py_program_name (char **prog_name)
99100
*/
100101
py_exist = chsrc_check_program ("python3");
101102

102-
if (py_exist) *prog_name = "python3";
103+
if (py_exist)
104+
{
105+
*prog_name = "python3";
106+
107+
// https://github.com/RubyMetric/chsrc/issues/327
108+
if (xy.on_windows)
109+
{
110+
int status = xy_run_get_status ("python3 --version");
111+
if (status == 9009)
112+
{
113+
chsrc_error2 (CHINESE ? "用户环境中的 `python3` 命令,是微软商店的占位符,并非真正可用的 Python。请安装真正的 Python 后重试!"
114+
: "`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!");
115+
exit (Exit_UserCause);
116+
}
117+
}
118+
119+
}
103120
else
104121
{
105-
/* 不要调用 python 自己,而是使用 python --version,或者其他方式
106-
因为直接执行 python 会使Windows弹出Microsoft Store */
122+
/**
123+
* 不要直接:
124+
*
125+
* $ python
126+
*
127+
* 这样调用 `python` 自己,而是使用 `python --version`,或者其他方式
128+
* 因为直接执行 `python` 会使 Windows 弹出Microsoft Store
129+
*/
107130
py_exist = chsrc_check_program ("python");
108131

109132
if (py_exist) *prog_name = "python";

0 commit comments

Comments
 (0)