From 84503248d59de9e67fefac2b41557ae430dab276 Mon Sep 17 00:00:00 2001 From: LinRan Date: Sun, 28 Dec 2025 14:07:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(python/uv):=20=E6=B7=BB=E5=8A=A0=20Windows?= =?UTF-8?q?=20=E5=B9=B3=E5=8F=B0=20uv=20=E9=85=8D=E7=BD=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recipe/lang/Python/rawstr4c.h | 5 ++++- src/recipe/lang/Python/rawstr4c.md | 7 +++++++ src/recipe/lang/Python/uv.c | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/recipe/lang/Python/rawstr4c.h b/src/recipe/lang/Python/rawstr4c.h index c1a8dc0..c96f57d 100644 --- a/src/recipe/lang/Python/rawstr4c.h +++ b/src/recipe/lang/Python/rawstr4c.h @@ -1,3 +1,4 @@ + #pragma once /** @@ -16,4 +17,6 @@ char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x char RAWSTR_pl_python_test_uv_if_set_source_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x69\x66\x20\x28\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x20\x7c\x20\x53\x65\x6c\x65\x63\x74\x2d\x53\x74\x72\x69\x6e\x67\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x20\x65\x78\x69\x74\x20\x30\x20\x7d\x20\x65\x6c\x73\x65\x20\x7b\x20\x65\x78\x69\x74\x20\x31\x20\x7d\x22"; -char RAWSTR_pl_python_set_uv_config_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x2d\x72\x65\x70\x6c\x61\x63\x65\x20\x27\x5e\x75\x72\x6c\x20\x3d\x20\x5c\x22\x2e\x2a\x5c\x22\x24\x27\x2c\x20\x27\x75\x72\x6c\x20\x3d\x20\x5c\x22\x40\x75\x72\x6c\x40\x5c\x22\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x7c\x20\x53\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x22"; \ No newline at end of file +char RAWSTR_pl_python_set_uv_config_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x2d\x72\x65\x70\x6c\x61\x63\x65\x20\x27\x5e\x75\x72\x6c\x20\x3d\x20\x5c\x22\x2e\x2a\x5c\x22\x24\x27\x2c\x20\x27\x75\x72\x6c\x20\x3d\x20\x5c\x22\x40\x75\x72\x6c\x40\x5c\x22\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x7c\x20\x53\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x22"; + +char RAWSTR_pl_python_get_uv_config_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x22"; \ No newline at end of file diff --git a/src/recipe/lang/Python/rawstr4c.md b/src/recipe/lang/Python/rawstr4c.md index 7f87b61..abcc2c4 100644 --- a/src/recipe/lang/Python/rawstr4c.md +++ b/src/recipe/lang/Python/rawstr4c.md @@ -39,6 +39,13 @@ grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p' ``` +### Get uv config on Windows + +```powershell +powershell -Command "Get-Content '@f@'" +``` + + ### Set uv config ```sh diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index d2caf9d..05edd5f 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -91,8 +91,18 @@ pl_python_uv_getsrc (char *option) } /* 获取 [[index]] 配置项的 url */ - char *cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config, "@f@", uv_config); - chsrc_run (cmd, RunOpt_Default); + char *cmd = NULL; + if (xy.on_windows) + { + /* 在 Windows 上使用 PowerShell 替代 grep */ + cmd = xy_str_gsub(RAWSTR_pl_python_get_uv_config_on_windows, "@f@", uv_config); + } + else + { + /* 在 Linux 或 macOS 上使用 grep */ + cmd = xy_str_gsub(RAWSTR_pl_python_get_uv_config, "@f@", uv_config); + } + chsrc_run(cmd, RunOpt_Default); }