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.5.tar.gz (35.7 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.7+ Windows x86-64

pep508_rs-0.1.5-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.5-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.5-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.5-cp37-abi3-musllinux_1_2_aarch64.whl (966.8 kB view details)

Uploaded CPython 3.7+ musllinux: musl 1.2+ ARM64

pep508_rs-0.1.5-cp37-abi3-manylinux_2_34_x86_64.whl (855.9 kB view details)

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

pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (992.7 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ s390x

pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (991.9 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ppc64le

pep508_rs-0.1.5-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.5-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (746.7 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARMv7l

pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (785.8 kB view details)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ ARM64

pep508_rs-0.1.5-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.5-cp37-abi3-macosx_10_7_x86_64.whl (816.9 kB view details)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pep508_rs-0.1.5.tar.gz
Algorithm Hash digest
SHA256 a3b3e3867c43910db92a431ad4499526ddc95dc7817b5359fc0c5b37cfe72fcf
MD5 00481f43b34724a9e47c0a145b01552e
BLAKE2b-256 5c1cf859e7d6443c5610f831177df2aff2936018364d319a40fddf77838de5b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7505ce08c4b2add3559f04cbe6e02b51f307bbfedf8a29a88d4d7f1af9dcea51
MD5 fd3cf1ada4aaa1a823bc2a6d1bd68547
BLAKE2b-256 82cfd877438d8768210950679a18e2ef274cef1478588fe5a546493098fb6997

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0491d84e7a510901216eb23b7449a50a5f41f5917e90110dd36820b210cde2e8
MD5 3aff5614b57d141f3107c2145b4dd7af
BLAKE2b-256 e024c8f83f2efffb6051470d57d2a2dfe37894eded9d134fc629e2503bd1a5e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 546011eb4d9819aa9f360947567059492fa35982983581fd095943d3db4ac61c
MD5 244efde21a831fcaeef5878a79a88b78
BLAKE2b-256 25d7509dadbc732e1ed124e7cc2d5e0b7fa73ba68b424c9817ebad36ed8ae820

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 ac14a7b046bbf6a38130cba2505c4733939d0d380c0b0afb6b8d6042d62a42c2
MD5 687281c524b74ab657e6ee5a657c661c
BLAKE2b-256 505bbef0877e544065780bb7192ce66fbee5fc1a1c155883b2bb598e5a960254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 cd764e17b5a8804000015a62dbb10d937aea97dfd612cfd4df0760a81003541b
MD5 3d8f892591a20d4aa33449090891b2bb
BLAKE2b-256 2d400f51084f205faf14b7a75019ffa0e4254e7a55a99f6fa492abddd3f61122

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2e885d41075cbf62fe23315ff51b56889f22f44f06d0fcd521bcce5a9b0f21fa
MD5 597159217e171adc00250a5cbdbc605b
BLAKE2b-256 bc41ee062b3295e957441dcc45b38e18d558edacc4329cc30c8ca5f7d6cb383c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 d8d5cf3e50fd91504c70581b8669c1c7d830311a133e14f190f0ef95774420f8
MD5 20a2f827948e3872f9009f35bef66e67
BLAKE2b-256 059cda0ca695cd82faaab89fcf42ebae3f645bec7a3876a3c0cefc6c2ad19486

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 e3cba1d18e5bb97982a636b3524c47a67b9fba3196ab19552319517b91a4746c
MD5 b93a0f44e91427912029f176235491b6
BLAKE2b-256 d67e421c4c2f0b347ddb1d7cac02f419a8f2c75a9a80e7bc4a73a86ac79b216d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm Hash digest
SHA256 173a9cbf2893e65f89aeda0f5d894bf0f246a01a544ef9e3e051bd257c362282
MD5 1c8d4c98a342972ae862f722c44f81bc
BLAKE2b-256 cc6ea6c25369347ceca90cee559603c64e3229925a8051f594175226bbd16a12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 43f6b747dbb262c1524d77b55cb181b731d7449b561f8b0e8ae41916d56e04ff
MD5 d2ec05c7d5d76af3a280685b79ac0604
BLAKE2b-256 43cfc1b5922b307a6be95fd5b56f2b5943a7ba417301027097acd7942b712ae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2d55c962f021468fb23d565b31fa92d77db38c25e486eb3775bc5dc64c9da54b
MD5 b84384ab3be5812727402139917c508c
BLAKE2b-256 c13af177ef01aa306ed3919d2a0e3e71af0405e85b1a5998c887e7271cf9aed7

See more details on using hashes here.

File details

Details for the file pep508_rs-0.1.5-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.5-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 323e424683b258851f2fb28c592a0fde9a53b9ee4d1615f2f73f3f1d28ae0603
MD5 03a37b205c2d81e7d41e9f74fca35646
BLAKE2b-256 e0e460e9c72f87b44d60c691e68d26d74939c9f88ba753c67e671ec933de30d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pep508_rs-0.1.5-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 170f8675e449e34e7cbd28f64950e02bd7782832da2afcde92d75ee7d111c0ad
MD5 5c0a539f014a03118ea2919a520bc4b9
BLAKE2b-256 e01f64291dbfcc9284300840e1064ef26a45a1f4c18f4d9e89ef35fb1991f4e3

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