-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Libraries (networkx, beartype, pot, etc..) (#1080)
* update bearype, hyppo, networkx, pot * update testfixtures library * update nbsphinx * Update ipython, ipykernel * add setuptools dependency * dynamically generate version file * replace setuptools with other methods * remove unused import * leave a stub version file in the project
- Loading branch information
1 parent
3547bed
commit ce263c9
Showing
4 changed files
with
289 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,6 @@ | ||
# Copyright (c) Microsoft Corporation and contributors. | ||
# Licensed under the MIT License. | ||
|
||
import configparser | ||
import datetime | ||
from typing import Optional | ||
|
||
import pkg_resources | ||
|
||
|
||
def __from_distribution() -> Optional[str]: | ||
""" | ||
This will be coming from our sdist's setup.cfg that we package up, and usually (or | ||
always?) means it will mean the sdist has been installed in the python environment. | ||
This is the common case when you've installed graspologic from PyPI | ||
""" | ||
try: | ||
return str(pkg_resources.get_distribution("graspologic").version) | ||
except BaseException: | ||
return None | ||
|
||
|
||
def __from_filesystem(setup_config: str = "setup.cfg") -> Optional[str]: | ||
""" | ||
If we aren't an installed library, pkg_resources.get_distribution() won't be | ||
able to find setup.cfg's version, so we'll try to look at it from the filesystem | ||
We can probably presume in this circumstance that we are not a properly installed | ||
version and thus we're going to mark it with a dev label and a time entry | ||
This is the common case when you are developing graspologic itself. | ||
""" | ||
try: | ||
cfg_parser = configparser.RawConfigParser() | ||
cfg_parser.read(setup_config) | ||
base_version = cfg_parser.get("metadata", "version") | ||
now = datetime.datetime.today().strftime("%Y%m%d%H%M%S") | ||
return f"{base_version}.dev{now}" | ||
except BaseException: | ||
return None | ||
|
||
|
||
# This version placeholder will be replaced during package build. | ||
# Do not commit this file. | ||
__version__ ="0.0.0"# | ||
# | ||
def __version() -> str: | ||
""" | ||
Distribution takes precedence, but otherwise we try to read it from the filesystem | ||
If all else fails, we have no way of knowing what version we are | ||
""" | ||
possible_version = __from_distribution() or __from_filesystem() | ||
return possible_version if possible_version is not None else "unknown" | ||
return __version__ |
Oops, something went wrong.