A library for python dependency specifiers, better known as PEP 508
Project description
Dependency specifiers (PEP 508) in Rust
A library for python dependency specifiers, better known as PEP 508.
Usage
In Rust
use std::str::FromStr;
use pep508_rs::Requirement;
let marker = r#"requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8""#;
let dependency_specification = Requirement::from_str(marker).unwrap();
assert_eq!(dependency_specification.name, "requests");
assert_eq!(dependency_specification.extras, Some(vec!["security".to_string(), "tests".to_string()]));
In Python
from pep508_rs import Requirement
requests = Requirement(
'requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8"'
)
assert requests.name == "requests"
assert requests.extras == ["security", "tests"]
assert [str(i) for i in requests.version_or_url] == [">= 2.8.1", "== 2.8.*"]
Python bindings are built with maturin, but you can also use the normal pip install .
Version
and VersionSpecifier
from pep440_rs are reexported to avoid type mismatches.
Markers
Markers allow you to install dependencies only in specific environments (python version, operating system, architecture, etc.) or when a specific feature is activated. E.g. you can say importlib-metadata ; python_version < "3.8"
or itsdangerous (>=1.1.0) ; extra == 'security'
. Unfortunately, the marker grammar has some oversights (e.g. https://github.com/pypa/packaging.python.org/pull/1181) and the design of comparisons (PEP 440 comparisons with lexicographic fallback) leads to confusing outcomes. This implementation tries to carefully validate everything and emit warnings whenever bogus comparisons with unintended semantics are made.
In python, warnings are by default sent to the normal python logging infrastructure:
from pep508_rs import Requirement, MarkerEnvironment
env = MarkerEnvironment.current()
assert not Requirement("numpy; extra == 'science'").evaluate_markers(env, [])
assert Requirement("numpy; extra == 'science'").evaluate_markers(env, ["science"])
assert not Requirement(
"numpy; extra == 'science' and extra == 'arrays'"
).evaluate_markers(env, ["science"])
assert Requirement(
"numpy; extra == 'science' or extra == 'arrays'"
).evaluate_markers(env, ["science"])
from pep508_rs import Requirement, MarkerEnvironment
env = MarkerEnvironment.current()
Requirement("numpy; python_version >= '3.9.'").evaluate_markers(env, [])
# This will log:
# "Expected PEP 440 version to compare with python_version, found '3.9.', "
# "evaluating to false: Version `3.9.` doesn't match PEP 440 rules"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pep508_rs-0.2.0.tar.gz
.
File metadata
- Download URL: pep508_rs-0.2.0.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4982c2031343c7e430ae088201753256459662e08a2b17feddf66d528e31eb06 |
|
MD5 | b005ebadd5cac422ce7e795073355de5 |
|
BLAKE2b-256 | 1d2e1eadd0590412dcca3ba6b33653f8d8bbf742de38a9fa22e5aa61d3dce959 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 799.9 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf472dac5a6a6b674c82923f9c7e736f7116d2eb7c4d3865ef9761d37ff8c5fd |
|
MD5 | 1e19c3230c44cd2ffba107bbd6d0a583 |
|
BLAKE2b-256 | 2ecbb9a92bd1d8a3b2ad76c5b743cc0d887ddbbac8cb1e64b2c9920934154868 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_x86_64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 469276c8d53b1f3620e88d7062b83ee575c3ddcf22900144d73b5f0cb8b50e0f |
|
MD5 | fe5d09d41a08ff353736d8df66b46240 |
|
BLAKE2b-256 | 0cf6ce7c899374c3e68d9f9df612f55f68fe30504e2c21a75bbc01bd5147a7ee |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_i686.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48a4e54425b6a978ddc08505695c092b26229089dac53f78a2297b9d22cc1d23 |
|
MD5 | 46c4c6e8c211421fc4d63962110e8522 |
|
BLAKE2b-256 | d2a8613e41397b3e916bf6ab9759ce04c5f2b38d3b604f99ee2f311a4d48db57 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_armv7l.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80fee93431aee72c50754b9ce06fcbbe2753c6fc3ec3d6091a08137e7baaa1ec |
|
MD5 | 08abd89c3af16bda3773d71ce4e92b4e |
|
BLAKE2b-256 | 35930f1297984abc5a72de2d103dd7f27e52c332029512569e9b66ab627ae187 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_aarch64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 009c658033a6c04711e61818e81d7e0725157bd3211a1512365a4a1a841ca002 |
|
MD5 | b2bde608d2e128656f264f3d05a09d96 |
|
BLAKE2b-256 | fa1d2dc6680e1a2a4ed5ab67682695813f76acd688c77db2be61f401a4588724 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 914.3 kB
- Tags: CPython 3.7+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8358a470e5da176f2cb04f4142035881b447b6bbb9557b415686d61ac0dad65f |
|
MD5 | 44f7408ce62b0694b6bb78d74b22d0ce |
|
BLAKE2b-256 | f00ef3c8b0deff2bf741960956874ad5283fece05a3ba9788e50d18447bb660b |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38daa342b604771f42039147b15dd926614f5e4138a75da7f32faa6a685a45b1 |
|
MD5 | b0102d0deae03bcf8a431c4946256e24 |
|
BLAKE2b-256 | 08cadcf8fa99b067c7885a3eeb41f9f46f19acffb5a8ac93cd53c2d0ea72ef73 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e508e1f0eb18d8e95b56ea00f271a3775896d4cd4764ee3a8ddd6e6972a713a |
|
MD5 | 82ae38a77a507cde8faeb3df9c087059 |
|
BLAKE2b-256 | 0ea40bce7a06ec882f1a18577b2ff832bf828159dfc1061a53f8ef369e53600e |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e59adb7f443dc587ac8baba37c0b9a89966cc468ffc308802b7ac56faceb9ced |
|
MD5 | 5fdf80234dad0ae322dae302156e014d |
|
BLAKE2b-256 | 07f149a9083662131eba8295c77df00cb9b5fb9f332ebc3ed7bdeb019febf8d6 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 800.8 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a04c289e155bb130b107bd9238ea5fdfbf63c7d208058928cfeced3efd536a3d |
|
MD5 | c6a4604aa1385e021a899809253d109b |
|
BLAKE2b-256 | 2664185cc77bb43cba89ff46f836c52b740be5a572dc7b8584138010ad9280f1 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 844.0 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72709640764e46dda1cd7f8775174b33d1ae5c0fba3e3c516b42afd216e35e0d |
|
MD5 | cac757bedbb598235677fd4fd8ffcaac |
|
BLAKE2b-256 | cdeeb17796a8bb55a6c2ed55e984945f328ffbf271de4dbdcf0522e9bdbf0edb |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.7+, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53da46d625adcb560d53ca5cd94ea7d41415ea67626de347be7137e047a44aad |
|
MD5 | 98f36aabbaab34fdf318c52f409ab383 |
|
BLAKE2b-256 | 42e8cdac282e7788ea28d094b4628249a008cc60222b27b15e9de1a85d9a1a70 |
File details
Details for the file pep508_rs-0.2.0-cp37-abi3-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: pep508_rs-0.2.0-cp37-abi3-macosx_10_7_x86_64.whl
- Upload date:
- Size: 872.0 kB
- Tags: CPython 3.7+, macOS 10.7+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/0.15.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4904210e3b8b2965e74d18bff8ad563bd2baa85ddfa2323dfa601f1db9157a43 |
|
MD5 | 5d470dc6a733980eeac44bf2567c7f5a |
|
BLAKE2b-256 | 68a3e15145c42baec8f630ee8878109ce876a32d47d7fcb2968513600ef50e33 |