Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/recipe/lang/Python/pip.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ 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-07-11");
chef_set_last_updated (this, "2025-09-10");
chef_set_sources_last_updated (this, "2025-07-11");

chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_set_sauciers (this, 1, "@happy-game");

chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
Expand All @@ -31,8 +31,24 @@ 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");
chsrc_run (cmd, RunOpt_Default);
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url 2>/dev/null");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2>/dev/null 疏忽了 Windows 上的情况,会报错找不到路径,从而走向 else 分支

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复


int status = system (cmd);
if (0 == status)
{
// 执行成功时显示当前源
}
else
{
// 执行失败时显示默认源
if (ENGLISH)
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);
}
}


Expand Down
Loading