Skip to content

Commit

Permalink
Update Libraries (networkx, beartype, pot, etc..) (#1080)
Browse files Browse the repository at this point in the history
* 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
darthtrevino authored May 22, 2024
1 parent 3547bed commit ce263c9
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 233 deletions.
7 changes: 2 additions & 5 deletions graspologic/layouts/colors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import atexit
import json
import math
import os
Expand All @@ -10,7 +9,6 @@
from typing import Any, Optional

import numpy as np
import pkg_resources
from sklearn.preprocessing import minmax_scale

from graspologic.types import Dict, Tuple
Expand All @@ -22,9 +20,8 @@ def _load_thematic_json(path: Optional[str]) -> Tuple[Dict[Any, Any], Dict[Any,
if path is not None and Path(path).is_file():
colors_path = path
else:
atexit.register(pkg_resources.cleanup_resources)
include_path = pkg_resources.resource_filename(__package__, "include")
colors_path = os.path.join(include_path, "colors-100.json")
dir = os.path.dirname(__file__)
colors_path = os.path.join(dir, "include", "colors-100.json")

with open(colors_path) as thematic_json_io:
thematic_json = json.load(thematic_json_io)
Expand Down
54 changes: 5 additions & 49 deletions graspologic/version.py
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__
Loading

0 comments on commit ce263c9

Please sign in to comment.