From 13a7895af59e803b70074da669654315435e0f5d Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 12 Aug 2026 10:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=20`py`=20=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recipe/lang/Python/PDM.c | 18 +++---- src/recipe/lang/Python/Poetry.c | 18 +++---- src/recipe/lang/Python/Python.c | 30 ++++++------ src/recipe/lang/Python/Rye.c | 20 ++++---- src/recipe/lang/Python/common.h | 14 +++--- src/recipe/lang/Python/pip.c | 24 +++++----- src/recipe/lang/Python/rawstr4c.h | 4 +- src/recipe/lang/Python/rawstr4c.md | 2 +- src/recipe/lang/Python/uv/uv.c | 76 +++++++++++++++--------------- src/recipe/menu.c | 12 ++--- 10 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/recipe/lang/Python/PDM.c b/src/recipe/lang/Python/PDM.c index 8c46fc41..4f38663b 100644 --- a/src/recipe/lang/Python/PDM.c +++ b/src/recipe/lang/Python/PDM.c @@ -2,12 +2,12 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------*/ -def_target(pl_python_pdm, "pdm"); +def_target(pl_py_pdm, "pdm"); void -pl_python_pdm_prelude (void) +pl_py_pdm_prelude (void) { - chef_prep_this (pl_python_pdm, gsr); + chef_prep_this (pl_py_pdm, gsr); chef_set_recipe_created_on (this, "2024-06-05"); chef_set_recipe_last_updated (this, "2025-07-11"); @@ -23,12 +23,12 @@ pl_python_pdm_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - chef_use_other_target_sources (this, &pl_python_group_target); + chef_use_other_target_sources (this, &pl_py_group_target); } void -pl_python_pdm_getsrc (char *option) +pl_py_pdm_getsrc (char *option) { // @HELP 不加 --global 时,会检测到本项目的配置吗? // 如果不行的话,就要分别改成 --global 和 --local @@ -41,9 +41,9 @@ pl_python_pdm_getsrc (char *option) * @consult https://github.com/RubyMetric/chsrc/issues/19 */ void -pl_python_pdm_setsrc (char *option) +pl_py_pdm_setsrc (char *option) { - Source_t source = chsrc_yield_source (&pl_python_group_target, option); + Source_t source = chsrc_yield_source (&pl_py_group_target, option); if (chsrc_in_standalone_mode()) chsrc_confirm_source(&source); @@ -64,7 +64,7 @@ pl_python_pdm_setsrc (char *option) } void -pl_python_pdm_resetsrc (char *option) +pl_py_pdm_resetsrc (char *option) { - pl_python_pdm_setsrc (option); + pl_py_pdm_setsrc (option); } diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c index f3097a67..c0533d0b 100644 --- a/src/recipe/lang/Python/Poetry.c +++ b/src/recipe/lang/Python/Poetry.c @@ -2,12 +2,12 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------*/ -def_target(pl_python_poetry, "poetry"); +def_target(pl_py_poetry, "poetry"); void -pl_python_poetry_prelude (void) +pl_py_poetry_prelude (void) { - chef_prep_this (pl_python_poetry, gsr); + chef_prep_this (pl_py_poetry, gsr); chef_set_recipe_created_on (this, "2024-08-08"); chef_set_recipe_last_updated (this, "2025-07-11"); @@ -24,11 +24,11 @@ pl_python_poetry_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - chef_use_other_target_sources (this, &pl_python_group_target); + chef_use_other_target_sources (this, &pl_py_group_target); } void -pl_python_poetry_getsrc (char *option) +pl_py_poetry_getsrc (char *option) { chsrc_note2 ("poetry换源情况: 请查看本项目 pyproject.toml 中 [[tool.poetry.source]]"); } @@ -38,9 +38,9 @@ pl_python_poetry_getsrc (char *option) * @consult https://python-poetry.org/docs/repositories/#project-configuration */ void -pl_python_poetry_setsrc (char *option) +pl_py_poetry_setsrc (char *option) { - Source_t source = chsrc_yield_source (&pl_python_group_target, option); + Source_t source = chsrc_yield_source (&pl_py_group_target, option); if (chsrc_in_standalone_mode()) chsrc_confirm_source(&source); @@ -56,7 +56,7 @@ pl_python_poetry_setsrc (char *option) void -pl_python_poetry_resetsrc (char *option) +pl_py_poetry_resetsrc (char *option) { - pl_python_poetry_setsrc (option); + pl_py_poetry_setsrc (option); } diff --git a/src/recipe/lang/Python/Python.c b/src/recipe/lang/Python/Python.c index b5aaa8e9..51e6d3ab 100644 --- a/src/recipe/lang/Python/Python.c +++ b/src/recipe/lang/Python/Python.c @@ -9,38 +9,38 @@ * ------------------------------------------------------------*/ void -pl_python_group_getsrc (char *option) +pl_py_group_getsrc (char *option) { bool pdm_exist = false, poetry_exist = false, uv_exist = false; - pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist); + pl_py_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist); // 交给后面检查命令的存在性 - pl_python_pip_getsrc (option); + pl_py_pip_getsrc (option); br(); if (poetry_exist) { - pl_python_poetry_getsrc (option); + pl_py_poetry_getsrc (option); br(); } if (pdm_exist) { - pl_python_pdm_getsrc (option); + pl_py_pdm_getsrc (option); } if (uv_exist) { - pl_python_uv_getsrc (option); + pl_py_uv_getsrc (option); } } void -pl_python_group_setsrc (char *option) +pl_py_group_setsrc (char *option) { { char *msg = ENGLISH ? "Three package managers will be replaced for you at the same time: " @@ -54,31 +54,31 @@ pl_python_group_setsrc (char *option) poetry_exist = false, uv_exist = false; - pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist); + pl_py_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist); chsrc_set_target_group_mode (); - chsrc_use_this_source (pl_python_group); + chsrc_use_this_source (pl_py_group); // 交给后面检查命令的存在性 - pl_python_pip_setsrc (option); + pl_py_pip_setsrc (option); br(); if (poetry_exist) { - pl_python_poetry_setsrc (option); + pl_py_poetry_setsrc (option); br(); } if (pdm_exist) { - pl_python_pdm_setsrc (option); + pl_py_pdm_setsrc (option); } if (uv_exist) { - pl_python_uv_setsrc (option); + pl_py_uv_setsrc (option); } chsrc_determine_chgtype (ChgType_Auto); @@ -87,7 +87,7 @@ pl_python_group_setsrc (char *option) void -pl_python_group_resetsrc (char *option) +pl_py_group_resetsrc (char *option) { - pl_python_group_setsrc (option); + pl_py_group_setsrc (option); } diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index 4b06764a..b005454d 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -4,12 +4,12 @@ * 由于Rye已经有后继uv了,所以我们不把该管理器纳入Python group中 * ------------------------------------------------------------*/ -def_target(pl_python_rye, "rye"); +def_target(pl_py_rye, "rye"); void -pl_python_rye_prelude (void) +pl_py_rye_prelude (void) { - chef_prep_this (pl_python_rye, gsr); + chef_prep_this (pl_py_rye, gsr); chef_set_recipe_created_on (this, "2024-12-06"); chef_set_recipe_last_updated (this, "2025-08-09"); @@ -25,7 +25,7 @@ pl_python_rye_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - chef_use_other_target_sources (this, &pl_python_group_target); + chef_use_other_target_sources (this, &pl_py_group_target); } char * @@ -40,7 +40,7 @@ pl_python_find_rye_config () void -pl_python_rye_getsrc (char *option) +pl_py_rye_getsrc (char *option) { char *rye_config = pl_python_find_rye_config (); chsrc_note2 (xy_strcat (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容")); @@ -51,12 +51,12 @@ pl_python_rye_getsrc (char *option) * @consult https://github.com/RubyMetric/chsrc/issues/127 */ void -pl_python_rye_setsrc (char *option) +pl_py_rye_setsrc (char *option) { /* 并不在 Python group 中,所以不考虑 target group 情况,仅使用 Python group 提供的源 */ - Source_t source = chsrc_yield_source_and_confirm (&pl_python_group_target, option); + Source_t source = chsrc_yield_source_and_confirm (&pl_py_group_target, option); - const char *content = RAWSTR_pl_python_rye_config; + const char *content = RAWSTR_pl_py_rye_config; content = xy_str_gsub (content, "@1@", source.mirror->abbr); content = xy_str_gsub (content, "@2@", source.url); @@ -71,7 +71,7 @@ pl_python_rye_setsrc (char *option) void -pl_python_rye_resetsrc (char *option) +pl_py_rye_resetsrc (char *option) { - pl_python_rye_setsrc (option); + pl_py_rye_setsrc (option); } diff --git a/src/recipe/lang/Python/common.h b/src/recipe/lang/Python/common.h index 5e0f4787..7373216b 100644 --- a/src/recipe/lang/Python/common.h +++ b/src/recipe/lang/Python/common.h @@ -4,7 +4,7 @@ #include "rawstr4c.h" -def_target(pl_python_group, "python/pypi/py"); +def_target(pl_py_group, "python/pypi/py"); /** * @note 测速链接的这个前缀是 ${host}/pipi/web/pacakges/56/e4.... @@ -16,7 +16,7 @@ def_target(pl_python_group, "python/pypi/py"); * 实际文件仍位于 /pypi-packages,需要特殊处理 */ static char * -pl_python_speed_url_constructor (const char *url, const char *user_data) +pl_py_speed_url_constructor (const char *url, const char *user_data) { char *str = xy_str_delete_suffix (url, "/simple"); str = xy_2strcat (str, "/packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl"); @@ -29,9 +29,9 @@ pl_python_speed_url_constructor (const char *url, const char *user_data) void -pl_python_group_prelude (void) +pl_py_group_prelude (void) { - chef_prep_this (pl_python_group, gsr); + chef_prep_this (pl_py_group, gsr); chef_set_recipe_created_on (this, "2023-09-03"); chef_set_recipe_last_updated (this, "2026-08-01"); @@ -75,11 +75,11 @@ pl_python_group_prelude (void) // {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL} def_sources_end() - chef_set_rest_smURL_with_func (this, pl_python_speed_url_constructor, NULL); + chef_set_rest_smURL_with_func (this, pl_py_speed_url_constructor, NULL); } void -pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_exist) +pl_py_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_exist) { *poetry_exist = chsrc_check_program ("poetry"); *pdm_exist = chsrc_check_program ("pdm"); @@ -91,7 +91,7 @@ pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_ * @param[out] prog_name 返回 Python 的可用名,如果不可用,则返回 NULL */ void -pl_python_get_py_program_name (char **prog_name) +pl_py_get_python_program_name (char **prog_name) { *prog_name = NULL; diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index e765e5bf..6ae83eb7 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -2,12 +2,12 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------*/ -def_target(pl_python_pip, "pip"); +def_target(pl_py_pip, "pip"); void -pl_python_pip_prelude (void) +pl_py_pip_prelude (void) { - chef_prep_this (pl_python_pip, gsr); + chef_prep_this (pl_py_pip, gsr); chef_set_recipe_created_on (this, "2023-09-03"); chef_set_recipe_last_updated (this, "2025-09-12"); @@ -23,15 +23,15 @@ pl_python_pip_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - chef_use_other_target_sources (this, &pl_python_group_target); + chef_use_other_target_sources (this, &pl_py_group_target); } void -pl_python_pip_getsrc (char *option) +pl_py_pip_getsrc (char *option) { char *py_prog_name = NULL; - pl_python_get_py_program_name (&py_prog_name); + pl_py_get_python_program_name (&py_prog_name); char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url"); @@ -49,7 +49,7 @@ pl_python_pip_getsrc (char *option) else chsrc_note2 ("pip 中未配置源,显示默认上游源:"); - Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream"); + Source_t default_source = chsrc_yield_source (&pl_py_group_target, "upstream"); say (default_source.url); } } @@ -59,7 +59,7 @@ pl_python_pip_getsrc (char *option) * @consult https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ */ void -pl_python_pip_setsrc (char *option) +pl_py_pip_setsrc (char *option) { // 对于不支持的情况,尽早结束 if (chsrc_in_project_scope_mode()) @@ -71,12 +71,12 @@ pl_python_pip_setsrc (char *option) return; } - Source_t source = chsrc_yield_source (&pl_python_group_target, option); + Source_t source = chsrc_yield_source (&pl_py_group_target, option); if (chsrc_in_standalone_mode()) chsrc_confirm_source(&source); char *py_prog_name = NULL; - pl_python_get_py_program_name (&py_prog_name); + pl_py_get_python_program_name (&py_prog_name); // 这里用的是 config --user,会写入用户目录(而不是项目目录) // https://github.com/RubyMetric/chsrc/issues/39 @@ -93,7 +93,7 @@ pl_python_pip_setsrc (char *option) void -pl_python_pip_resetsrc (char *option) +pl_py_pip_resetsrc (char *option) { - pl_python_pip_setsrc (option); + pl_py_pip_setsrc (option); } diff --git a/src/recipe/lang/Python/rawstr4c.h b/src/recipe/lang/Python/rawstr4c.h index 37e4f081..0239d394 100644 --- a/src/recipe/lang/Python/rawstr4c.h +++ b/src/recipe/lang/Python/rawstr4c.h @@ -4,7 +4,7 @@ * Generated by rawstr4c v1.1.0-2025/09/27 */ -char RAWSTR_pl_python_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x0a\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x0a\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x0a"; +char RAWSTR_pl_py_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x0a\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x0a\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x0a"; char RAWSTR_pl_python_get_uv_config[] = "\x67\x72\x65\x70\x20\x2d\x41\x20\x32\x20\x27\x69\x6e\x64\x65\x78\x27\x20\x40\x66\x40\x20\x7c\x20\x73\x65\x64\x20\x2d\x6e\x20\x27\x73\x2f\x5e\x75\x72\x6c\x20\x3d\x20\x22\x5c\x28\x2e\x2a\x5c\x29\x22\x2f\x5c\x31\x2f\x70\x27"; @@ -18,5 +18,5 @@ char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x2 char RAWSTR_pl_python_test_uv_if_set_source_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x69\x66\x20\x28\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x20\x7c\x20\x53\x65\x6c\x65\x63\x74\x2d\x53\x74\x72\x69\x6e\x67\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x20\x65\x78\x69\x74\x20\x30\x20\x7d\x20\x65\x6c\x73\x65\x20\x7b\x20\x65\x78\x69\x74\x20\x31\x20\x7d\x22"; -char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22"; +char RAWSTR_pl_py_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22"; diff --git a/src/recipe/lang/Python/rawstr4c.md b/src/recipe/lang/Python/rawstr4c.md index cf658d6d..b62b2bf9 100644 --- a/src/recipe/lang/Python/rawstr4c.md +++ b/src/recipe/lang/Python/rawstr4c.md @@ -12,7 +12,7 @@ # rawstr4c input for Python -- prefix = `RAWSTR_pl_python` +- prefix = `RAWSTR_pl_py` - output = `:global-variable-only-header` - translate = `:hex` - no-postfix = `true` diff --git a/src/recipe/lang/Python/uv/uv.c b/src/recipe/lang/Python/uv/uv.c index a89dc644..2961b2a0 100644 --- a/src/recipe/lang/Python/uv/uv.c +++ b/src/recipe/lang/Python/uv/uv.c @@ -2,16 +2,16 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------*/ -def_target(pl_python_uv, "uv"); +def_target(pl_py_uv, "uv"); #include "uv-helper.c" #include "uv-python-build.c" // 调整 `python-install-mirror` 相关配置应在 `uv-python-build.c` 中修改,本处仅为 uv 最常用的 `pypi` 镜像配置。 void -pl_python_uv_prelude (void) +pl_py_uv_prelude (void) { - chef_prep_this (pl_python_uv, gsr); + chef_prep_this (pl_py_uv, gsr); chef_set_recipe_created_on (this, "2024-12-11"); chef_set_recipe_last_updated (this, "2026-08-11"); @@ -27,7 +27,7 @@ pl_python_uv_prelude (void) chef_allow_english(this); chef_allow_user_define(this); - chef_use_other_target_sources (this, &pl_python_group_target); + chef_use_other_target_sources (this, &pl_py_group_target); // 挂载 源target chef_set_preludefn_for_sources_target (pl_py_uv_python_build); @@ -48,21 +48,21 @@ pl_python_uv_prelude (void) * Unix 用户配置目录优先使用 $XDG_CONFIG_HOME/uv,未设置时回退到 ~/.config/uv。 */ -#define PL_Python_uv_ConfigFile "uv.toml" -#define PL_Python_uv_PyprojectConfigFile "pyproject.toml" +#define pl_py_uv_ConfigFile "uv.toml" +#define pl_py_uv_PyprojectConfigFile "pyproject.toml" // 注意: 不能以 "./" 开头 —— Windows 上 chsrc_backup 的 copy 命令无法处理 -#define PL_Python_uv_Local_ConfigPath "" -#define PL_Python_uv_User_ConfigPath "~/.config" +#define pl_py_uv_Local_ConfigPath "" +#define pl_py_uv_User_ConfigPath "~/.config" static const char * -pl_python_uv_user_config_path (void) +pl_py_uv_user_config_path (void) { const char *xdg = getenv ("XDG_CONFIG_HOME"); - return (xdg && *xdg) ? xdg : PL_Python_uv_User_ConfigPath; + return (xdg && *xdg) ? xdg : pl_py_uv_User_ConfigPath; } static Source_t -pl_python_uv_yield_target_source (Target_t *target, char *option) +pl_py_uv_yield_target_source (Target_t *target, char *option) { if (!target->inited) target->preludefn (); @@ -77,7 +77,7 @@ pl_python_uv_yield_target_source (Target_t *target, char *option) } static char * -pl_python_uv_read_config (const char *path) +pl_py_uv_read_config (const char *path) { if (!xy_file_exist (path)) return xy_strdup (""); @@ -101,16 +101,16 @@ pl_python_find_uv_config (bool mkdir) if (chsrc_in_project_scope_mode()) { // uv.toml 与 pyproject.toml 并存时,uv 会忽略后者中的 [tool.uv]。 - char *uv_toml = xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile); + char *uv_toml = xy_2strcat (pl_py_uv_Local_ConfigPath, pl_py_uv_ConfigFile); if (xy_file_exist (uv_toml)) return uv_toml; free (uv_toml); - char *pyproject = xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_PyprojectConfigFile); + char *pyproject = xy_2strcat (pl_py_uv_Local_ConfigPath, pl_py_uv_PyprojectConfigFile); if (xy_file_exist (pyproject)) return pyproject; free (pyproject); - return xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile); + return xy_2strcat (pl_py_uv_Local_ConfigPath, pl_py_uv_ConfigFile); } else { @@ -130,20 +130,20 @@ pl_python_find_uv_config (bool mkdir) { chsrc_ensure_dir (config_dir); } - char *result = xy_path_join (config_dir, PL_Python_uv_ConfigFile); + char *result = xy_path_join (config_dir, pl_py_uv_ConfigFile); free (config_dir); return result; } else { // config path on Linux or macOS - const char *config_path = pl_python_uv_user_config_path (); + const char *config_path = pl_py_uv_user_config_path (); char *config_dir = xy_path_join (config_path, "uv"); if (mkdir) { chsrc_ensure_dir (config_dir); } - char *result = xy_path_join (config_dir, PL_Python_uv_ConfigFile); + char *result = xy_path_join (config_dir, pl_py_uv_ConfigFile); free (config_dir); return result; } @@ -152,7 +152,7 @@ pl_python_find_uv_config (bool mkdir) void -pl_python_uv_getsrc (char *option) +pl_py_uv_getsrc (char *option) { char *uv_config = pl_python_find_uv_config (false); @@ -167,7 +167,7 @@ pl_python_uv_getsrc (char *option) } // uv.toml 与 pyproject.toml 均使用同一套受限 TOML 读取逻辑。 - char *content = pl_python_uv_read_config (uv_config); + char *content = pl_py_uv_read_config (uv_config); if (!content) { chsrc_error2 ("无法读取 uv 配置文件"); @@ -175,7 +175,7 @@ pl_python_uv_getsrc (char *option) return; } - bool pyproject = xy_str_end_with (uv_config, PL_Python_uv_PyprojectConfigFile); + bool pyproject = xy_str_end_with (uv_config, pl_py_uv_PyprojectConfigFile); const char *index_header = pyproject ? "[[tool.uv.index]]" : "[[index]]"; const char *parent_table = pyproject ? "[tool.uv]" : NULL; @@ -191,7 +191,7 @@ pl_python_uv_getsrc (char *option) chsrc_note2 ("No source configured in uv, showing default upstream source:"); else chsrc_note2 ("uv 中未配置源,显示默认上游源:"); - Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream"); + Source_t default_source = chsrc_yield_source (&pl_py_group_target, "upstream"); say (default_source.url); } @@ -212,16 +212,16 @@ pl_python_uv_getsrc (char *option) * 一次性完成uv配置文件的全部文件操作 (set 路径) */ static bool -pl_python_uv_write_all (const char *uv_config, const char *pypi_url, const char *py_dl_url) +pl_py_uv_write_all (const char *uv_config, const char *pypi_url, const char *py_dl_url) { - char *content = pl_python_uv_read_config (uv_config); + char *content = pl_py_uv_read_config (uv_config); if (!content) { chsrc_error2 ("无法读取 uv 配置文件"); return false; } - bool pyproject = xy_str_end_with (uv_config, PL_Python_uv_PyprojectConfigFile); + bool pyproject = xy_str_end_with (uv_config, pl_py_uv_PyprojectConfigFile); const char *index_header = pyproject ? "[[tool.uv.index]]" : "[[index]]"; const char *parent_table = pyproject ? "[tool.uv]" : NULL; @@ -248,7 +248,7 @@ pl_python_uv_write_all (const char *uv_config, const char *pypi_url, const char * @consult https://docs.astral.sh/uv/reference/settings/#python-install-mirror */ void -pl_python_uv_setsrc (char *option) +pl_py_uv_setsrc (char *option) { chsrc_ensure_program ("uv"); @@ -272,11 +272,11 @@ pl_python_uv_setsrc (char *option) return; } - Source_t default_pypi = pl_python_uv_yield_target_source (&pl_python_group_target, "upstream"); - Source_t default_gh = pl_python_uv_yield_target_source (&pl_py_uv_python_build_target, "upstream"); + Source_t default_pypi = pl_py_uv_yield_target_source (&pl_py_group_target, "upstream"); + Source_t default_gh = pl_py_uv_yield_target_source (&pl_py_uv_python_build_target, "upstream"); chsrc_backup (uv_config); - if (!pl_python_uv_write_all (uv_config, default_pypi.url, default_gh.url)) + if (!pl_py_uv_write_all (uv_config, default_pypi.url, default_gh.url)) { free (uv_config); return; @@ -302,10 +302,10 @@ pl_python_uv_setsrc (char *option) for (int i = 0; i < pl_py_uv_python_build_target.sources_n; i++) if (xy_streql (pl_py_uv_python_build_target.sources[i].mirror->code, option)) { gh_found = true; break; } - if (!pl_python_group_target.inited) - pl_python_group_target.preludefn (); - for (int i = 0; i < pl_python_group_target.sources_n; i++) - if (xy_streql (pl_python_group_target.sources[i].mirror->code, option)) + if (!pl_py_group_target.inited) + pl_py_group_target.preludefn (); + for (int i = 0; i < pl_py_group_target.sources_n; i++) + if (xy_streql (pl_py_group_target.sources[i].mirror->code, option)) { pypi_found = true; break; } if (gh_found && !pypi_found) @@ -317,15 +317,15 @@ pl_python_uv_setsrc (char *option) gh_opt = option; // 共有 code: 两个 target 都使用同一 code } - Source_t source = chsrc_yield_source (&pl_python_group_target, pypi_opt); + Source_t source = chsrc_yield_source (&pl_py_group_target, pypi_opt); // 内部 target 不得复用 Python group leader 的数组下标。 - Source_t gh_source = pl_python_uv_yield_target_source (&pl_py_uv_python_build_target, gh_opt); + Source_t gh_source = pl_py_uv_yield_target_source (&pl_py_uv_python_build_target, gh_opt); if (chsrc_in_standalone_mode()) chsrc_confirm_source (&source); chsrc_backup (uv_config); - if (!pl_python_uv_write_all (uv_config, source.url, gh_source.url)) + if (!pl_py_uv_write_all (uv_config, source.url, gh_source.url)) { free (uv_config); return; @@ -341,7 +341,7 @@ pl_python_uv_setsrc (char *option) void -pl_python_uv_resetsrc (char *option) +pl_py_uv_resetsrc (char *option) { - pl_python_uv_setsrc (option); + pl_py_uv_setsrc (option); } diff --git a/src/recipe/menu.c b/src/recipe/menu.c index ec407d4d..c27609a4 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -155,12 +155,12 @@ chsrc_init_menu () #define add(t) xy_seq_push(ProgStore.pl, &pl_##t##_target); (&pl_##t##_target)->preludefn = pl_##t##_prelude add (ruby); - add (python_group); - add (python_pip); - add (python_poetry); - add (python_pdm); - add (python_rye); - add (python_uv); + add (py_group); + add (py_pip); + add (py_poetry); + add (py_pdm); + add (py_rye); + add (py_uv); add (js_group); add (js_bun); add (js_npm);