Simple version management in Python
Project description
sversion
Simple version retrieval for Python projects. Walks up the directory tree from a given path and reads the version from a pyproject.toml or a plain VERSION.txt file.
Requirements
Python 3.14+
Installation
pip install sversion
Usage
From pyproject.toml
Reads project.version (PEP 621) or tool.poetry.version:
from sversion.pyproject_toml_based import get_version
version = get_version(__file__)
print(version) # e.g. "1.2.3"
Pass a custom filename to look for a differently named TOML file:
version = get_version(__file__, project_file_name="my_project.toml")
From a version file
Reads the first non-whitespace content of a VERSION.txt file:
from sversion.version_file_based import get_version
version = get_version(__file__)
print(version) # e.g. "1.2.3"
Pass a custom filename:
version = get_version(__file__, version_file_name="RELEASE")
How the search works
Both functions accept either a file path or a directory path as start_search_path. Starting from that location they walk up the directory tree, checking each level for the target file, and return the version from the first match found.
API
# pyproject_toml_based
get_version(start_search_path: str, project_file_name: str = "pyproject.toml") -> str
# version_file_based
get_version(start_search_path: str, version_file_name: str = "VERSION.txt") -> str
Both raise VersionNotFoundException (from sversion.error_handling) when no matching file is found before reaching the filesystem root.
License
MIT
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 sversion-2.4.0.tar.gz.
File metadata
- Download URL: sversion-2.4.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e543005bfd21559dac0ae4ef2a9ab3364d4ca894416cc660275495a42098b32c
|
|
| MD5 |
210e7354fd631d2c5ad5fe74f14c029f
|
|
| BLAKE2b-256 |
a904e83864c09a354d6c7373ffe7e82fdd719c8ccb28aed79d8f4b995b909660
|
File details
Details for the file sversion-2.4.0-py3-none-any.whl.
File metadata
- Download URL: sversion-2.4.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f479fcdfbfcb9817ea4870fa6fd6c28bb064464dc82d5f2412c19c5947c7bc0
|
|
| MD5 |
27111f34149d2df9f75555149c78bdae
|
|
| BLAKE2b-256 |
68268362dfcdc48084dedd91cd3fcfa83948924257347b39b3526688de8d1276
|