From 3ff23763517122716313fb7c2506d72e2687161f Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 13 Sep 2024 19:12:41 +0800 Subject: [PATCH] Separate `Poetry` out [GitHub #79] --- src/recipe/lang/Python/Poetry.c | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/recipe/lang/Python/Poetry.c diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c new file mode 100644 index 0000000..6492df1 --- /dev/null +++ b/src/recipe/lang/Python/Poetry.c @@ -0,0 +1,96 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2024-08-08> + * Last Modified : <2024-09-13> + * ------------------------------------------------------------*/ + +// @note Poetry 默认使用项目级换源 + + +/** + * @update 2024-05-24 + * @note 不要添加Zju,浙大的pypi在校外访问会自动转向Tuna + */ +static SourceInfo +pl_python_poetry_sources[] = { + {&Upstream, "https://pypi.org/simple"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/pypi/web/simple"}, + {&Lzuoss, "https://mirror.lzu.edu.cn/pypi/web/simple"}, + {&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple"}, + {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/pypi/web/simple"}, + {&Tuna, "https://pypi.tuna.tsinghua.edu.cn/simple"}, + {&Ali, "https://mirrors.aliyun.com/pypi/simple/"}, + {&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple"}, + {&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple"}, + {&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple"} + // {&Netease, "https://mirrors.163.com/.help/pypi.html"} // 不用,24小时更新一次 +}; +def_sources_n(pl_python_poetry); + + +/** + * chsrc get poetry + */ +void +pl_python_poetry_getsrc (char *option) +{ + chsrc_note2 ("poetry换源情况: 请查阅本项目 pyproject.toml 中 [[tool.poetry.source]]"); +} + + +/** + * @consult https://python-poetry.org/docs/repositories/#project-configuration + * + * chsrc set poetry + */ +void +pl_python_poetry_setsrc (char *option) +{ + chsrc_yield_source_and_confirm (pl_python_poetry); + + char *cmd = NULL; + + if (CliOpt_Locally==false) + chsrc_note2 ("Poertry 仅支持项目级换源"); + + cmd = xy_2strjoin ("poetry source add my_mirror ", source.url); + chsrc_run (cmd, RunOpt_Default); + + chsrc_conclude (&source, ChsrcTypeAuto); +} + + +/** + * chsrc reset poetry + */ +void +pl_python_poetry_resetsrc (char *option) +{ + pl_python_poetry_setsrc (ChsrcTypeReset); +} + + +/** + * chsrc ls poetry + */ +FeatInfo +pl_python_poetry_feat (char *option) +{ + FeatInfo fi = {0}; + + fi.can_get = true; + fi.can_reset = true; + + fi.stcan_locally = CanFully; + fi.locally = NULL; + fi.can_english = false; + fi.can_user_define = true; + + fi.note = NULL; + return fi; +} + +def_target_gsrf(pl_python_poetry);