Skip to content

Commit 52f2ea5

Browse files
Merge pull request #1 from MingriLingran/dev
Dev
2 parents 08b213a + f7393fa commit 52f2ea5

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/recipe/lang/Python/rawstr4c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x2
1414

1515
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";
1616

17+
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";
18+
19+
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";

src/recipe/lang/Python/rawstr4c.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p'
4545
@sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|;}' @f@
4646
```
4747

48+
### Set uv config on Windows
49+
50+
```powershell
51+
powershell -Command "$content = Get-Content '@f@'; $content = $content -replace '^url = \".*\"$', 'url = \"@url@\"'; $content | Set-Content '@f@'"
52+
```
53+
4854

4955
### Test uv if set source
5056

5157
```sh
5258
grep -q '^\[\[index]]$' @f@
5359
```
5460

61+
### Test uv if set source on Windows
62+
63+
```powershell
64+
powershell -Command "if (Get-Content @f@ | Select-String '^\[\[index\]\]$') { exit 0 } else { exit 1 }"
65+
```
66+
5567
<br>
5668

5769

@@ -64,4 +76,4 @@ grep -q '^\[\[index]]$' @f@
6476
[[sources]]
6577
name = "@1@"
6678
url = "@2@"
67-
```
79+
```

src/recipe/lang/Python/uv.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pl_python_uv_setsrc (char *option)
131131
if (xy.on_windows)
132132
{
133133
/* 在 Windows 上使用 PowerShell 替代 grep */
134-
cmd = xy_str_gsub("powershell -Command \"if (Get-Content @f@ | Select-String '^\\[\\[index\\]\\]$') { exit 0 } else { exit 1 }\"", "@f@", uv_config);
134+
cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source_on_windows, "@f@", uv_config);
135135
}
136136
else
137137
{
@@ -144,8 +144,7 @@ pl_python_uv_setsrc (char *option)
144144
if (xy.on_windows)
145145
{
146146
/* 在 Windows 上使用 PowerShell 替代 sed */
147-
char *powershell_cmd_template = "powershell -Command \"$content = Get-Content '@f@'; $content = $content -replace '^url = \\\".*\\\"$', 'url = \\\"@url@\\\"'; $content | Set-Content '@f@'\"";
148-
char *powershell_cmd_with_file = xy_str_gsub(powershell_cmd_template, "@f@", uv_config);
147+
char *powershell_cmd_with_file = xy_str_gsub(RAWSTR_pl_python_set_uv_config_on_windows, "@f@", uv_config);
149148
char *powershell_cmd = xy_str_gsub(powershell_cmd_with_file, "@url@", source.url);
150149
chsrc_run (powershell_cmd, RunOpt_Default);
151150
}

0 commit comments

Comments
 (0)