增加 chsrc_run_directly() 并修复 pipget 时在 Windows 上找不到路径的问题

[GitHub #286]
This commit is contained in:
Aoran Zeng
2025-09-12 12:30:03 +08:00
parent c7e5c1fafb
commit 9d1a287f91
2 changed files with 30 additions and 7 deletions

View File

@@ -10,7 +10,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-08-27>
* Last Modified : <2025-09-12>
*
* chsrc framework
* ------------------------------------------------------------*/
@@ -1348,6 +1348,28 @@ chsrc_run_as_a_service (const char *cmd)
}
/**
* @brief 以纯粹的方式直接运行命令,不做任何多余处理,
* 命令执行前显示给用户,并保留所有输出给用户
*
* @return 返回命令的退出状态
*/
int
chsrc_run_directly (const char *cmd)
{
if (ENGLISH)
xy_log_brkt (blue (App_Name), bdblue ("RUN"), blue (cmd));
else
xy_log_brkt (blue (App_Name), bdblue ("运行"), blue (cmd));
if (in_dry_run_mode())
{
return 0; // Dry Run 此时立即结束,并不真正执行
}
int status = system (cmd);
return status;
}
/**
* @brief 在本目录创建一个临时文件

View File

@@ -10,7 +10,7 @@ pl_python_pip_prelude (void)
chef_prep_this (pl_python_pip, gsr);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-09-10");
chef_set_last_updated (this, "2025-09-12");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
@@ -31,12 +31,13 @@ pl_python_pip_getsrc (char *option)
char *py_prog_name = NULL;
pl_python_get_py_program_name (&py_prog_name);
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url 2>/dev/null");
int status = system (cmd);
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url");
int status = chsrc_run_directly (cmd);
if (0 == status)
{
// 执行成功时显示当前源
xy_noop ();
}
else
{
@@ -45,9 +46,9 @@ pl_python_pip_getsrc (char *option)
chsrc_note2 ("No source configured in pip, showing default upstream source:");
else
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream");
chsrc_log (default_source.url);
say (default_source.url);
}
}