refactor: move __version__ and __version_info__ into _version.py#865
Merged
Conversation
Extract the version definitions from brainpy/__init__.py into a dedicated brainpy/_version.py module and re-export them from the package root, so the canonical version string lives in a single small file. pyproject already reads brainpy.__version__ and lists _version.py in its coverage omit lists.
Reviewer's GuideRefactors version handling by moving the package version definitions into a dedicated brainpy._version module and re-exporting them from brainpy.init to keep existing public APIs and packaging configuration working. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider using a relative import (
from ._version import __version__, __version_info__) in__init__.pyto avoid potential issues if the package is ever renamed or vendored.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using a relative import (`from ._version import __version__, __version_info__`) in `__init__.py` to avoid potential issues if the package is ever renamed or vendored.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
chaoming0625
added a commit
that referenced
this pull request
Jul 9, 2026
PR #865 moved __version__ into brainpy/_version.py and made __init__ re-export it. That broke static version resolution for consumers still pointing at brainpy.__init__: - pyproject.toml used `attr = "brainpy.__version__"`. setuptools reads attr via AST only when it is a literal assignment; after the move __init__ exposes the name through an ImportFrom, so setuptools falls back to importing the whole brainpy package. In Publish.yml's isolated `python -m build` env (no jax / brainstate) that import fails. Point the attr at brainpy._version.__version__, which resolves statically without importing the package. - docs/conf.py imported the full brainpy package solely to read brainpy.__version__. Read it directly from brainpy._version instead. brainpy/__init__.py keeps re-exporting __version__/__version_info__, so bp.__version__ still works for users.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extract the version definitions from
brainpy/__init__.pyinto a dedicatedbrainpy/_version.pymodule and re-export them from the package root.brainpy._versionis now the single source of truth for the version string.brainpy/__init__.pyre-exports__version__and__version_info__, sopyproject'sversion = { attr = "brainpy.__version__" }still resolves._version.pyis already listed in the coverage omit lists inpyproject.toml.Verified
import brainpyyields2.8.0/(2, 8, 0).Summary by Sourcery
Enhancements: