-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read version from version files via ast
In cases where packages import `__version__` from version modules (like those generated by setuptools_scm or attribution), this allows flit-core to use the existing ast-based logic to read the version directly from those files when possible. It checks a few well-known version filenames, including the package-level `__init__.py` as usual, with `__init__.py` taking precedence over external version files if an assigned `__version__` value exists in multiple places. This makes flit more resilient to reading version from these packages, even if their `__init__.py` has transitive imports that aren't available in the environment at build time (eg, conda-forge builds). It also reduces the number of times when flit has to fall back to actually importing the `__init__.py` file rather than reading with ast.
- Loading branch information
Showing
3 changed files
with
35 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
2 changes: 2 additions & 0 deletions
2
flit_core/flit_core/tests/samples/imported_version/package1/__init__.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
"""This module has a __version__ that requires a relative import""" | ||
|
||
from ._version import __version__ | ||
|
||
import a_package_that_doesnt_exist |
2 changes: 2 additions & 0 deletions
2
flit_core/flit_core/tests/samples/imported_version/package1/_version.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
"""Imposter docstring that shouldn't be used""" | ||
|
||
__version__ = '0.5.8' |