mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 05:15:00 +00:00
Copy over pep440-rs
crate (#30)
This PR copies over the `pep440-rs` crate at commit `a8303b01ffef6fccfdce562a887f6b110d482ef3` with no modifications. It won't pass CI, but modifications will intentionally be confined to later PRs.
This commit is contained in:
parent
1e6a217503
commit
f03398bee3
15 changed files with 3480 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
|||
# Crates
|
||||
|
||||
## [pep440-rs](./pep440-rs)
|
||||
|
||||
Utilities for interacting with Python version numbers and specifiers.
|
||||
|
||||
## [puffin-cli](./puffin-cli)
|
||||
|
||||
Command-line interface for the Puffin package manager.
|
||||
|
|
410
crates/pep440-rs/Cargo.lock
generated
Normal file
410
crates/pep440-rs/Cargo.lock
generated
Normal file
|
@ -0,0 +1,410 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306"
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.148"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pep440_rs"
|
||||
version = "0.3.12"
|
||||
dependencies = [
|
||||
"indoc 2.0.4",
|
||||
"lazy_static",
|
||||
"pyo3",
|
||||
"regex",
|
||||
"serde",
|
||||
"tracing",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"indoc 1.0.9",
|
||||
"libc",
|
||||
"memoffset",
|
||||
"parking_lot",
|
||||
"pyo3-build-config",
|
||||
"pyo3-ffi",
|
||||
"pyo3-macros",
|
||||
"unindent",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-build-config"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-ffi"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pyo3-build-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"pyo3-macros-backend",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pyo3-macros-backend"
|
||||
version = "0.19.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.188"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.188"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.12.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.37",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
|
||||
[[package]]
|
||||
name = "unindent"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c"
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
25
crates/pep440-rs/Cargo.toml
Normal file
25
crates/pep440-rs/Cargo.toml
Normal file
|
@ -0,0 +1,25 @@
|
|||
[package]
|
||||
name = "pep440_rs"
|
||||
version = "0.3.12"
|
||||
description = "A library for python version numbers and specifiers, implementing PEP 440"
|
||||
edition = "2021"
|
||||
include = ["/src", "Changelog.md", "License-Apache", "License-BSD", "Readme.md", "pyproject.toml"]
|
||||
# Same license as pypa/packaging where the tests are from
|
||||
license = "Apache-2.0 OR BSD-2-Clause"
|
||||
repository = "https://github.com/konstin/pep440-rs"
|
||||
readme = "Readme.md"
|
||||
|
||||
[lib]
|
||||
name = "pep440_rs"
|
||||
crate-type = ["rlib", "cdylib"]
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.4.0"
|
||||
pyo3 = { version = "0.19", optional = true, features = ["extension-module", "abi3-py37"] }
|
||||
regex = { version = "1.8.1", default-features = false, features = ["std", "perf", "unicode-case", "unicode-perl"] }
|
||||
serde = { version = "1.0.162", features = ["derive"], optional = true }
|
||||
tracing = { version = "0.1.37", optional = true }
|
||||
unicode-width = "0.1.10"
|
||||
|
||||
[dev-dependencies]
|
||||
indoc = "2.0.1"
|
51
crates/pep440-rs/Changelog.md
Normal file
51
crates/pep440-rs/Changelog.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
## 0.3.12
|
||||
|
||||
* Implement `FromPyObject` for `Version`
|
||||
|
||||
## 0.3.11
|
||||
|
||||
* CI fix
|
||||
|
||||
## 0.3.10
|
||||
|
||||
* Update pyo3 to 0.19 and maturin to 1.0
|
||||
|
||||
## 0.3.7
|
||||
|
||||
* Add `major()`, `minor()` and `micro()` to `Version` by ischaojie ([#9](https://github.com/konstin/pep440-rs/pull/9))
|
||||
|
||||
* ## 0.3.6
|
||||
|
||||
* Fix Readme display
|
||||
|
||||
## 0.3.5
|
||||
|
||||
* Make string serialization look more like poetry's
|
||||
* Implement `__hash__` for `VersionSpecifier`
|
||||
|
||||
## 0.3.4
|
||||
|
||||
* Python bindings for `VersionSpecifiers`
|
||||
|
||||
## 0.3.3
|
||||
|
||||
* Implement `Display` for `VersionSpecifiers`
|
||||
|
||||
## 0.3.2
|
||||
|
||||
* Expose `VersionSpecifier().operator` and `VersionSpecifier().version` to Python
|
||||
|
||||
## 0.3.1
|
||||
|
||||
* Expose `Version` from `PyVersion`
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Introduced a `PyVersion` wrapper specifically for the Python bindings to work around https://github.com/PyO3/pyo3/pull/2786
|
||||
* Added `VersionSpecifiers::contains`
|
||||
* Added `Version::from_release`, a constructor for a version that is just a release such as `3.8`.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Added `VersionSpecifiers`, a thin wrapper around `Vec<VersionSpecifier>` with a serde implementation. `VersionSpecifiers::from_str` is now preferred over `parse_version_specifiers`.
|
||||
* Reexport rust function for python module
|
176
crates/pep440-rs/License-Apache
Normal file
176
crates/pep440-rs/License-Apache
Normal file
|
@ -0,0 +1,176 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
22
crates/pep440-rs/License-BSD
Normal file
22
crates/pep440-rs/License-BSD
Normal file
|
@ -0,0 +1,22 @@
|
|||
Copyright (c) 2023 konstin
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
56
crates/pep440-rs/Readme.md
Normal file
56
crates/pep440-rs/Readme.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
# PEP440 in rust
|
||||
|
||||
[](https://crates.io/crates/pep440_rs)
|
||||
[](https://pypi.org/project/pep440_rs)
|
||||
|
||||
A library for python version numbers and specifiers, implementing
|
||||
[PEP 440](https://peps.python.org/pep-0440). See [Reimplementing PEP 440](https://cohost.org/konstin/post/514863-reimplementing-pep-4) for some background.
|
||||
|
||||
Higher level bindings to the requirements syntax are available in [pep508_rs](https://github.com/konstin/pep508_rs).
|
||||
|
||||
```rust
|
||||
use std::str::FromStr;
|
||||
use pep440_rs::{parse_version_specifiers, Version, VersionSpecifier};
|
||||
|
||||
let version = Version::from_str("1.19").unwrap();
|
||||
let version_specifier = VersionSpecifier::from_str("==1.*").unwrap();
|
||||
assert!(version_specifier.contains(&version));
|
||||
let version_specifiers = parse_version_specifiers(">=1.16, <2.0").unwrap();
|
||||
assert!(version_specifiers.iter().all(|specifier| specifier.contains(&version)));
|
||||
```
|
||||
|
||||
In python (`pip install pep440_rs`):
|
||||
|
||||
```python
|
||||
from pep440_rs import Version, VersionSpecifier
|
||||
|
||||
assert Version("1.1a1").any_prerelease()
|
||||
assert Version("1.1.dev2").any_prerelease()
|
||||
assert not Version("1.1").any_prerelease()
|
||||
assert VersionSpecifier(">=1.0").contains(Version("1.1a1"))
|
||||
assert not VersionSpecifier(">=1.1").contains(Version("1.1a1"))
|
||||
# Note that python comparisons are the version ordering, not the version specifiers operators
|
||||
assert Version("1.1") >= Version("1.1a1")
|
||||
assert Version("2.0") in VersionSpecifier("==2")
|
||||
```
|
||||
|
||||
PEP 440 has a lot of unintuitive features, including:
|
||||
|
||||
* An epoch that you can prefix the version which, e.g. `1!1.2.3`. Lower epoch always means lower
|
||||
version (`1.0 <=2!0.1`)
|
||||
* post versions, which can be attached to both stable releases and prereleases
|
||||
* dev versions, which can be attached to sbpth table releases and prereleases. When attached to a
|
||||
prerelease the dev version is ordered just below the normal prerelease, however when attached
|
||||
to a stable version, the dev version is sorted before a prereleases
|
||||
* prerelease handling is a mess: "Pre-releases of any kind, including developmental releases,
|
||||
are implicitly excluded from all version specifiers, unless they are already present on the
|
||||
system, explicitly requested by the user, or if the only available version that satisfies
|
||||
the version specifier is a pre-release.". This means that we can't say whether a specifier
|
||||
matches without also looking at the environment
|
||||
* prelease vs. prerelease incl. dev is fuzzy
|
||||
* local versions on top of all the others, which are added with a + and have implicitly typed
|
||||
string and number segments
|
||||
* no semver-caret (`^`), but a pseudo-semver tilde (`~=`)
|
||||
* ordering contradicts matching: We have e.g. `1.0+local > 1.0` when sorting,
|
||||
but `==1.0` matches `1.0+local`. While the ordering of versions itself is a total order
|
||||
the version matching needs to catch all sorts of special cases
|
15
crates/pep440-rs/pyproject.toml
Normal file
15
crates/pep440-rs/pyproject.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[project]
|
||||
name = "pep440_rs"
|
||||
readme = "python/Readme.md"
|
||||
|
||||
[build-system]
|
||||
requires = ["maturin>=1.0.0,<2.0.0"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[tool.maturin]
|
||||
features = ["pyo3"]
|
||||
python-source = "python"
|
||||
module-name = "pep440_rs._pep440_rs"
|
||||
|
||||
[tool.ruff.per-file-ignores]
|
||||
"python/pep440_rs/__init__.py" = ["F403", "F405"]
|
42
crates/pep440-rs/python/Readme.md
Normal file
42
crates/pep440-rs/python/Readme.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# PEP440 in rust
|
||||
|
||||
A library for python version numbers and specifiers, implementing
|
||||
[PEP 440](https://peps.python.org/pep-0440)
|
||||
|
||||
```shell
|
||||
pip install pep440_rs
|
||||
```
|
||||
|
||||
```python
|
||||
from pep440_rs import Version, VersionSpecifier
|
||||
|
||||
assert Version("1.1a1").any_prerelease()
|
||||
assert Version("1.1.dev2").any_prerelease()
|
||||
assert not Version("1.1").any_prerelease()
|
||||
assert VersionSpecifier(">=1.0").contains(Version("1.1a1"))
|
||||
assert not VersionSpecifier(">=1.1").contains(Version("1.1a1"))
|
||||
assert Version("2.0") in VersionSpecifier("==2")
|
||||
```
|
||||
|
||||
Unlike [pypa/packaging](https://github.com/pypa/packaging), this library always matches preleases. To only match final releases, filter with `.any_prelease()` beforehand.
|
||||
|
||||
PEP 440 has a lot of unintuitive features, including:
|
||||
|
||||
* An epoch that you can prefix the version which, e.g. `1!1.2.3`. Lower epoch always means lower
|
||||
version (`1.0 <=2!0.1`)
|
||||
* post versions, which can be attached to both stable releases and prereleases
|
||||
* dev versions, which can be attached to sbpth table releases and prereleases. When attached to a
|
||||
prerelease the dev version is ordered just below the normal prerelease, however when attached
|
||||
to a stable version, the dev version is sorted before a prereleases
|
||||
* prerelease handling is a mess: "Pre-releases of any kind, including developmental releases,
|
||||
are implicitly excluded from all version specifiers, unless they are already present on the
|
||||
system, explicitly requested by the user, or if the only available version that satisfies
|
||||
the version specifier is a pre-release.". This means that we can't say whether a specifier
|
||||
matches without also looking at the environment
|
||||
* prelease vs. prerelease incl. dev is fuzzy
|
||||
* local versions on top of all the others, which are added with a + and have implicitly typed
|
||||
string and number segments
|
||||
* no semver-caret (`^`), but a pseudo-semver tilde (`~=`)
|
||||
* ordering contradicts matching: We have e.g. `1.0+local > 1.0` when sorting,
|
||||
but `==1.0` matches `1.0+local`. While the ordering of versions itself is a total order
|
||||
the version matching needs to catch all sorts of special cases
|
22
crates/pep440-rs/python/pep440_rs/__init__.py
Normal file
22
crates/pep440-rs/python/pep440_rs/__init__.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
A PEP440 reimplementation in rust
|
||||
|
||||
```python
|
||||
from pep440_rs import Version, VersionSpecifier
|
||||
|
||||
|
||||
assert Version("1.1a1").any_prerelease()
|
||||
assert Version("1.1.dev2").any_prerelease()
|
||||
assert not Version("1.1").any_prerelease()
|
||||
assert VersionSpecifier(">=1.0").contains(Version("1.1a1"))
|
||||
assert not VersionSpecifier(">=1.1").contains(Version("1.1a1"))
|
||||
assert Version("2.0") in VersionSpecifier("==2")
|
||||
```
|
||||
|
||||
"""
|
||||
|
||||
from ._pep440_rs import *
|
||||
|
||||
__doc__ = _pep440_rs.__doc__
|
||||
if hasattr(_pep440_rs, "__all__"):
|
||||
__all__ = _pep440_rs.__all__
|
40
crates/pep440-rs/python/pep440_rs/__init__.pyi
Normal file
40
crates/pep440-rs/python/pep440_rs/__init__.pyi
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Generated by `stubgen -p pep440_rs`
|
||||
from typing import Any, ClassVar
|
||||
|
||||
|
||||
class Version:
|
||||
dev: Any
|
||||
epoch: Any
|
||||
post: Any
|
||||
pre: Any
|
||||
release: Any
|
||||
major: Any
|
||||
minor: Any
|
||||
micro: Any
|
||||
|
||||
@classmethod
|
||||
def __init__(cls, *args, **kwargs) -> None: ...
|
||||
def any_prerelease(self, *args, **kwargs) -> Any: ...
|
||||
def parse_star(self, *args, **kwargs) -> Any: ...
|
||||
def __eq__(self, other) -> Any: ...
|
||||
def __ge__(self, other) -> Any: ...
|
||||
def __gt__(self, other) -> Any: ...
|
||||
def __hash__(self) -> Any: ...
|
||||
def __le__(self, other) -> Any: ...
|
||||
def __lt__(self, other) -> Any: ...
|
||||
def __ne__(self, other) -> Any: ...
|
||||
|
||||
|
||||
class VersionSpecifier:
|
||||
__hash__: ClassVar[None] = ...
|
||||
|
||||
@classmethod
|
||||
def __init__(cls, *args, **kwargs) -> None: ...
|
||||
def contains(self, *args, **kwargs) -> Any: ...
|
||||
def __contains__(self, other) -> Any: ...
|
||||
def __eq__(self, other) -> Any: ...
|
||||
def __ge__(self, other) -> Any: ...
|
||||
def __gt__(self, other) -> Any: ...
|
||||
def __le__(self, other) -> Any: ...
|
||||
def __lt__(self, other) -> Any: ...
|
||||
def __ne__(self, other) -> Any: ...
|
91
crates/pep440-rs/src/lib.rs
Normal file
91
crates/pep440-rs/src/lib.rs
Normal file
|
@ -0,0 +1,91 @@
|
|||
//! A library for python version numbers and specifiers, implementing
|
||||
//! [PEP 440](https://peps.python.org/pep-0440)
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::str::FromStr;
|
||||
//! use pep440_rs::{VersionSpecifiers, Version, VersionSpecifier};
|
||||
//!
|
||||
//! let version = Version::from_str("1.19").unwrap();
|
||||
//! let version_specifier = VersionSpecifier::from_str("== 1.*").unwrap();
|
||||
//! assert!(version_specifier.contains(&version));
|
||||
//! let version_specifiers = VersionSpecifiers::from_str(">=1.16, <2.0").unwrap();
|
||||
//! assert!(version_specifiers.iter().all(|specifier| specifier.contains(&version)));
|
||||
//! ```
|
||||
//!
|
||||
//! One thing that's a bit awkward about the API is that there's two kinds of
|
||||
//! [Version]: One that doesn't allow stars (i.e. a package version), and one that does
|
||||
//! (i.e. a version in a specifier), but they both use the same struct.
|
||||
//!
|
||||
//! The error handling and diagnostics is a bit overdone because this my parser-and-diagnostics
|
||||
//! learning project (which kinda failed because the byte based regex crate and char-based
|
||||
//! diagnostics don't mix well)
|
||||
//!
|
||||
//! PEP 440 has a lot of unintuitive features, including:
|
||||
//!
|
||||
//! * An epoch that you can prefix the version which, e.g. `1!1.2.3`. Lower epoch always means lower
|
||||
//! version (`1.0 <=2!0.1`)
|
||||
//! * post versions, which can be attached to both stable releases and prereleases
|
||||
//! * dev versions, which can be attached to sbpth table releases and prereleases. When attached to a
|
||||
//! prerelease the dev version is ordered just below the normal prerelease, however when attached
|
||||
//! to a stable version, the dev version is sorted before a prereleases
|
||||
//! * prerelease handling is a mess: "Pre-releases of any kind, including developmental releases,
|
||||
//! are implicitly excluded from all version specifiers, unless they are already present on the
|
||||
//! system, explicitly requested by the user, or if the only available version that satisfies
|
||||
//! the version specifier is a pre-release.". This means that we can't say whether a specifier
|
||||
//! matches without also looking at the environment
|
||||
//! * prelease vs. prerelease incl. dev is fuzzy
|
||||
//! * local versions on top of all the others, which are added with a + and have implicitly typed
|
||||
//! string and number segments
|
||||
//! * no semver-caret (`^`), but a pseudo-semver tilde (`~=`)
|
||||
//! * ordering contradicts matching: We have e.g. `1.0+local > 1.0` when sorting,
|
||||
//! but `==1.0` matches `1.0+local`. While the ordering of versions itself is a total order
|
||||
//! the version matching needs to catch all sorts of special cases
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[cfg(feature = "pyo3")]
|
||||
use pyo3::{pymodule, types::PyModule, PyResult, Python};
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
#[cfg(feature = "pyo3")]
|
||||
pub use version::PyVersion;
|
||||
pub use version::{LocalSegment, Operator, PreRelease, Version};
|
||||
pub use version_specifier::{parse_version_specifiers, VersionSpecifier, VersionSpecifiers};
|
||||
|
||||
mod version;
|
||||
mod version_specifier;
|
||||
|
||||
/// Error with span information (unicode width) inside the parsed line
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
pub struct Pep440Error {
|
||||
/// The actual error message
|
||||
pub message: String,
|
||||
/// The string that failed to parse
|
||||
pub line: String,
|
||||
/// First character for underlining (unicode width)
|
||||
pub start: usize,
|
||||
/// Number of characters to underline (unicode width)
|
||||
pub width: usize,
|
||||
}
|
||||
|
||||
impl Display for Pep440Error {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(f, "Failed to parse version:")?;
|
||||
writeln!(f, "{}", self.line)?;
|
||||
writeln!(f, "{}{}", " ".repeat(self.start), "^".repeat(self.width))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for Pep440Error {}
|
||||
|
||||
/// Python bindings shipped as `pep440_rs`
|
||||
#[cfg(feature = "pyo3")]
|
||||
#[pymodule]
|
||||
#[pyo3(name = "_pep440_rs")]
|
||||
pub fn python_module(_py: Python, module: &PyModule) -> PyResult<()> {
|
||||
module.add_class::<PyVersion>()?;
|
||||
module.add_class::<Operator>()?;
|
||||
module.add_class::<VersionSpecifier>()?;
|
||||
module.add_class::<VersionSpecifiers>()?;
|
||||
Ok(())
|
||||
}
|
1187
crates/pep440-rs/src/version.rs
Normal file
1187
crates/pep440-rs/src/version.rs
Normal file
File diff suppressed because it is too large
Load diff
1291
crates/pep440-rs/src/version_specifier.rs
Normal file
1291
crates/pep440-rs/src/version_specifier.rs
Normal file
File diff suppressed because it is too large
Load diff
48
crates/pep440-rs/test/test_python.py
Normal file
48
crates/pep440-rs/test/test_python.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
This is implementation has some very rudimentary python bindings
|
||||
"""
|
||||
from pep440_rs import Version, VersionSpecifier, Operator, VersionSpecifiers
|
||||
|
||||
|
||||
def test_pep440():
|
||||
assert Version("1.1a1").any_prerelease()
|
||||
assert Version("1.1.dev2").any_prerelease()
|
||||
assert not Version("1.1").any_prerelease()
|
||||
assert VersionSpecifier(">=1.0").contains(Version("1.1a1"))
|
||||
assert not VersionSpecifier(">=1.1").contains(Version("1.1a1"))
|
||||
assert Version("1.1") >= Version("1.1a1")
|
||||
assert Version("2.0") in VersionSpecifier("==2")
|
||||
assert Version("2.1").major == 2
|
||||
assert Version("2.1").minor == 1
|
||||
assert Version("2.1").micro == 0
|
||||
|
||||
|
||||
def test_version_specifier():
|
||||
assert VersionSpecifier(">=1.1").version == Version("1.1")
|
||||
assert VersionSpecifier(">=1.1").operator == Operator.GreaterThanEqual
|
||||
assert str(VersionSpecifier(">=1.1").operator) == ">="
|
||||
# Note: This removes the star
|
||||
assert VersionSpecifier("==1.1.*").version == Version("1.1")
|
||||
assert str(VersionSpecifier("==1.1.*").operator) == "=="
|
||||
assert {
|
||||
VersionSpecifier("==1.1.*"),
|
||||
VersionSpecifier("==1.1"),
|
||||
VersionSpecifier("==1.1"),
|
||||
} == {VersionSpecifier("==1.1.*"), VersionSpecifier("==1.1")}
|
||||
|
||||
|
||||
def test_version_specifiers():
|
||||
assert str(VersionSpecifiers(">=1.1, <2.0")) == ">=1.1, <2.0"
|
||||
assert list(VersionSpecifiers(">=1.1, <2.0")) == [
|
||||
VersionSpecifier(">=1.1"),
|
||||
VersionSpecifier("<2.0"),
|
||||
]
|
||||
|
||||
|
||||
def test_normalization():
|
||||
assert str(Version("1.19-alpha.1")) == "1.19a1"
|
||||
assert str(VersionSpecifier(" >=1.19-alpha.1 ")) == ">=1.19a1"
|
||||
assert repr(Version("1.19-alpha.1")) == '<Version("1.19a1")>'
|
||||
assert (
|
||||
repr(VersionSpecifier(" >=1.19-alpha.1 ")) == '<VersionSpecifier(">=1.19a1")>'
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue