Skip pip when -local

[GitHub #79]
This commit is contained in:
Aoran Zeng 2024-09-13 19:33:00 +08:00
parent 48cefa1b1d
commit 7901491c39
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
3 changed files with 42 additions and 43 deletions

View File

@ -341,7 +341,7 @@ query_mirror_exist (SourceInfo *sources, size_t size, char *target, char *input)
if (xy_streql ("first", input))
{
char *msg = CliOpt_InEnglish ? "Will use the first speed source measured by maintainers" : "将使用维护团队测速第一的源";
char *msg = CliOpt_InEnglish ? "Will use the first speedy source measured by maintainers" : "将使用维护团队测速第一的源";
say (msg);
return 1; // 返回第2个因为第1个是上游默认源
}

View File

@ -34,53 +34,14 @@ def_sources_n(pl_python);
void
pl_python_getsrc (char *option)
{
char *prog_name = NULL;
pl_python_get_py_program_name (&prog_name);
bool pdm_exist = false,
poetry_exist = false;
pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist);
if (prog_name)
{
pl_python_pip_setsrc (option);
say ("");
}
if (poetry_exist)
{
pl_python_poetry_setsrc (option);
say ("");
}
if (pdm_exist)
{
pl_python_pdm_setsrc (option);
}
}
void
pl_python_setsrc (char *option)
{
char *chsrc_type = xy_streql (option, ChsrcTypeReset) ? ChsrcTypeReset : ChsrcTypeAuto;
char *prog_name = NULL;
pl_python_get_py_program_name (&prog_name);
bool pdm_exist = false,
poetry_exist = false;
pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist);
// chsrc_yield_source_and_confirm (pl_python);
if (prog_name)
{
pl_python_pip_getsrc (option);
say ("");
}
// 交给后面检查命令的存在性
pl_python_pip_getsrc (option);
say ("");
if (poetry_exist)
{
@ -92,6 +53,35 @@ pl_python_setsrc (char *option)
{
pl_python_pdm_getsrc (option);
}
}
void
pl_python_setsrc (char *option)
{
char *chsrc_type = xy_streql (option, ChsrcTypeReset) ? ChsrcTypeReset : ChsrcTypeAuto;
bool pdm_exist = false,
poetry_exist = false;
pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist);
// chsrc_yield_source_and_confirm (pl_python);
// 交给后面检查命令的存在性
pl_python_pip_setsrc (option);
say ("");
if (poetry_exist)
{
pl_python_poetry_setsrc (option);
say ("");
}
if (pdm_exist)
{
pl_python_pdm_setsrc (option);
}
// chsrc_conclude (&source, chsrc_type);
}

View File

@ -50,6 +50,15 @@ pl_python_pip_getsrc (char *option)
void
pl_python_pip_setsrc (char *option)
{
// 对于不支持的情况,尽早结束
if (CliOpt_Locally)
{
char *msg = CliOpt_InEnglish ? "pip doesn't support `-local`. SKIP changing source!" : "pip 不支持 -local跳过换源";
chsrc_error (msg);
// 不能直接退出,因为 Leader target 不能就此结束
return;
}
chsrc_yield_source_and_confirm (pl_python_pip);
char *py_prog_name = NULL;