Skip to content

Commit

Permalink
Support Rye for Python
Browse files Browse the repository at this point in the history
[GitHub #127]
  • Loading branch information
ccmywish committed Dec 6, 2024
1 parent 3e62f2a commit 5ec75b3
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/chsrc-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* | GnixAij <gaojiaxing0220@gmail.com>
* | ChatGPT <https://chatgpt.com>
* | czyt <czyt.go@gmail.com>
* | zouri <guoshuaisun@outlook.com>
* |
* Created On : <2023-08-28>
* Last Modified : <2024-11-22>
* Last Modified : <2024-12-06>
*
* chsrc: Change Source —— 全平台通用命令行换源工具
* ------------------------------------------------------------*/

#define Chsrc_Version "0.1.9.4"
#define Chsrc_Version "0.1.9.4-dev1"
#define Chsrc_Release_Date "2024/11/22"
#define Chsrc_Banner_Version "v" Chsrc_Version "-" Chsrc_Release_Date
#define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc"
Expand All @@ -38,6 +39,7 @@
#include "recipe/lang/Python/pip.c"
#include "recipe/lang/Python/Poetry.c"
#include "recipe/lang/Python/PDM.c"
#include "recipe/lang/Python/Rye.c"
#include "recipe/lang/Python/Python.c"

#include "recipe/lang/Node.js/common.h"
Expand Down
2 changes: 1 addition & 1 deletion src/recipe/lang/Python/PDM.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Contributors : Nul None <nul@none.org>
* Created On : <2024-06-05>
* Last Modified : <2024-09-14>
* ------------------------------------------------------------*/
Expand Down
89 changes: 89 additions & 0 deletions src/recipe/lang/Python/Rye.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2024-12-06>
* Last Modified : <2024-12-06>
*
* 由于Rye已经有后继uv了,所以我们不把该管理器纳入Python group中
* ------------------------------------------------------------*/

char *
pl_python_find_rye_config ()
{
char *buf = xy_run ("rye config --show-path", 0, NULL);
char *rye_config = xy_normalize_path (xy_str_strip (buf));

return rye_config;
}

/**
* chsrc get rye
*/
void
pl_python_rye_getsrc (char *option)
{
char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strjoin (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容"));
}


/**
* @consult https://github.com/RubyMetric/chsrc/issues/127
* @consult recipe Java
*
* chsrc set rye
*/
void
pl_python_rye_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_python);

const char *file = xy_strjoin (7,
"[[sources]]\n",
"name = \"", source.mirror->abbr, "\"\n",
"url = \"", source.url, "\"");

char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strjoin (3, "请在您的 Rye 配置文件 ", rye_config, " 中添加:"));
puts (file);

ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}


/**
* chsrc reset rye
*/
void
pl_python_rye_resetsrc (char *option)
{
pl_python_rye_setsrc (option);
}


/**
* chsrc ls rye
*/
Feature_t
pl_python_rye_feat (char *option)
{
Feature_t f = {0};

f.can_get = true;
f.can_reset = true;

f.cap_locally = true;
f.cap_locally_explain = NULL;

f.can_english = false;
f.can_user_define = true;

f.note = NULL;
return f;
}

// def_target_gsrf(pl_python_rye);
Target_t pl_python_rye_target = {def_target_inner_gsrf(pl_python_rye),def_target_sourcesn(pl_python)};
2 changes: 1 addition & 1 deletion src/recipe/lang/Python/pip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Contributors : Nul None <nul@none.org>
* Created On : <2023-09-03>
* Last Modified : <2024-09-14>
* ------------------------------------------------------------*/
Expand Down
5 changes: 3 additions & 2 deletions src/recipe/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-01>
* Major Revision : 1
* Last Modified : <2024-10-29>
* Last Modified : <2024-12-06>
* ------------------------------------------------------------*/

/* Begin Target Matrix */
Expand All @@ -17,6 +17,7 @@ static const char
*pl_python_pip[] = {"pip", NULL, t(&pl_python_pip_target)},
*pl_python_poetry[] = {"poetry", NULL, t(&pl_python_poetry_target)},
*pl_python_pdm[] = {"pdm", NULL, t(&pl_python_pdm_target)},
*pl_python_rye[] = {"rye", NULL, t(&pl_python_rye_target)},

*pl_nodejs[] = {"node", "nodejs", NULL, t(&pl_nodejs_target)},
*pl_nodejs_bun[] = {"bun", NULL, t(&pl_nodejs_bun_target)},
Expand Down Expand Up @@ -47,7 +48,7 @@ static const char
**pl_packagers[] =
{
pl_ruby,
pl_python, pl_python_pip, pl_python_poetry, pl_python_pdm,
pl_python, pl_python_pip, pl_python_poetry, pl_python_pdm, pl_python_rye,
pl_nodejs, pl_nodejs_bun,
pl_nodejs_npm, pl_nodejs_pnpm, pl_nodejs_yarn,
pl_nodejs_nvm,
Expand Down

0 comments on commit 5ec75b3

Please sign in to comment.