Skip to content

Add fallback version for building from source without git metadata - #34

Closed
AtharvRG wants to merge 1 commit into
IBM:mainfrom
AtharvRG:fix/setup-default-release-version
Closed

AtharvRG wants to merge 1 commit into
IBM:mainfrom
AtharvRG:fix/setup-default-release-version

Conversation

@AtharvRG

Copy link
Copy Markdown

Summary

Building the package from a source tree without git metadata (e.g. GitHub tarball archives or a git checkout without the .git folder) currently fails:

LookupError: Error getting the version from source `vcs`: setuptools-scm was unable to detect version ...

This adds a fallback-version = "0.0.0" to [tool.hatch.version] in pyproject.toml, so such builds default to a placeholder version instead of hard-failing. The issue was originally reported against setup.py, which asserted when RELEASE_VERSION was missing; setup.py has since been replaced by pyproject.toml + hatch-vcs, and this is the equivalent fix in the current build system.

Verification

  • Without git metadata (cloned tree with .git removed): python -m build now succeeds, producing alchemy_config-0.0.0.tar.gz / alchemy_config-0.0.0-py3-none-any.whl.
  • With git metadata (normal repo checkout): build still derives the correct VCS version, e.g. alchemy_config-1.2.1.dev35+ga760720ad — no regression.

Fixes #9

Changes

  • pyproject.toml: added fallback-version = "0.0.0" under [tool.hatch.version]

When building from a source tree without git metadata (e.g. GitHub
tarball archives or git checkouts without the .git folder), hatch-vcs
raises a LookupError since no version can be derived from tags.

Set fallback-version = "0.0.0" in [tool.hatch.version] so such builds
default to a placeholder version instead of failing.

Fixes IBM#9
@AtharvRG

Copy link
Copy Markdown
Author

Hi! I worked on this issue for Hacktoberfest. Some notes on the approach:

Context: Since the issue was filed, the build system changed — setup.py was replaced by pyproject.toml using hatchling + hatch-vcs (commit adfd21d). So instead of defaulting RELEASE_VERSION in setup.py, the equivalent fix today is giving hatch-vcs a fallback for when version discovery fails.

What fails today: any source tree without git metadata can't be built. Reproduced with a git clone minus the .git folder:

LookupError: Error getting the version from source `vcs`:
setuptools-scm was unable to detect version for ...

The fix: fallback-version = "0.0.0" under [tool.hatch.version] — a one-line change, mirroring the version = "0.0.0" default the issue originally suggested.

Tested:

  • Without git metadata → builds alchemy_config-0.0.0 (was a hard error before)
  • With git metadata → still builds the proper VCS-derived version, no regression

Happy to adjust if you'd prefer a different fallback strategy or a different default version!

@AtharvRG AtharvRG closed this Oct 31, 2026
@AtharvRG
AtharvRG deleted the fix/setup-default-release-version branch October 31, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a default version in setup.py

1 participant