read-version
Extract your project's __version__ variable
What it is and what it does
read_version is a small utility that parses Python source files to extract the value of a variable (typically __version__) for use during package setup. It was designed to eliminate the repetitive boilerplate code that developers write in setup.py to read version strings from their package's __init__.py or other source files.
The package offers two approaches: a functional API (import and call read_version() in setup.py) and a declarative approach (configure metadata extraction via pyproject.toml). However, the package is abandoned and explicitly marked obsolete—setuptools has supported the attr: directive natively since version 46.4.0, which provides the same functionality without an external dependency. New projects should use setuptools' built-in mechanism instead.
Use it for:
- Migrating older projects that use read_version to avoid rewriting setup.py when upgrading setuptools.
- Extracting multiple metadata fields (author, license, keywords) from source variables via pyproject.toml configuration.
- Reading version from non-standard variable names or file locations using the variable and path parameters.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts a version string or other variable from Python source code for use in setup.py, eliminating boilerplate version-parsing code during package builds.
No. The package is abandoned (last release July 2021, repository archived) and explicitly superseded by setuptools' native attr: directive. New projects should use setuptools 46.4.0+ instead. Only consider read_version if maintaining legacy code that already depends on it and you cannot upgrade setuptools.
Install
read-version on PyPI
pip
pip install read-versionuv
uv add read-versionpoetry
poetry add read-versionInstalling read-version
Before you install
Installation is straightforward with low friction—a pure Python wheel with only setuptools as a runtime dependency. However, the package is abandoned as of 2021 and explicitly superseded by setuptools' native attr: directive (available since setuptools 46.4.0), making it obsolete for new projects.
License in practice
Licensed under MIT (permissive), so there are no licensing restrictions on use or redistribution.
Quickstart
# In setup.py:
from read_version import read_version
setup(
version=read_version('packagename', '__init__.py'),
...
)
# Or declaratively in pyproject.toml:
# [tool.read_version]
# version = "packagename:__version__"
Requires Python 3.6 or higher. The declarative approach also requires setuptools 42.0.0 or later. The package is no longer maintained; modern projects should use setuptools' native attr: directive instead.
Verify before relying
- Whether the package's static analysis correctly handles all edge cases in real-world __version__ assignments (e.g., complex expressions, conditional assignments).
- Performance characteristics when parsing large or complex source files.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (~=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — setuptools |
| Maintenance | abandoned — 1,846 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 185,030/month — #10,019 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: read_version-0.3.2-py3-none-any.whl
Keywords: packaging, setuptools, version
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
setuptools-scmAutomatically extracts and manages Python…
permissive · top 1,000 on PyPI
single-sourceExtracts your package version from…
permissive · top 15,000 on PyPI
versioningitAutomatically determines your Python package's…
permissive · top 5,000 on PyPI
setuptools-git-versioningAutomatically generates PEP 440-compliant…
permissive · top 5,000 on PyPI
pypi-simpleA client library for querying PyPI and…
permissive · top 15,000 on PyPI
nameofRetrieves the name of a variable or attribute…
permissive · top 15,000 on PyPI
versioneer-518Automates version management in…
permissive · top 15,000 on PyPI
versioneerVersioneer automates version management in…
permissive · top 5,000 on PyPI
hatch-nodejs-versionProvides Hatch plugins to read and write Python…
permissive · top 15,000 on PyPI
varnameRetrieves variable names at runtime from inside…
permissive · top 15,000 on PyPI