@@ -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-17 " );
13+ chef_set_last_updated (this , "2025-12-28 " );
1414 chef_set_sources_last_updated (this , "2025-08-09" );
1515
1616 chef_set_chef (this , NULL );
1717 chef_set_cooks (this , 1 , "@happy-game" );
18- chef_set_sauciers (this , 2 , "@Kattos" , "@ccmywish" );
18+ chef_set_sauciers (this , 3 , "@MingriLingran" , "@Kattos" , "@ccmywish" );
1919
2020 chef_allow_local_mode (this , FullyCan , NULL , NULL );
2121 chef_allow_english (this );
@@ -91,8 +91,18 @@ pl_python_uv_getsrc (char *option)
9191 }
9292
9393 /* 获取 [[index]] 配置项的 url */
94- char * cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config , "@f@" , uv_config );
95- chsrc_run (cmd , RunOpt_Default );
94+ char * cmd = NULL ;
95+ if (xy .on_windows )
96+ {
97+ /* 在 Windows 上使用 PowerShell 替代 grep */
98+ cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config_on_windows , "@f@" , uv_config );
99+ }
100+ else
101+ {
102+ /* 在 Linux 或 macOS 上使用 grep */
103+ cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config , "@f@" , uv_config );
104+ }
105+ chsrc_run (cmd , RunOpt_Default );
96106}
97107
98108
@@ -119,19 +129,6 @@ pl_python_uv_setsrc (char *option)
119129
120130 const char * source_content = xy_str_gsub (RAWSTR_pl_python_uv_config_source_content , "@url@" , source .url );
121131
122- #if defined(XY_Build_On_macOS ) || defined(XY_Build_On_BSD )
123- char * sed_cmd = "sed -i '' " ;
124- #else
125- char * sed_cmd = "sed -i " ;
126- #endif
127-
128- /**
129- * 将 [[index]] 到 default = true 之间的 url = ".*" 替换为 url = "source.url"
130- */
131- char * update_config_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config , "@sed@" , sed_cmd );
132- update_config_cmd = xy_str_gsub (update_config_cmd , "@f@" , uv_config );
133- update_config_cmd = xy_str_gsub (update_config_cmd , "@url@" , source .url );
134-
135132 if (!xy_file_exist (uv_config ))
136133 {
137134 /* 当 uv_config 不存在,直接写入文件 */
@@ -140,12 +137,41 @@ pl_python_uv_setsrc (char *option)
140137 else
141138 {
142139 /* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */
143- char * cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source , "@f@" , uv_config );
144- chsrc_ensure_program ("grep" );
140+ char * cmd = NULL ;
141+ if (xy .on_windows )
142+ {
143+ /* 在 Windows 上使用 PowerShell 替代 grep */
144+ cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source_on_windows , "@f@" , uv_config );
145+ }
146+ else
147+ {
148+ cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source , "@f@" , uv_config );
149+ }
150+
145151 int status = xy_run_get_status (cmd );
146152 if (0 == status )
147153 {
148- chsrc_run (update_config_cmd , RunOpt_Default );
154+ if (xy .on_windows )
155+ {
156+ /* 在 Windows 上使用 PowerShell 替代 sed */
157+ char * powershell_cmd_with_file = xy_str_gsub (RAWSTR_pl_python_set_uv_config_on_windows , "@f@" , uv_config );
158+ char * powershell_cmd = xy_str_gsub (powershell_cmd_with_file , "@url@" , source .url );
159+ chsrc_run (powershell_cmd , RunOpt_Default );
160+ }
161+ else
162+ {
163+ /* 非 Windows 系统使用 sed */
164+ char * sed_cmd = NULL ;
165+ #if defined(XY_Build_On_macOS ) || defined(XY_Build_On_BSD )
166+ sed_cmd = "sed -i '' " ;
167+ #else
168+ sed_cmd = "sed -i " ;
169+ #endif
170+ char * update_config_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config , "@sed@" , sed_cmd );
171+ update_config_cmd = xy_str_gsub (update_config_cmd , "@f@" , uv_config );
172+ update_config_cmd = xy_str_gsub (update_config_cmd , "@url@" , source .url );
173+ chsrc_run (update_config_cmd , RunOpt_Default );
174+ }
149175 }
150176 else
151177 {
0 commit comments