Commit 98cc93a
authored
Validate pyproject.toml before installing dependencies (#1066)
This PR implements validation for `pyproject.toml` when installing
dependencies, addressing issue
#411. It's
an initial implementation that covers some most common formatting
errors, we can definitely expand coverage as we receive user feedback.
This PR
1. Ensured `pyproject.toml` adheres to relevant PEP standards (PEP 508,
PEP 440, PEP 621, PEP 518) before attempting to install packages from it
and provides feedback when validation fails, allowing the user to fix
the file or proceed if they choose.
It added `validatePyprojectToml` in `pipUtils.ts` which checks:
- Package Name (PEP 508): Validates name format (alphanumeric, dots,
hyphens, underscores).
<img width="461" height="96" alt="image"
src="https://github.com/user-attachments/assets/ca5aa95f-7bc8-47cf-a5c7-80f048e0feac"
/>
- Version Format (PEP 440): Validates version strings against the
standard (including pre/post/dev/local releases).
<img width="450" height="91" alt="image"
src="https://github.com/user-attachments/assets/1c0fb176-6ade-45a4-a0fe-356f86695f07"
/>
- Required Fields (PEP 621): Checks for the presence of the required
name field in the [project] section.
<img width="447" height="83" alt="image"
src="https://github.com/user-attachments/assets/5762f22e-a4ce-4553-8185-efd9f4b9f37e"
/>
- Build System (PEP 518): Checks for the presence of the required
requires field in the [build-system] section.
<img width="446" height="92" alt="image"
src="https://github.com/user-attachments/assets/5ea2559e-0704-40cb-a763-e2ac8b92601d"
/>
2. Implemented `shouldProceedAfterPyprojectValidation` to display an
error message with options to "Open pyproject.toml", "Continue Anyway",
or "Cancel", only when user selects dependencies from incorrectly
formatted `pypyroject.toml` file to install when creating environment.
Example user flow:
https://github.com/user-attachments/assets/4e919f2a-1934-4b8e-80d3-579880830b5a
3. Added a new test file `helpers.validatePyproject.unit.test.ts` with
comprehensive unit tests.1 parent f026743 commit 98cc93a
File tree
7 files changed
+668
-21
lines changed- src
- common
- managers/builtin
- test/managers/builtin
7 files changed
+668
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
16 | 73 | | |
17 | 74 | | |
18 | 75 | | |
| |||
78 | 135 | | |
79 | 136 | | |
80 | 137 | | |
81 | | - | |
| 138 | + | |
82 | 139 | | |
83 | 140 | | |
84 | 141 | | |
85 | 142 | | |
| 143 | + | |
86 | 144 | | |
87 | 145 | | |
88 | 146 | | |
| |||
124 | 182 | | |
125 | 183 | | |
126 | 184 | | |
127 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
128 | 199 | | |
129 | 200 | | |
130 | 201 | | |
| |||
136 | 207 | | |
137 | 208 | | |
138 | 209 | | |
139 | | - | |
| 210 | + | |
140 | 211 | | |
141 | 212 | | |
142 | 213 | | |
| |||
148 | 219 | | |
149 | 220 | | |
150 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
151 | 246 | | |
152 | 247 | | |
153 | 248 | | |
154 | 249 | | |
155 | 250 | | |
156 | 251 | | |
157 | 252 | | |
158 | | - | |
| 253 | + | |
159 | 254 | | |
160 | 255 | | |
161 | 256 | | |
162 | 257 | | |
163 | 258 | | |
164 | 259 | | |
165 | | - | |
| 260 | + | |
166 | 261 | | |
167 | 262 | | |
168 | 263 | | |
169 | 264 | | |
170 | 265 | | |
171 | | - | |
| 266 | + | |
172 | 267 | | |
173 | | - | |
| 268 | + | |
174 | 269 | | |
175 | 270 | | |
176 | 271 | | |
| 272 | + | |
| 273 | + | |
177 | 274 | | |
178 | 275 | | |
179 | 276 | | |
| |||
204 | 301 | | |
205 | 302 | | |
206 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
207 | 316 | | |
208 | 317 | | |
209 | 318 | | |
| |||
219 | 328 | | |
220 | 329 | | |
221 | 330 | | |
222 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
223 | 374 | | |
224 | 375 | | |
225 | 376 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 235 | + | |
238 | 236 | | |
239 | 237 | | |
240 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | | - | |
| 343 | + | |
| 344 | + | |
339 | 345 | | |
340 | 346 | | |
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
344 | 357 | | |
345 | 358 | | |
346 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
| 400 | + | |
400 | 401 | | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
404 | 405 | | |
405 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
406 | 413 | | |
407 | 414 | | |
408 | 415 | | |
| |||
0 commit comments