Update pyproject-toml to support PEP 639 (#13902)

Fixes #13869
This commit is contained in:
konsti 2024-11-18 15:16:02 +01:00 committed by Micha Reiser
parent 8b925ea626
commit b46cc6ac0b
10 changed files with 77 additions and 47 deletions

63
Cargo.lock generated
View file

@ -212,6 +212,12 @@ dependencies = [
"generic-array",
]
[[package]]
name = "boxcar"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f839cdf7e2d3198ac6ca003fd8ebc61715755f41c1cad15ff13df67531e00ed"
[[package]]
name = "bstr"
version = "1.11.0"
@ -1935,18 +1941,6 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a"
[[package]]
name = "pep440_rs"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c29f9c43de378b4e4e0cd7dbcce0e5cfb80443de8c05620368b2948bc936a1"
dependencies = [
"once_cell",
"regex",
"serde",
"unicode-width 0.1.13",
]
[[package]]
name = "pep440_rs"
version = "0.7.2"
@ -1956,22 +1950,29 @@ dependencies = [
"serde",
"unicode-width 0.2.0",
"unscanny",
"version-ranges",
]
[[package]]
name = "pep508_rs"
version = "0.3.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "910c513bea0f4f833122321c0f20e8c704e01de98692f6989c2ec21f43d88b1e"
checksum = "8c2feee999fa547bacab06a4881bacc74688858b92fa8ef1e206c748b0a76048"
dependencies = [
"boxcar",
"indexmap",
"itertools 0.13.0",
"once_cell",
"pep440_rs 0.4.0",
"pep440_rs",
"regex",
"rustc-hash 2.0.0",
"serde",
"smallvec",
"thiserror 1.0.67",
"tracing",
"unicode-width 0.1.13",
"unicode-width 0.2.0",
"url",
"urlencoding",
"version-ranges",
]
[[package]]
@ -2135,14 +2136,15 @@ dependencies = [
[[package]]
name = "pyproject-toml"
version = "0.9.0"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95c3dd745f99aa3c554b7bb00859f7d18c2f1d6afd749ccc86d60b61e702abd9"
checksum = "643af57c3f36ba90a8b53e972727d8092f7408a9ebfbaf4c3d2c17b07c58d835"
dependencies = [
"indexmap",
"pep440_rs 0.4.0",
"pep440_rs",
"pep508_rs",
"serde",
"thiserror 1.0.67",
"toml",
]
@ -2370,7 +2372,7 @@ dependencies = [
"glob",
"insta",
"notify",
"pep440_rs 0.7.2",
"pep440_rs",
"rayon",
"red_knot_python_semantic",
"red_knot_vendored",
@ -2729,7 +2731,7 @@ dependencies = [
"natord",
"path-absolutize",
"pathdiff",
"pep440_rs 0.7.2",
"pep440_rs",
"pyproject-toml",
"quick-junit",
"regex",
@ -3060,7 +3062,7 @@ dependencies = [
"matchit",
"path-absolutize",
"path-slash",
"pep440_rs 0.7.2",
"pep440_rs",
"regex",
"ruff_cache",
"ruff_formatter",
@ -3960,6 +3962,12 @@ dependencies = [
"serde",
]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf16_iter"
version = "1.0.5"
@ -4007,6 +4015,15 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "version-ranges"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8d079415ceb2be83fc355adbadafe401307d5c309c7e6ade6638e6f9f42f42d"
dependencies = [
"smallvec",
]
[[package]]
name = "version_check"
version = "0.9.4"

View file

@ -111,7 +111,7 @@ pathdiff = { version = "0.2.1" }
pep440_rs = { version = "0.7.1" }
pretty_assertions = "1.3.0"
proc-macro2 = { version = "1.0.79" }
pyproject-toml = { version = "0.9.0" }
pyproject-toml = { version = "0.13.4" }
quick-junit = { version = "0.5.0" }
quote = { version = "1.0.23" }
rand = { version = "0.8.5" }

View file

@ -0,0 +1,6 @@
[project]
name = "hello-world"
version = "0.1.0"
# PEP 639 - passing
license = "MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)"
license-files = ["LICEN[CS]E*", "AUTHORS*", "licenses/LICENSE.MIT"]

View file

@ -1,5 +1,3 @@
# license-files is wrong here
# https://github.com/PyO3/maturin/issues/1615
[build-system]
requires = [ "maturin>=0.14", "numpy", "wheel", "patchelf",]
build-backend = "maturin"

View file

@ -372,7 +372,8 @@ mod tests {
#[test_case(Rule::InvalidPyprojectToml, Path::new("bleach"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("invalid_author"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("maturin"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("maturin_gh_1615"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("various_invalid"))]
#[test_case(Rule::InvalidPyprojectToml, Path::new("pep639"))]
fn invalid_pyproject_toml(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
let path = test_resource_path("fixtures")

View file

@ -2,7 +2,7 @@
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: Version specifier `>=1.1.0<1.2` doesn't match PEP 440 rules
pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: after parsing `1.1.0`, found `<1.2`, which is not part of a valid version
tinycss2>=1.1.0<1.2
^^^^^^^^^^^
|

View file

@ -2,11 +2,13 @@
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:6:84: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string
pyproject.toml:5:11: RUF200 Failed to parse pyproject.toml: a table with 'name' and/or 'email' keys
|
4 | # Ensure that the spans from toml handle utf-8 correctly
5 | authors = [
6 | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 }
| ^ RUF200
7 | ]
3 | version = "0.1.0"
4 | # Ensure that the spans from toml handle utf-8 correctly
5 | authors = [
| ___________^
6 | | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 }
7 | | ]
| |_^ RUF200
|

View file

@ -1,13 +0,0 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:9:17: RUF200 Failed to parse pyproject.toml: wanted string or table
|
7 | [project]
8 | name = "..."
9 | license-files = [ "license.txt",]
| ^^^^^^^^^^^^^^^^^ RUF200
10 | requires-python = ">=3.8"
11 | requires-dist = [ "maturin>=0.14", "...",]
|

View file

@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---

View file

@ -0,0 +1,15 @@
---
source: crates/ruff_linter/src/rules/ruff/mod.rs
snapshot_kind: text
---
pyproject.toml:10:16: RUF200 Failed to parse pyproject.toml: URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ /path/to/file`).
...
^^^
|
8 | requires-python = ">=3.8"
9 | requires-dist = [ "maturin>=0.14", "...",]
10 | dependencies = [ "packaging", "...",]
| ^^^^^^^^^^^^^^^^^^^^^^ RUF200
11 | zip-safe = false
12 | version = "..."
|