Skip to content

Commit a41ff32

Browse files
committed
get uv 使用 PowerShell 脚本
1 parent 79b9f8d commit a41ff32

3 files changed

Lines changed: 34 additions & 21 deletions

File tree

src/recipe/lang/Python/rawstr4c.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
21
#pragma once
32

43
/**
5-
* Generated by rawstr4c v1.0.0-2025/08/09
4+
* Generated by rawstr4c v1.1.0-2025/09/27
65
*/
76

87
char RAWSTR_pl_python_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x0a\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x0a\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x0a";
98

109
char RAWSTR_pl_python_get_uv_config[] = "\x67\x72\x65\x70\x20\x2d\x41\x20\x32\x20\x27\x69\x6e\x64\x65\x78\x27\x20\x40\x66\x40\x20\x7c\x20\x73\x65\x64\x20\x2d\x6e\x20\x27\x73\x2f\x5e\x75\x72\x6c\x20\x3d\x20\x22\x5c\x28\x2e\x2a\x5c\x29\x22\x2f\x5c\x31\x2f\x70\x27";
1110

11+
char RAWSTR_pl_python_get_uv_config_on_windows[] = "\x24\x6c\x69\x6e\x65\x73\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x3b\x0a\x0a\x66\x6f\x72\x28\x24\x69\x6e\x64\x65\x78\x3d\x30\x3b\x20\x24\x69\x6e\x64\x65\x78\x20\x2d\x6c\x74\x20\x24\x6c\x69\x6e\x65\x73\x2e\x43\x6f\x75\x6e\x74\x3b\x20\x24\x69\x6e\x64\x65\x78\x2b\x2b\x29\x20\x7b\x0a\x20\x20\x69\x66\x28\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x5d\x20\x2d\x6d\x61\x74\x63\x68\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x0a\x20\x20\x20\x20\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x2e\x2e\x28\x24\x69\x6e\x64\x65\x78\x2b\x33\x29\x5d\x0a\x20\x20\x7d\x0a\x7d";
12+
1213
char RAWSTR_pl_python_set_uv_config[] = "\x40\x73\x65\x64\x40\x20\x27\x2f\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x2f\x2c\x2f\x5e\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x24\x2f\x7b\x73\x7c\x5e\x75\x72\x6c\x20\x3d\x20\x22\x2e\x2a\x22\x24\x7c\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x7c\x3b\x7d\x27\x20\x40\x66\x40";
1314

14-
char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x24\x27\x20\x40\x66\x40";
15+
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";
1516

16-
char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22";
17+
char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x24\x27\x20\x40\x66\x40";
1718

1819
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";
1920

20-
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";
21+
char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22";
2122

22-
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\x24\x6c\x69\x6e\x65\x73\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x3b\x20\x66\x6f\x72\x28\x24\x69\x6e\x64\x65\x78\x3d\x30\x3b\x20\x24\x69\x6e\x64\x65\x78\x20\x2d\x6c\x74\x20\x24\x6c\x69\x6e\x65\x73\x2e\x43\x6f\x75\x6e\x74\x3b\x20\x24\x69\x6e\x64\x65\x78\x2b\x2b\x29\x20\x7b\x20\x69\x66\x28\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x5d\x20\x2d\x6d\x61\x74\x63\x68\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x20\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x2e\x2e\x28\x24\x69\x6e\x64\x65\x78\x2b\x33\x29\x5d\x20\x7d\x20\x7d\x22";

src/recipe/lang/Python/rawstr4c.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
! SPDX-License-Identifier: GPL-3.0-or-later
33
! -------------------------------------------------------------
44
! Config Type : rawstr4c (Markdown)
5-
! Config Authors: Aoran Zeng <ccmywish@qq.com>
6-
! | happy game <happygame1024@gmail.com>
7-
! Contributors : Nil Null <nil@null.org>
5+
! Config Authors: @ccmywish
6+
! | @happy-game
7+
! | @MingriLingran
8+
! Contributors : Nil Null <nil@null.org>
89
! Created On : <2025-07-14>
9-
! Last Modified : <2025-12-17>
10+
! Last Modified : <2025-12-29>
1011
! ---------------------------------------------------------- -->
1112

1213
# rawstr4c input for Python
@@ -41,8 +42,20 @@ grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p'
4142

4243
### Get uv config on Windows
4344

45+
为什么不用 `Select-String`,原因见: <https://github.com/RubyMetric/chsrc/pull/328#issuecomment-3695577870>
46+
47+
还有另外一个好处:如果 `[[index]]` 配置被写入了多次,可以这样检查出来
48+
49+
我们倾向于使用脚本而非命令,因为内容较长,便于用户检查到底执行了什么内容。
50+
4451
```powershell
45-
powershell -Command "$lines = Get-Content @f@; for($index=0; $index -lt $lines.Count; $index++) { if($lines[$index] -match '^\[\[index\]\]$') { $lines[$index..($index+3)] } }"
52+
$lines = Get-Content @f@;
53+
54+
for($index=0; $index -lt $lines.Count; $index++) {
55+
if($lines[$index] -match '^\[\[index\]\]$') {
56+
$lines[$index..($index+3)]
57+
}
58+
}
4659
```
4760

4861

@@ -83,4 +96,4 @@ powershell -Command "if (Get-Content @f@ | Select-String '^\[\[index\]\]$') { ex
8396
[[sources]]
8497
name = "@1@"
8598
url = "@2@"
86-
```
99+
```

src/recipe/lang/Python/uv.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pl_python_uv_prelude (void)
1010
chef_prep_this (pl_python_uv, gsr);
1111

1212
chef_set_created_on (this, "2024-12-11");
13-
chef_set_last_updated (this, "2025-12-28");
13+
chef_set_last_updated (this, "2025-12-29");
1414
chef_set_sources_last_updated (this, "2025-08-09");
1515

1616
chef_set_chef (this, NULL);
17-
chef_set_cooks (this, 1, "@happy-game");
18-
chef_set_sauciers (this, 3, "@MingriLingran", "@Kattos", "@ccmywish");
17+
chef_set_cooks (this, 2, "@happy-game", "@MingriLingran");
18+
chef_set_sauciers (this, 2, "@Kattos", "@ccmywish");
1919

2020
chef_allow_local_mode (this, FullyCan, NULL, NULL);
2121
chef_allow_english(this);
@@ -91,18 +91,18 @@ pl_python_uv_getsrc (char *option)
9191
}
9292

9393
/* 获取 [[index]] 配置项的 url */
94-
char *cmd = NULL;
9594
if (xy.on_windows)
9695
{
9796
/* 在 Windows 上使用 PowerShell 替代 grep */
98-
cmd = xy_str_gsub(RAWSTR_pl_python_get_uv_config_on_windows, "@f@", uv_config);
97+
char *script = xy_str_gsub (RAWSTR_pl_python_get_uv_config_on_windows, "@f@", uv_config);
98+
chsrc_run_as_pwsh_file (script);
9999
}
100100
else
101101
{
102-
/* 在 Linux 或 macOS 上使用 grep */
103-
cmd = xy_str_gsub(RAWSTR_pl_python_get_uv_config, "@f@", uv_config);
102+
/* 在类 Unix 系统上使用 grep */
103+
char *cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config, "@f@", uv_config);
104+
chsrc_run (cmd, RunOpt_Default);
104105
}
105-
chsrc_run(cmd, RunOpt_Default);
106106
}
107107

108108

@@ -147,7 +147,7 @@ pl_python_uv_setsrc (char *option)
147147
{
148148
cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
149149
}
150-
150+
151151
int status = xy_run_get_status (cmd);
152152
if (0==status)
153153
{

0 commit comments

Comments
 (0)