mirror of
https://github.com/RubyMetric/chsrc
synced 2026-10-26 01:54:44 +08:00
删除 Python Group target
This commit is contained in:
15 files changed
+202
-329
No files matched your search
@@ -7,7 +7,7 @@
|
||||
! Contributors : @Mikachu2333
|
||||
! |
|
||||
! Created On : <2024-08-19>
|
||||
! Last Modified : <2026-01-21>
|
||||
! Last Modified : <2026-08-12>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# Write A Recipe Even If You Don't Know C
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
1. 看一眼就能上手的参照物是 [PHP recipe](../src/recipe/lang/PHP.c)
|
||||
2. 最好的参照物是 [Ruby recipe](../src/recipe/lang/Ruby/Ruby.c)
|
||||
3. 组换源参照物是 [Python group recipe](../src/recipe/lang/Python/Python.c)
|
||||
3. 组换源参照物是 [JS group recipe](../src/recipe/lang/JavaScript/JavaScript.c)
|
||||
|
||||
5. 在 [Wiki] 中记录的镜像站中寻找可用源;可以额外补充镜像站
|
||||
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@
|
||||
.\" Contributors : Nul None <nul@none.org>
|
||||
.\" |
|
||||
.\" Created On : <2024-08-21>
|
||||
.\" Last Modified : <2026-02-24>
|
||||
.\" Last Modified : <2026-08-12>
|
||||
.\" ----------------------------------------------------------------
|
||||
|
||||
.TH chsrc 1 "2026-02-24" "v0.2.5" "RubyMetric chsrc"
|
||||
.TH chsrc 1 "2026-08-12" "v0.2.6" "RubyMetric chsrc"
|
||||
|
||||
.SH NAME
|
||||
chsrc - Change Source for every software on every platform from the command line
|
||||
|
||||
+3
-3
@@ -6,15 +6,15 @@
|
||||
@c Contributors : Nul None <nul@none.org>
|
||||
@c |
|
||||
@c Created On : <2024-08-22>
|
||||
@c Last Modified : <2026-02-24>
|
||||
@c Last Modified : <2026-08-12>
|
||||
@c --------------------------------------------------------------
|
||||
|
||||
\input texinfo
|
||||
@setfilename chsrc.info
|
||||
@settitle chsrc
|
||||
|
||||
@set Chsrc_Version v0.2.5
|
||||
@set Doc_Publish_Date 2026-02-24
|
||||
@set Chsrc_Version v0.2.6
|
||||
@set Doc_Publish_Date 2026-08-12
|
||||
|
||||
@copying
|
||||
@comment 这是软件copyright,不是文档copyright,因此不放在titlepage
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Contributors : @livelycode36
|
||||
* |
|
||||
* Created On : <2023-08-29>
|
||||
* Last Modified : <2026-08-11>
|
||||
* Last Modified : <2026-08-12>
|
||||
*
|
||||
* chsrc struct
|
||||
* ------------------------------------------------------------*/
|
||||
@@ -234,11 +234,10 @@ Target_t;
|
||||
|
||||
/* 简化 "源target" 的编写 */
|
||||
#define chef_prep_sources_target(t) Target_t *this = &t##_target; this->inited = true; chef_allow_NOOP(t); \
|
||||
chef_deny_english(); \
|
||||
chef_deny_user_define();
|
||||
chef_deny_english(this);
|
||||
|
||||
/* 内部 "源target" 的 prelude 未通过 menu.c 的 add() 注册, 手动挂载 */
|
||||
#define chef_set_preludefn_for_sources_target(t) t##target.preludefn = t##_prelude;
|
||||
#define chef_set_preludefn_for_sources_target(t) t##_target.preludefn = t##_prelude;
|
||||
|
||||
|
||||
#define chef_use_this(t) Target_t *this = &t##_target;
|
||||
|
||||
@@ -45,7 +45,7 @@ pl_js_group_prelude (void)
|
||||
|
||||
|
||||
|
||||
def_sources_target (pl_js_nodejs_binary, "nodejs-binary");
|
||||
def_sources_target(pl_js_nodejs_binary, "nodejs-binary");
|
||||
|
||||
void
|
||||
pl_js_nodejs_binary_prelude (void)
|
||||
@@ -58,6 +58,8 @@ pl_js_nodejs_binary_prelude (void)
|
||||
chef_set_chefs (this, 1, "@ccmywish");
|
||||
chef_set_sauciers (this, 0);
|
||||
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://nodejs.org/dist/", FeedByPrelude},
|
||||
{&NpmMirror, "https://npmmirror.com/mirrors", FeedByPrelude},
|
||||
|
||||
@@ -23,7 +23,7 @@ pl_py_pdm_prelude (void)
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
chef_use_other_target_sources (this, &pl_py_group_target);
|
||||
chef_use_other_target_sources (this, &pl_py_pypi_target);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,7 @@ pl_py_pdm_getsrc (char *option)
|
||||
void
|
||||
pl_py_pdm_setsrc (char *option)
|
||||
{
|
||||
Source_t source = chsrc_yield_source (&pl_py_group_target, option);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source(&source);
|
||||
Source_t source = chsrc_yield_source_and_confirm (&pl_py_pypi_target, option);
|
||||
|
||||
char *cmd = NULL;
|
||||
|
||||
@@ -56,11 +54,8 @@ pl_py_pdm_setsrc (char *option)
|
||||
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -24,7 +24,7 @@ pl_py_poetry_prelude (void)
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
chef_use_other_target_sources (this, &pl_py_group_target);
|
||||
chef_use_other_target_sources (this, &pl_py_pypi_target);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -40,18 +40,13 @@ pl_py_poetry_getsrc (char *option)
|
||||
void
|
||||
pl_py_poetry_setsrc (char *option)
|
||||
{
|
||||
Source_t source = chsrc_yield_source (&pl_py_group_target, option);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source(&source);
|
||||
Source_t source = chsrc_yield_source_and_confirm (&pl_py_pypi_target, option);
|
||||
|
||||
char *cmd = xy_2strcat ("poetry source add my_mirror ", source.url);
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : @ccmywish
|
||||
* Contributors : @happy-game
|
||||
* |
|
||||
* Created On : <2023-09-03>
|
||||
* Last Modified : <2025-12-31>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
pl_py_group_getsrc (char *option)
|
||||
{
|
||||
bool pdm_exist = false,
|
||||
poetry_exist = false,
|
||||
uv_exist = false;
|
||||
|
||||
pl_py_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist);
|
||||
|
||||
// 交给后面检查命令的存在性
|
||||
pl_py_pip_getsrc (option);
|
||||
br();
|
||||
|
||||
if (poetry_exist)
|
||||
{
|
||||
pl_py_poetry_getsrc (option);
|
||||
br();
|
||||
}
|
||||
|
||||
if (pdm_exist)
|
||||
{
|
||||
pl_py_pdm_getsrc (option);
|
||||
}
|
||||
|
||||
if (uv_exist)
|
||||
{
|
||||
pl_py_uv_getsrc (option);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_py_group_setsrc (char *option)
|
||||
{
|
||||
{
|
||||
char *msg = ENGLISH ? "Three package managers will be replaced for you at the same time: "
|
||||
"pip, Poetry, PDM. If you need to change the source independently, "
|
||||
"please run independently `chsrc set <pkg-manager>`"
|
||||
: "将同时更换4个包管理器 pip, Poetry, PDM, uv 的源,若需要独立换源,请独立运行 chsrc set <pkg-manager>";
|
||||
chsrc_alert2 (msg);
|
||||
}
|
||||
|
||||
bool pdm_exist = false,
|
||||
poetry_exist = false,
|
||||
uv_exist = false;
|
||||
|
||||
pl_py_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist);
|
||||
|
||||
chsrc_set_target_group_mode ();
|
||||
|
||||
chsrc_use_this_source (pl_py_group);
|
||||
|
||||
|
||||
// 交给后面检查命令的存在性
|
||||
pl_py_pip_setsrc (option);
|
||||
br();
|
||||
|
||||
if (poetry_exist)
|
||||
{
|
||||
pl_py_poetry_setsrc (option);
|
||||
br();
|
||||
}
|
||||
|
||||
if (pdm_exist)
|
||||
{
|
||||
pl_py_pdm_setsrc (option);
|
||||
}
|
||||
|
||||
if (uv_exist)
|
||||
{
|
||||
pl_py_uv_setsrc (option);
|
||||
}
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_py_group_resetsrc (char *option)
|
||||
{
|
||||
pl_py_group_setsrc (option);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ pl_py_rye_prelude (void)
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
chef_use_other_target_sources (this, &pl_py_group_target);
|
||||
chef_use_other_target_sources (this, &pl_py_pypi_target);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -54,7 +54,7 @@ void
|
||||
pl_py_rye_setsrc (char *option)
|
||||
{
|
||||
/* 并不在 Python group 中,所以不考虑 target group 情况,仅使用 Python group 提供的源 */
|
||||
Source_t source = chsrc_yield_source_and_confirm (&pl_py_group_target, option);
|
||||
Source_t source = chsrc_yield_source_and_confirm (&pl_py_pypi_target, option);
|
||||
|
||||
const char *content = RAWSTR_pl_py_rye_config;
|
||||
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#include "rawstr4c.h"
|
||||
|
||||
def_target(pl_py_group, "python/pypi/py");
|
||||
|
||||
/**
|
||||
* @note 测速链接的这个前缀是 ${host}/pipi/web/pacakges/56/e4....
|
||||
* 下面有几个镜像站微调了这个路径,我们只要确认能找到 packages 目录就好
|
||||
*
|
||||
* @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的文件
|
||||
*
|
||||
* @warning 2026-08-01 Sjtug 的索引地址为 /pypi/web/simple,
|
||||
* 实际文件仍位于 /pypi-packages,需要特殊处理
|
||||
*/
|
||||
static char *
|
||||
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");
|
||||
if (strstr (url, "mirror.sjtu.edu.cn"))
|
||||
// e.g. https://mirror.sjtu.edu.cn/pypi-packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl
|
||||
str = xy_str_gsub (str, "pypi/web/packages", "pypi-packages");// 针对 Sjtug
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_py_group_prelude (void)
|
||||
{
|
||||
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");
|
||||
|
||||
// 组换源的 leader target 应把所有 follower target 的贡献者都记录过来
|
||||
chef_set_chefs (this, 2, "@ccmywish", "@happy-game");
|
||||
chef_set_sauciers (this, 4, "@ReachForStar", "@Kattos", "@Mikachu2333", "@Yangmoooo");
|
||||
|
||||
/* 部分包管理器支持 ProjectScope,但是为了让流程执行下去,我们这里都写 ScopeCap_Able_And_Implemented */
|
||||
chef_set_scope_cap (this, ProjectScope, ScopeCap_Able_And_Implemented);
|
||||
chef_set_scope_cap (this, UserScope, ScopeCap_Able_And_Implemented);
|
||||
chef_set_scope_cap (this, SystemScope, ScopeCap_Unable);
|
||||
chef_set_default_scope (this, UserScope);
|
||||
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://pypi.org/simple", FeedByPrelude},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
// 不要添加Zju,浙大的PyPI服务在校外访问会自动转向Tuna
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
// 2025-09-29 此源已停用
|
||||
// @ref https://mirrors.jlu.edu.cn/_news/#2025-04-06-pypi-repo-down
|
||||
// {&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/pypi/simple", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/pypi/simple", FeedByPrelude},
|
||||
{&Nju, "https://mirror.nju.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Pku, "https://mirrors.pku.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple", FeedByPrelude},
|
||||
|
||||
// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple", FeedByPrelude}
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple", FeedByPrelude},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple", FeedByPrelude}
|
||||
|
||||
/* 不启用原因:24小时更新一次 */
|
||||
// {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL}
|
||||
def_sources_end()
|
||||
|
||||
chef_set_rest_smURL_with_func (this, pl_py_speed_url_constructor, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
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");
|
||||
*uv_exist = chsrc_check_program ("uv");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param[out] prog_name 返回 Python 的可用名,如果不可用,则返回 NULL
|
||||
*/
|
||||
void
|
||||
pl_py_get_python_program_name (char **prog_name)
|
||||
{
|
||||
*prog_name = NULL;
|
||||
|
||||
bool py_exist = false;
|
||||
|
||||
/**
|
||||
* @issue https://gitee.com/RubyMetric/chsrc/issues/I9VZL2
|
||||
*
|
||||
* 由于Python2和Python3的历史,目前(2024-06)许多python命令实际上仍然是python2
|
||||
* 因此我们首先测试 python3
|
||||
*/
|
||||
py_exist = chsrc_check_program ("python3");
|
||||
|
||||
bool python3_is_winstore_placeholder = false;
|
||||
|
||||
const int winstore_python_status_code = 9009;
|
||||
|
||||
const char *winstore_placeholder_cn = "是微软商店的占位符,并非真正可用的 Python";
|
||||
const char *winstore_placeholder_en = "a placeholder of Microsoft Store, not the real Python";
|
||||
|
||||
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 == winstore_python_status_code)
|
||||
{
|
||||
python3_is_winstore_placeholder = true;
|
||||
*prog_name = NULL;
|
||||
// https://github.com/RubyMetric/chsrc/issues/351
|
||||
// 仅警告,不要直接退出,因为用户环境中还可能存在真正的 `python` 命令
|
||||
chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python3` 命令,", winstore_placeholder_cn)
|
||||
: xy_2strcat ("`python3` in your environment is ", winstore_placeholder_en));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!py_exist || python3_is_winstore_placeholder)
|
||||
{
|
||||
/**
|
||||
* 不要直接:
|
||||
*
|
||||
* $ python
|
||||
*
|
||||
* 这样调用 `python` 自己,而是使用 `python --version`,或者其他方式
|
||||
* 因为直接执行 `python` 会使 Windows 弹出Microsoft Store
|
||||
*/
|
||||
py_exist = chsrc_check_program ("python");
|
||||
|
||||
if (py_exist)
|
||||
{
|
||||
if (xy.on_windows)
|
||||
{
|
||||
int status = xy_run_get_status ("python --version");
|
||||
if (status == winstore_python_status_code)
|
||||
{
|
||||
chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python` 命令,也", winstore_placeholder_cn)
|
||||
: xy_2strcat ("`python` in your environment is also ", winstore_placeholder_en));
|
||||
chsrc_error (CHINESE ? "请安装真正的 Python 后重试!"
|
||||
: "Please install the real Python and try again!");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
*prog_name = "python";
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_error ("未找到 Python 相关命令,请检查是否存在");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
def_target(pl_py_pip, "pip");
|
||||
def_target(pl_py_pip, "pip/python/py");
|
||||
|
||||
void
|
||||
pl_py_pip_prelude (void)
|
||||
@@ -10,7 +10,7 @@ pl_py_pip_prelude (void)
|
||||
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");
|
||||
chef_set_recipe_last_updated (this, "2026-08-12");
|
||||
|
||||
chef_set_chefs (this, 1, "@ccmywish");
|
||||
chef_set_sauciers (this, 1, "@happy-game");
|
||||
@@ -23,10 +23,94 @@ pl_py_pip_prelude (void)
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
chef_use_other_target_sources (this, &pl_py_group_target);
|
||||
chef_use_other_target_sources (this, &pl_py_pypi_target);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param[out] prog_name 返回 Python 的可用名,如果不可用,则返回 NULL
|
||||
*/
|
||||
void
|
||||
pl_py_get_python_program_name (char **prog_name)
|
||||
{
|
||||
*prog_name = NULL;
|
||||
|
||||
bool py_exist = false;
|
||||
|
||||
/**
|
||||
* @issue https://gitee.com/RubyMetric/chsrc/issues/I9VZL2
|
||||
*
|
||||
* 由于Python2和Python3的历史,目前(2024-06)许多python命令实际上仍然是python2
|
||||
* 因此我们首先测试 python3
|
||||
*/
|
||||
py_exist = chsrc_check_program ("python3");
|
||||
|
||||
bool python3_is_winstore_placeholder = false;
|
||||
|
||||
const int winstore_python_status_code = 9009;
|
||||
|
||||
const char *winstore_placeholder_cn = "是微软商店的占位符,并非真正可用的 Python";
|
||||
const char *winstore_placeholder_en = "a placeholder of Microsoft Store, not the real Python";
|
||||
|
||||
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 == winstore_python_status_code)
|
||||
{
|
||||
python3_is_winstore_placeholder = true;
|
||||
*prog_name = NULL;
|
||||
// https://github.com/RubyMetric/chsrc/issues/351
|
||||
// 仅警告,不要直接退出,因为用户环境中还可能存在真正的 `python` 命令
|
||||
chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python3` 命令,", winstore_placeholder_cn)
|
||||
: xy_2strcat ("`python3` in your environment is ", winstore_placeholder_en));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!py_exist || python3_is_winstore_placeholder)
|
||||
{
|
||||
/**
|
||||
* 不要直接:
|
||||
*
|
||||
* $ python
|
||||
*
|
||||
* 这样调用 `python` 自己,而是使用 `python --version`,或者其他方式
|
||||
* 因为直接执行 `python` 会使 Windows 弹出Microsoft Store
|
||||
*/
|
||||
py_exist = chsrc_check_program ("python");
|
||||
|
||||
if (py_exist)
|
||||
{
|
||||
if (xy.on_windows)
|
||||
{
|
||||
int status = xy_run_get_status ("python --version");
|
||||
if (status == winstore_python_status_code)
|
||||
{
|
||||
chsrc_warn2 (CHINESE ? xy_2strcat ("用户环境中的 `python` 命令,也", winstore_placeholder_cn)
|
||||
: xy_2strcat ("`python` in your environment is also ", winstore_placeholder_en));
|
||||
chsrc_error (CHINESE ? "请安装真正的 Python 后重试!"
|
||||
: "Please install the real Python and try again!");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
*prog_name = "python";
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_error ("未找到 Python 相关命令,请检查是否存在");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
pl_py_pip_getsrc (char *option)
|
||||
{
|
||||
@@ -49,7 +133,7 @@ pl_py_pip_getsrc (char *option)
|
||||
else
|
||||
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
|
||||
|
||||
Source_t default_source = chsrc_yield_source (&pl_py_group_target, "upstream");
|
||||
Source_t default_source = chsrc_yield_source (&pl_py_pypi_target, "upstream");
|
||||
say (default_source.url);
|
||||
}
|
||||
}
|
||||
@@ -71,9 +155,7 @@ pl_py_pip_setsrc (char *option)
|
||||
return;
|
||||
}
|
||||
|
||||
Source_t source = chsrc_yield_source (&pl_py_group_target, option);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source(&source);
|
||||
Source_t source = chsrc_yield_source_and_confirm (&pl_py_pypi_target, option);
|
||||
|
||||
char *py_prog_name = NULL;
|
||||
pl_py_get_python_program_name (&py_prog_name);
|
||||
@@ -84,11 +166,8 @@ pl_py_pip_setsrc (char *option)
|
||||
char *cmd = xy_2strcat (py_prog_name, xy_2strcat (" -m pip config --user set global.index-url ", source.url));
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#include "rawstr4c.h"
|
||||
|
||||
def_sources_target(pl_py_pypi, "pypi");
|
||||
|
||||
/**
|
||||
* @note 测速链接的这个前缀是 ${host}/pipi/web/pacakges/56/e4....
|
||||
* 下面有几个镜像站微调了这个路径,我们只要确认能找到 packages 目录就好
|
||||
*
|
||||
* @note 2025-09-29 更新了测试的 pkg 链接,换用了一个 40M 的文件
|
||||
*
|
||||
* @warning 2026-08-01 Sjtug 的索引地址为 /pypi/web/simple,
|
||||
* 实际文件仍位于 /pypi-packages,需要特殊处理
|
||||
*/
|
||||
static char *
|
||||
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");
|
||||
if (strstr (url, "mirror.sjtu.edu.cn"))
|
||||
// e.g. https://mirror.sjtu.edu.cn/pypi-packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl
|
||||
str = xy_str_gsub (str, "pypi/web/packages", "pypi-packages");// 针对 Sjtug
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pl_py_pypi_prelude (void)
|
||||
{
|
||||
chef_prep_sources_target (pl_py_pypi);
|
||||
|
||||
chef_set_recipe_created_on (this, "2023-09-03");
|
||||
chef_set_recipe_last_updated (this, "2026-08-01");
|
||||
|
||||
// 组换源的 leader target 应把所有 follower target 的贡献者都记录过来
|
||||
chef_set_chefs (this, 2, "@ccmywish", "@happy-game");
|
||||
chef_set_sauciers (this, 4, "@ReachForStar", "@Kattos", "@Mikachu2333", "@Yangmoooo");
|
||||
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&UpstreamProvider, "https://pypi.org/simple", FeedByPrelude},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
// 不要添加Zju,浙大的PyPI服务在校外访问会自动转向Tuna
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
// 2025-09-29 此源已停用
|
||||
// @ref https://mirrors.jlu.edu.cn/_news/#2025-04-06-pypi-repo-down
|
||||
// {&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/pypi/simple", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/pypi/simple", FeedByPrelude},
|
||||
{&Nju, "https://mirror.nju.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Pku, "https://mirrors.pku.edu.cn/pypi/web/simple", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple", FeedByPrelude},
|
||||
|
||||
// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple", FeedByPrelude}
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple", FeedByPrelude},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple", FeedByPrelude}
|
||||
|
||||
/* 不启用原因:24小时更新一次 */
|
||||
// {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL}
|
||||
def_sources_end()
|
||||
|
||||
chef_set_rest_smURL_with_func (this, pl_py_speed_url_constructor, NULL);
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
* 针对 python-build-standalone 的测速链接。
|
||||
*/
|
||||
|
||||
def_sources_target (pl_py_uv_python_build, "uv-python-build");
|
||||
def_sources_target(pl_py_uv_python_build, "uv-python-build");
|
||||
|
||||
// CNB (Cloud Native Build, 腾讯) 托管的 python-build-standalone releases 镜像
|
||||
static MirrorSite_t CnbUvPython =
|
||||
|
||||
@@ -27,7 +27,7 @@ pl_py_uv_prelude (void)
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
chef_use_other_target_sources (this, &pl_py_group_target);
|
||||
chef_use_other_target_sources (this, &pl_py_pypi_target);
|
||||
|
||||
// 挂载 源target
|
||||
chef_set_preludefn_for_sources_target (pl_py_uv_python_build);
|
||||
@@ -191,7 +191,7 @@ pl_py_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_py_group_target, "upstream");
|
||||
Source_t default_source = chsrc_yield_source (&pl_py_pypi_target, "upstream");
|
||||
say (default_source.url);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ pl_py_uv_setsrc (char *option)
|
||||
return;
|
||||
}
|
||||
|
||||
Source_t default_pypi = pl_py_uv_yield_target_source (&pl_py_group_target, "upstream");
|
||||
Source_t default_pypi = pl_py_uv_yield_target_source (&pl_py_pypi_target, "upstream");
|
||||
Source_t default_gh = pl_py_uv_yield_target_source (&pl_py_uv_python_build_target, "upstream");
|
||||
|
||||
chsrc_backup (uv_config);
|
||||
@@ -302,10 +302,10 @@ pl_py_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_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))
|
||||
if (!pl_py_pypi_target.inited)
|
||||
pl_py_pypi_target.preludefn ();
|
||||
for (int i = 0; i < pl_py_pypi_target.sources_n; i++)
|
||||
if (xy_streql (pl_py_pypi_target.sources[i].mirror->code, option))
|
||||
{ pypi_found = true; break; }
|
||||
|
||||
if (gh_found && !pypi_found)
|
||||
@@ -317,26 +317,21 @@ pl_py_uv_setsrc (char *option)
|
||||
gh_opt = option; // 共有 code: 两个 target 都使用同一 code
|
||||
}
|
||||
|
||||
Source_t source = chsrc_yield_source (&pl_py_group_target, pypi_opt);
|
||||
Source_t source = chsrc_yield_source (&pl_py_pypi_target, pypi_opt);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
// 内部 target 不得复用 Python group leader 的数组下标。
|
||||
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_confirm_source (&gh_source);
|
||||
|
||||
chsrc_backup (uv_config);
|
||||
if (!pl_py_uv_write_all (uv_config, source.url, gh_source.url))
|
||||
{
|
||||
free (uv_config);
|
||||
return;
|
||||
}
|
||||
free (uv_config);
|
||||
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-4
@@ -13,13 +13,12 @@
|
||||
#include "lang/rawstr4c.h"
|
||||
|
||||
#include "lang/Ruby/Ruby.c"
|
||||
#include "lang/Python/common.h"
|
||||
#include "lang/Python/pip.c"
|
||||
#include "lang/Python/pypi.c"
|
||||
#include "lang/Python/pip.c"
|
||||
#include "lang/Python/Poetry.c"
|
||||
#include "lang/Python/PDM.c"
|
||||
#include "lang/Python/Rye.c"
|
||||
#include "lang/Python/uv/uv.c"
|
||||
#include "lang/Python/Python.c"
|
||||
|
||||
#include "lang/JavaScript/common.h"
|
||||
#include "lang/JavaScript/npm.c"
|
||||
@@ -155,7 +154,6 @@ chsrc_init_menu ()
|
||||
|
||||
#define add(t) xy_seq_push(ProgStore.pl, &pl_##t##_target); (&pl_##t##_target)->preludefn = pl_##t##_prelude
|
||||
add (ruby);
|
||||
add (py_group);
|
||||
add (py_pip);
|
||||
add (py_poetry);
|
||||
add (py_pdm);
|
||||
@@ -230,5 +228,6 @@ chsrc_init_menu ()
|
||||
add (anaconda);
|
||||
#undef add
|
||||
|
||||
chef_set_preludefn_for_sources_target (pl_py_pypi);
|
||||
chef_set_preludefn_for_sources_target (pl_js_nodejs_binary);
|
||||
}
|
||||
Reference in new issue
Block a user