Skip to content

Fixes version retrieval during package builds causing KeyError on installation - #766

Open
syed177013 wants to merge 1 commit into
XPixelGroup:masterfrom
syed177013:syed177013-patch-1
Open

Fixes version retrieval during package builds causing KeyError on installation#766
syed177013 wants to merge 1 commit into
XPixelGroup:masterfrom
syed177013:syed177013-patch-1

Conversation

@syed177013

@syed177013 syed177013 commented Sep 6, 2026

Copy link
Copy Markdown

This PR addresses a KeyError: 'version' that can occur when installing BasicSR during package metadata generation.

The issue occurs in get_version(), which previously relied on locals() to retrieve version after executing the generated basicsr/version.py.

-Updated get_version() to execute the generated version file in an explicit namespace and retrieve __version__ from that namespace directly.
-Ensured write_version_py() runs during the package build process so that the generated version file is available when get_version() is called.

After the changes:

-python -m pip install . successfully builds and installs BasicSR.
-import basicsr; print(basicsr.version) successfully reports the package version.
-Torch and Torchvision imports continue to work correctly.

This is a minimal packaging focused change and does not alter BasicSR's runtime functionality.

Fixes a KeyError: '__version__' when installing
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.

1 participant