From ee92d1faac6c3c6de581aef8fd51c6bd1b2b8f54 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 31 Dec 2025 14:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20`Windows`=20=E4=B8=8A=E9=A2=9D?= =?UTF-8?q?=E5=A4=96=E6=A3=80=E6=B5=8B=20`python3`=20=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=BA=E5=BE=AE=E8=BD=AF=E5=95=86=E5=BA=97?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E7=AC=A6=20[GitHub=20#327]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recipe/lang/Python/Python.c | 6 +++--- src/recipe/lang/Python/common.h | 33 ++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/recipe/lang/Python/Python.c b/src/recipe/lang/Python/Python.c index e7809f0..b5aaa8e 100644 --- a/src/recipe/lang/Python/Python.c +++ b/src/recipe/lang/Python/Python.c @@ -1,11 +1,11 @@ /** ------------------------------------------------------------ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- - * File Authors : Aoran Zeng - * Contributors : happy game + * File Authors : @ccmywish + * Contributors : @happy-game * | * Created On : <2023-09-03> - * Last Modified : <2025-07-14> + * Last Modified : <2025-12-31> * ------------------------------------------------------------*/ void diff --git a/src/recipe/lang/Python/common.h b/src/recipe/lang/Python/common.h index 84f6ddc..6c9b49a 100644 --- a/src/recipe/lang/Python/common.h +++ b/src/recipe/lang/Python/common.h @@ -9,7 +9,8 @@ def_target(pl_python_group, "python/pypi/py"); /** * @note 测速链接的这个前缀是 ${host}/pipi/web/pacakges/56/e4.... * 下面有几个镜像站微调了这个路径,我们只要确认能找到 packages 目录就好 - * @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的 + * + * @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的文件 * * @warning 2025-09-29 Sjtug 需要特殊处理 */ @@ -32,7 +33,7 @@ pl_python_group_prelude (void) chef_prep_this (pl_python_group, gsr); chef_set_created_on (this, "2023-09-03"); - chef_set_last_updated (this, "2025-09-30"); + chef_set_last_updated (this, "2025-12-31"); chef_set_sources_last_updated (this, "2025-09-30"); chef_set_chef (this, "@happy-game"); @@ -99,11 +100,33 @@ pl_python_get_py_program_name (char **prog_name) */ py_exist = chsrc_check_program ("python3"); - if (py_exist) *prog_name = "python3"; + if (py_exist) + { + *prog_name = "python3"; + + // https://github.com/RubyMetric/chsrc/issues/327 + if (xy.on_windows) + { + int status = xy_run_get_status ("python3 --version"); + if (status == 9009) + { + chsrc_error2 (CHINESE ? "用户环境中的 `python3` 命令,是微软商店的占位符,并非真正可用的 Python。请安装真正的 Python 后重试!" + : "`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!"); + exit (Exit_UserCause); + } + } + + } else { - /* 不要调用 python 自己,而是使用 python --version,或者其他方式 - 因为直接执行 python 会使Windows弹出Microsoft Store */ + /** + * 不要直接: + * + * $ python + * + * 这样调用 `python` 自己,而是使用 `python --version`,或者其他方式 + * 因为直接执行 `python` 会使 Windows 弹出Microsoft Store + */ py_exist = chsrc_check_program ("python"); if (py_exist) *prog_name = "python";