{"id":5822,"library":"vcver","title":"vcver - Dynamic Versioning from VCS","description":"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.","status":"active","version":"0.2.12","language":"en","source_language":"en","source_url":"https://github.com/toumorokoshi/vcver-python","tags":["versioning","git","mercurial","setuptools","build","scm"],"install":[{"cmd":"pip install vcver","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"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`.","wrong":"from vcver import get_version # Avoid direct import if using in setup.py","symbol":"get_version","correct":"import vcver\nversion = vcver.get_version()"}],"quickstart":{"code":"import vcver\n\n# Example usage in setup.py for setuptools:\n# from setuptools import setup\n# setup(\n#     name='your_package',\n#     version=vcver.get_version(),\n#     # ... other setup arguments\n# )\n\n# Or to get the version directly:\ncurrent_version = vcver.get_version()\nprint(f\"Current package version: {current_version}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"vcver 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}