-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix location of getting version to utils
- Loading branch information
1 parent
3acf7a0
commit 4dac8e1
Showing
3 changed files
with
34 additions
and
25 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
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Module that contains helper functions specifically related to the bigscape version | ||
""" | ||
|
||
import toml | ||
|
||
from importlib import metadata | ||
from pathlib import Path | ||
|
||
|
||
def get_bigscape_version() -> str: | ||
"""Get the version of BiG-SCAPE. | ||
The way we retrieve the version is different depending on whether the package is | ||
installed or not. | ||
We need a dedicated library for this because the python community has not figured | ||
out that version numbers are pretty core to software development and there is no | ||
single place to put them. We want it to only be in the pyproject.toml file and not | ||
anywhere else, but this file is not available when installed as a package | ||
""" | ||
# can we get to the pyproject.toml file? | ||
print(__file__) | ||
pyproject_toml = Path(__file__).parent.parent.parent / "pyproject.toml" | ||
|
||
if pyproject_toml.exists(): | ||
return toml.load(pyproject_toml)["project"]["version"] | ||
|
||
# if not, we're probably running as a package. get the version of the currently | ||
# installed big-scape package | ||
|
||
return metadata.version("big-scape") |