Skip to content

Commit 9d1a287

Browse files
committed
增加 chsrc_run_directly() 并修复 pipget 时在 Windows 上找不到路径的问题
[GitHub #286]
1 parent c7e5c1f commit 9d1a287

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

src/framework/core.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
1111
* |
1212
* Created On : <2023-08-29>
13-
* Last Modified : <2025-08-27>
13+
* Last Modified : <2025-09-12>
1414
*
1515
* chsrc framework
1616
* ------------------------------------------------------------*/
@@ -1348,6 +1348,28 @@ chsrc_run_as_a_service (const char *cmd)
13481348
}
13491349

13501350

1351+
/**
1352+
* @brief 以纯粹的方式直接运行命令,不做任何多余处理,
1353+
* 命令执行前显示给用户,并保留所有输出给用户
1354+
*
1355+
* @return 返回命令的退出状态
1356+
*/
1357+
int
1358+
chsrc_run_directly (const char *cmd)
1359+
{
1360+
if (ENGLISH)
1361+
xy_log_brkt (blue (App_Name), bdblue ("RUN"), blue (cmd));
1362+
else
1363+
xy_log_brkt (blue (App_Name), bdblue ("运行"), blue (cmd));
1364+
1365+
if (in_dry_run_mode())
1366+
{
1367+
return 0; // Dry Run 此时立即结束,并不真正执行
1368+
}
1369+
int status = system (cmd);
1370+
return status;
1371+
}
1372+
13511373

13521374
/**
13531375
* @brief 在本目录创建一个临时文件

src/recipe/lang/Python/pip.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pl_python_pip_prelude (void)
1010
chef_prep_this (pl_python_pip, gsr);
1111

1212
chef_set_created_on (this, "2023-09-03");
13-
chef_set_last_updated (this, "2025-09-10");
13+
chef_set_last_updated (this, "2025-09-12");
1414
chef_set_sources_last_updated (this, "2025-07-11");
1515

1616
chef_set_chef (this, NULL);
@@ -31,12 +31,13 @@ pl_python_pip_getsrc (char *option)
3131
char *py_prog_name = NULL;
3232
pl_python_get_py_program_name (&py_prog_name);
3333

34-
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url 2>/dev/null");
35-
36-
int status = system (cmd);
34+
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url");
35+
36+
int status = chsrc_run_directly (cmd);
3737
if (0 == status)
3838
{
3939
// 执行成功时显示当前源
40+
xy_noop ();
4041
}
4142
else
4243
{
@@ -45,9 +46,9 @@ pl_python_pip_getsrc (char *option)
4546
chsrc_note2 ("No source configured in pip, showing default upstream source:");
4647
else
4748
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
48-
49+
4950
Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream");
50-
chsrc_log (default_source.url);
51+
say (default_source.url);
5152
}
5253
}
5354

0 commit comments

Comments
 (0)