univers was born out of the need for a mostly universal way to store version ranges and to compare two software package versions in VulnerableCode.
Package version ranges and version constraints are useful and essential:
Version syntaxes and range notations are quite different across ecosystems, making it is difficult to process versions and version ranges across ecosystems in a consistent way.
Existing tools and libraries typically support a single algorithms to parse and compare versions with a single version range notation for a single package ecosystem.
univers is different:
univers wraps, embeds and implements multiple version comparison libraries, each focused on a specific ecosystem versioning scheme.
For each scheme, univers provides an implementation for:
vers
syntax.univers implements vers
, an experimental unified and mostly universal version range syntax. It can parse and convert an existing native version range strings to this unified syntax. For example, this means:
vers:pypi/>=1.2.3
,vers:npm/>=1.0.2|<2.0.0
The supported package ecosystems versioning schemes and underlying libraries include:
packaging.version
module.The level of support for each ecosystem may not be even for now and new schemes and support for more package types are implemented on a continuous basis.
Rather than using ecosystem-specific version schemes and code, another approach is to use a single procedure for all the versions as implemented in libversion. libversion
works in the most common case but may not work correctly when a task that demand precise version comparisons such as for dependency resolution and vulnerability lookup where a "good enough" comparison accuracy is not acceptable. libversion
does not handle version range notations.
$ pip install univers
Compare two native Python versions:
from univers.versions import PypiVersion assert PypiVersion("1.2.3") < PypiVersion("1.2.4")
Normalize a version range from an npm:
from univers.version_range import NpmVersionRange range = NpmVersionRange.from_native("^1.0.2") assert str(range) == "vers:npm/>=1.0.2|<2.0.0"
Test if a version is within or outside a version range:
from univers.versions import PypiVersion from univers.version_range import VersionRange range = VersionRange.from_string("vers:pypi/>=1.2.4") assert PypiVersion("1.2.4") in range assert PypiVersion("1.2.3") not in range
Run these commands, starting from a git clone of https://github.com/aboutcode-org/univers
$ ./configure --dev $ source venv/bin/active $ pytest -vvs
We use the same development process as other AboutCode projects.
Visit https://github.com/aboutcode-org/univers and https://gitter.im/aboutcode-org/vulnerablecode and https://gitter.im/aboutcode-org/aboutcode for support and chat.
Primary license: Apache-2.0 SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause AND MIT
Acknowledgements, Funding, Support and SponsoringThis project is funded, supported and sponsored by:
This project was funded through the NGI0 PET Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825310.
https://nlnet.nl/project/VulnerableCode/
This project was funded through the NGI0 Discovery Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825322.
https://nlnet.nl/project/vulnerabilitydatabase/
This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.
https://nlnet.nl/project/VulnerableCode-enhancements/
This project is funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594.
https://nlnet.nl/project/FederatedSoftwareMetadata/
This project was funded through the NGI0 Commons Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101135429. Additional funding is made available by the Swiss State Secretariat for Education, Research and Innovation (SERI).
https://nlnet.nl/project/FederatedCodeNext/
This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594.
https://nlnet.nl/project/CRAVEX/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4