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

Uploaded Source

Built Distribution

highlighter-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: highlighter-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for highlighter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3e3afda13c9c34800141173fb242012c8f38fd06390de5294cb358c4f6d53838
MD5 da7d710d0b6e523002daf2710c20ea3a
BLAKE2b-256 ca8f47273c515f1db516fa48b705869d67950c13806d966d80b3401af1779829

See more details on using hashes here.

File details

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

File metadata

  • Download URL: highlighter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for highlighter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef3a4eb634851533e0e4006dd0981dc518db6bae0d616ce664223edf9d571c24
MD5 de7e38a580b6f27374961ec29cb076c5
BLAKE2b-256 6b77888ff6107191526d650852631c7872020c05890a057b5446bbb514e69759

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