A library for dynamically computing Python requirements, to keep them up-to-date.
Project description
compreq
A library for dynamically computing Python requirements, to keep them up-to-date.
Concepts
This library relies heavily on packaging, and you should understand that first.
The base types are the Version, Specifier, SpecifierSet and Requirement in packaging and
Release and ReleaseSet added by this library.
For all of the base types this library adds lazy versions - which both allows reuse, but also allows some values to be fetched from the context, instead of specified explicitly.
To resolve a lazy object into a concrete value use a CompReq.resolve_... method.
Finally this library adds wrappers around pyproject.toml and requirements.txt files, for getting
and setting the requirments in them.
Example:
import compreq as cr
with cr.PyprojectFile.open() as pyproject:
prev_python_specifier = cr.get_bounds(
pyproject.get_requirements()["python"].specifier
).lower_specifier_set()
comp_req = cr.CompReq(python_specifier=prev_python_specifier)
default_range = cr.version(
">=",
cr.floor_ver(
cr.REL_MINOR,
cr.minimum_ver(
cr.max_ver(cr.min_age(years=1)),
cr.min_ver(cr.count(cr.MINOR, 3)),
),
),
) & cr.version("<", cr.ceil_ver(cr.REL_MAJOR, cr.max_ver()))
dev_range = cr.version(">=", cr.floor_ver(cr.REL_MINOR, cr.max_ver())) & cr.version(
"<", cr.ceil_ver(cr.REL_MINOR, cr.max_ver())
)
pyproject.set_requirements(
comp_req,
[
cr.pkg("beautifulsoup4") & default_range,
cr.pkg("packaging") & default_range,
cr.pkg("pip") & default_range,
cr.pkg("python") & default_range,
cr.pkg("python-dateutil") & default_range,
cr.pkg("requests") & default_range,
cr.pkg("tomlkit") & default_range,
cr.pkg("typing-extensions") & default_range,
],
)
pyproject.set_requirements(
comp_req,
[
cr.pkg("black") & dev_range,
cr.pkg("isort") & dev_range,
cr.pkg("mypy") & dev_range,
cr.pkg("pylint") & dev_range,
cr.pkg("pytest") & dev_range,
cr.pkg("taskipy") & dev_range,
cr.pkg("types-beautifulsoup4") & default_range,
cr.pkg("types-python-dateutil") & default_range,
cr.pkg("types-requests") & default_range,
],
"dev",
)
Or see requirements.py.
References:
https://peps.python.org/pep-0440/ https://packaging.pypa.io/en/stable
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file compreq-0.4.0.tar.gz.
File metadata
- Download URL: compreq-0.4.0.tar.gz
- Upload date:
- Size: 69.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be3f12f3719e4c001724df8492790614ef84f86b5e3b8f5991a2ec8965d5f3f6
|
|
| MD5 |
3db8ed04f7a335bf2a8ce67b59c78130
|
|
| BLAKE2b-256 |
a7b2892047dd37caa81137f240ec07d340190eb0072a47f1339cf191dc18055b
|
Provenance
The following attestation bundles were made for compreq-0.4.0.tar.gz:
Publisher:
test_release.yml on jesnie/compreq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compreq-0.4.0.tar.gz -
Subject digest:
be3f12f3719e4c001724df8492790614ef84f86b5e3b8f5991a2ec8965d5f3f6 - Sigstore transparency entry: 312103197
- Sigstore integration time:
-
Permalink:
jesnie/compreq@1b7f049b4bfe59cc8afef1d90afa967e1eb30bf0 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jesnie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_release.yml@1b7f049b4bfe59cc8afef1d90afa967e1eb30bf0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file compreq-0.4.0-py3-none-any.whl.
File metadata
- Download URL: compreq-0.4.0-py3-none-any.whl
- Upload date:
- Size: 33.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64940840bebc20ff770177874b3adec1bdd28585e6f26b9b4194c9f292f3b604
|
|
| MD5 |
63d3a3a060cc980b38ad9bce3f77f842
|
|
| BLAKE2b-256 |
12edf6d7871ca1ec16948c8acad5f33df0a2c59dd43df10f69a506590ae2d501
|
Provenance
The following attestation bundles were made for compreq-0.4.0-py3-none-any.whl:
Publisher:
test_release.yml on jesnie/compreq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
compreq-0.4.0-py3-none-any.whl -
Subject digest:
64940840bebc20ff770177874b3adec1bdd28585e6f26b9b4194c9f292f3b604 - Sigstore transparency entry: 312103212
- Sigstore integration time:
-
Permalink:
jesnie/compreq@1b7f049b4bfe59cc8afef1d90afa967e1eb30bf0 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jesnie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_release.yml@1b7f049b4bfe59cc8afef1d90afa967e1eb30bf0 -
Trigger Event:
release
-
Statement type: