Skip to main content

Easy-to-use PEP 508 markers

Project description

highlighter

Easy to use PEP 508 markers. These are the strings in requirements after a semicolon, such as enum34; python_version < '3.5' means the package enum34 but only on some versions of python.

from packaging.markers import Marker
from packaging.requirements import Requirement

from highlighter import EnvironmentMarkers

req = Requirement("enum34; python_version < '3.5'")

env = EnvironmentMarkers.for_python("3.7.5", "win32")
env.match(req.marker)  # False

# Lower-level interface, you can use Marker directly
m = Marker("python_version < '3.5'")
env.match(m)  # False

# What about extras?
req = Requirement("somepackage[foo,bar]")
m = Marker("extra == 'foo'")
env.match(m, extras=req.extras) # True

Egg-info Extras

This also includes a function that can convert a requires.txt (as found in egg-info dirs, the only kind we have in sdists) into an equivalent list of requirements.txt lines using PEP 508 markers.

from highlighter.sdist import convert_sdist_requires

convert_sdist_requires("""\
[socks]
PySocks!=1.5.7,>=1.5.6

[socks:sys_platform == "win32" and python_version == "2.7"]
win_inet_pton
""") == """\
PySocks!=1.5.7,>=1.5.6; extra == 'socks'
win_inet_pton; (sys_platform == "win32" and python_version == "2.7") and extra == 'socks'
"""

License

highlighter is copyright Tim Hatch, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

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

highlighter-0.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

highlighter-0.2.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file highlighter-0.2.0.tar.gz.

File metadata

  • Download URL: highlighter-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for highlighter-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8c32c8636e4e862d9415f665b4cba108418a5649485183f61da2de96d5d9734b
MD5 9bc8a443580f955f0570b68425918233
BLAKE2b-256 d5fcd5d1e8b1fb9468efab7ca0f1955376448ca135d6c0b78259288f751ab1a0

See more details on using hashes here.

Provenance

File details

Details for the file highlighter-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: highlighter-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for highlighter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08206ab8c0e0b6c8f77e9184df743bc7189a22e7ea062cc084d5f05a139d6a7f
MD5 13d4d9596136454c3223873b7f5d3c10
BLAKE2b-256 b14898b0951b8250bf82c73859299fddf2f94c4f0faced1eef583caea64a16c2

See more details on using hashes here.

Provenance

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