2 @package libtextworker.versioning
3 @brief Utilities for version control management.
12 import packaging.version
17 Projects called by functions under libtextworker.versioning.
24 Try to import a project then parse its version with the ```packaging.version``` module.
25 Parsed projects are stored in Requested (list).
26 @see is_development_version
27 @see is_development_from_project
34 module = importlib.import_module(project)
36 if project
not in Requested:
37 if not module.__version__:
39 "%(project)s does not have __version__ attribute!"
41 Requested[project] = packaging.version.parse(module.__version__)
43 return Requested[project]
48 Parse and check if the specified version is a prerelease.
49 @see is_development_version_from_project
51 return packaging.version.parse(version).is_prerelease
56 Like is_development_version(), but read the project's current version instead.
57 @see is_development_version
62 def require(project: str, target_version: str):
64 Ensures the correct versions of a project are available.
65 @param project (str): Target project name
66 @param target_version (str): Target project version
69 target = packaging.version.parse(target_version)
73 "Project %(project)s must be version >=%(target_version)s"
79 Ensures the correct version of a project IS available.
80 @param project (str): Target project name
81 @param target_version (str): Target project version
84 target = packaging.version.parse(target_version)
88 "Project %(project)s not available for version %(target_version)"
94 Ensures the project version is LOWER than the requested one.
95 @param project (str): Target project name
96 @param target_version (str): Target project version
99 target = packaging.version.parse(target_version)
101 if currver >= target:
103 "Project %(project)s not available for version %(target_version)"
packaging.version.Version parse_version(str project)
def is_development_version(str version)
def is_development_version_from_project(str project)
def require_exact(str project, str target_version)
def require(str project, str target_version)
def require_lower(str project, str target_version)