Registry / devops / vcver
library0.2.12pypypi✓ verified 22d ago

vcver is a Python library that automates the generation of package version strings by extracting information directly from version control systems such as Git or Mercurial. This enables dynamic versioning based on commit hashes, tags, and branch names, particularly useful for development builds. It seamlessly integrates with `setuptools` and is actively maintained with releases occurring roughly annually. The current version is 0.2.12.

pip install vcver
INSTALL
IMPORT
SIG · VCVER
V
vcver
devopspythonv0.2.12
Install
1.7s avg
Import
52ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.052s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.052s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_version
import vcver version = vcver.get_version()
from vcver import get_version # Avoid direct import if using in setup.py
When used in `setup.py` for `setuptools.setup(version=...)`, direct import like `from vcver import get_version` can cause issues if vcver itself depends on the package's version being defined during import. The standard recommendation is `version=vcver.get_version()` after `import vcver`.

Demonstrates how to integrate vcver into a `setup.py` for dynamic versioning using `setuptools.setup()`, and how to retrieve the version string directly within Python code.

import vcver # Example usage in setup.py for setuptools: # from setuptools import setup # setup( # name='your_package', # version=vcver.get_version(), # # ... other setup arguments # ) # Or to get the version directly: current_version = vcver.get_version() print(f"Current package version: {current_version}")
vcver --version
Debug
Known issues
gotchavcver relies on Git or Mercurial being installed and accessible in the system's PATH. If the repository is not a valid Git/Mercurial repository or the VCS tools are not found, `vcver.get_version()` will fall back to a default (e.g., '0.0.0') or raise an error depending on configuration.
fix
Ensure `git` or `hg` executables are installed and available in the system's PATH, and that your project directory is a valid VCS repository.
affects: All versions
gotchaWhen running in environments where `.git` or `.hg` directories are not present (e.g., installed packages from PyPI, CI/CD environments that don't clone full history), `vcver.get_version()` might not produce the expected dynamic version. For release builds, consider using `vcver.set_version()` to explicitly embed a fixed version.
fix
For production releases, use `vcver.set_version('X.Y.Z')` as part of your build process to hardcode the version, or ensure your build system retains the `.git` or `.hg` directory.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'vcver'
The 'vcver' package is not installed in the Python environment where the script or 'setup.py' is being executed.
fix
Install the package using pip: `pip install vcver`
FileNotFoundError: [Errno 2] No such file or directory: 'git'
The Git command-line tool is not installed on the system or is not accessible in the system's PATH environment variable, which 'vcver' relies on to extract version information.
fix
Install Git on your system and ensure it's added to your system's PATH. For Linux/macOS, use `sudo apt-get install git` or `brew install git`; for Windows, download from git-scm.com.
Command 'git' returned non-zero exit status 128
An underlying Git command failed, often due to repository issues like a detached HEAD state, a shallow clone, or a corrupted repository.
fix
Ensure the Git repository is valid, not a shallow clone if full history is required by 'vcver', and the Git environment is correctly set up. Use `git fetch --unshallow` if applicable.
vcver.NoVcsError: Could not find a VCS root.
'vcver' was executed in a directory that is not part of a Git or Mercurial repository, or it could not detect the repository due to issues like shallow cloning or specific environment setups.
fix
Ensure the call to `vcver.get_version()` is executed within the root of your Git or Mercurial repository. In CI/CD, ensure a full clone is performed rather than a shallow one, or configure `vcver` with `raise_if_no_vcs=False` to return `None` gracefully.
Upgrade
Version history
0.2.12latest on PyPI · released Aug 10, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
vcver — pip install vcver · libregistry