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.PoetryPyprojectFile.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
File details
Details for the file compreq-0.3.1.tar.gz
.
File metadata
- Download URL: compreq-0.3.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7379226ac13afa5d251dddda70f7e25421414d72d4e43f4dc7b2261d54c1c06 |
|
MD5 | 2c8b1f9425431f33ecefa62d0cd67986 |
|
BLAKE2b-256 | f173573ecdf2b1759a497171b4c21e1a72aa9ab77fd64f11e1f3836217eb09dc |
File details
Details for the file compreq-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: compreq-0.3.1-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad0623b6f9f48777d6bdd8c666488177022725bf594dad6f1ae028e521ae0a42 |
|
MD5 | 61c355b1486e31cf826887f647f3b243 |
|
BLAKE2b-256 | ccd53f0dbc02f497157b7c797ddbf52e123acd83b356e6efc19c2914d06176b9 |