Skip to main content

A library for python dependency specifiers, better known as PEP 508

Project description

Dependency specifiers (PEP 508) in Rust

Crates.io PyPI

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

pep508_rs-0.1.1.tar.gz (47.7 kB view details)

Uploaded Source

Built Distributions

pep508_rs-0.1.1-cp37-abi3-win_amd64.whl (741.5 kB view details)

Uploaded CPython 3.7+ Windows x86-64

pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ x86-64

pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_i686.whl (1.0 MB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ i686

pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_armv7l.whl (1.0 MB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARMv7l

pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_aarch64.whl (967.9 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

pep508_rs-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl (856.9 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.34+ x86-64

pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (997.7 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (985.4 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl (1.0 MB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64

pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (748.0 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (787.5 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

pep508_rs-0.1.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.6 MB view details)

Uploaded CPython 3.7+ macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

pep508_rs-0.1.1-cp37-abi3-macosx_10_7_x86_64.whl (818.0 kB view details)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

File details

Details for the file pep508_rs-0.1.1.tar.gz.

File metadata

  • Download URL: pep508_rs-0.1.1.tar.gz
  • Upload date:
  • Size: 47.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.16

File hashes

Hashes for pep508_rs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c9635282637c6e48bc4e8b0ea9a14ad7ce3f0b2de5c6effc902dabd54fb74dd3
MD5 8df8206f5ca95934cd116964fe894399
BLAKE2b-256 8cfb7f286cf19b9c7741610b3439a3bdb1ba3c864e762a061818fa1ce4ddbd69

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2458f2bffa823ba3fd2050720632f3e61b762db54bdfbb54a56864fb7df9b1b8
MD5 ce98c87d7360bd43103e0cfb032adf9e
BLAKE2b-256 e8105d0476c7d68125330f560a7c6e104a3ac223fbaac4d2213af3639495481d

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 62dc3c0bb841ca6a5ec6b9ae10dafc60b59ef834eb1335308f633c9b8a152eae
MD5 bca85499dea01360fe6119b8926c16d9
BLAKE2b-256 70defe7f3f5e1838fbf2c4c3a2dc92e04daf0a78c295b3c301eecf45809a0a00

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 0ea06a38f869d1899b53554ba5277a31728571cff6e309aec747214604565067
MD5 cdfc5e6d92eead12e78b9286e6954802
BLAKE2b-256 924d93ee068949117ce215027e92997715fa8b5448a1104ba8774a958d8f4ca5

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 30110fcbd3ec6d1d90ffa696b298902694e552d260750d08cd45b56705cb19a4
MD5 6114f9c34038a34909594b37ef7c97b2
BLAKE2b-256 c8cd47c6a8e2dcc17c4f7d56b02a55bf2dd5efd024ee518568bb4711c6b135dc

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d967ec17f2890cb1afccbf64bd61a49d35456bbfe10304ee70ee048f6fa92107
MD5 a5dbc0c992ef01ca447cc218a1b36de4
BLAKE2b-256 5b3c6b5155ccdb6fef9b6052393014876f0c17550e63b516a1246628cd44bdf7

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 552e847b574b0fe8cd7e81b8e4991eb130bd68a61e5ca544039127a151223dc6
MD5 a8be40d369598f31e1bfae007a7fbf4a
BLAKE2b-256 183451cca4360aa4ec8f5b04fba18029fcd1709c215593ebfbd5b1c72f313ccf

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 088f06b5a87e416e0b84597edc4f96048eeeeee94f02f24cc9681f0c9c8c4331
MD5 cfb0e1b4a92663028e28ebf935b64d7c
BLAKE2b-256 533cf1312c6f080c1b08b1c1d43d8a35c4972a66c452a9b08aaedcdbd757ed49

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 7856f2aae106156f6929d4af9fdb8e7705905bcb163c1a92a4962e0183362707
MD5 e0387c53d0cb123ba388fe3d49caf520
BLAKE2b-256 3e05f7608eb5b7105ef13a371f2ace78083f6469e94bee64a54bd506e8962816

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 a624fe4915115f8b7ce17a606f243521569df75c4c300e7e7f6b9675a54c2aeb
MD5 1581f65fbe93f60d5fa9918fb601713c
BLAKE2b-256 5348ddccd3a781977def3dcdff2dd446016d54196fb9f2f94ce201f957533108

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 60ca633b32cb07c9bcb221aa01c16fd12c5ac569ba0bf15ae6eed26d5a06d001
MD5 2db7254c017b6664877d4cb734553eab
BLAKE2b-256 970110c07ee61df98ac23dfd92ec242de0b30377060724270ecb220ac3fd5271

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3c8bf432408804971fea18b11325b8ef3e08c8ce900976fb3055807b1fd3d3ab
MD5 7155b65b883b0d307902487cb97ab474
BLAKE2b-256 2e9a924a4704acc3dcbb755e960537a1f57039628e22798922a2afb8936fdf89

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4b0cd4fee1ea8aaa09d0973877ce8872e5f982995ab5a2114c8d2c398386e659
MD5 175bd23ae174586b3681a55c4391999d
BLAKE2b-256 21182c231db271dcf5484fa05b33319a71fc28a6be62c4205cbd4e4da998ede7

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.1-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for pep508_rs-0.1.1-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b9296045a0463e50ff87b8f2ed5e16b05279d57578d0a82bc902d6b028bb5616
MD5 fe681851aca4759d18af52262225ecd2
BLAKE2b-256 94e45baa624bf355a4c0e95d20185d87b43995eb946114077307f44185786a51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page