Skip to content

Commit

Permalink
Remove versioneer.py; use setuptools-git-versioning instead (python-g…
Browse files Browse the repository at this point in the history
…raphblas#362)

* Remove versioneer.py; use setuptools-git-versioning instead

* Alright, readthedocs doesn't know how to install in conda env; maybe we should use pip

Context: I updated settings on the readthedocs site to "install" the package. Oh well.

* Give informative error message
  • Loading branch information
eriknw authored Jan 6, 2023
1 parent 501fe6f commit ac9fbb2
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 2,428 deletions.
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
comment: off
ignore:
- graphblas/_version.py
- graphblas/viz.py
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

5 changes: 5 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ build:

conda:
environment: docs/env.yml

python:
install:
- method: pip
path: .
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ include setup.py
include README.md
include LICENSE
include MANIFEST.in
include versioneer.py
include graphblas/_version.py
include graphblas/graphblas.yaml
include graphblas/tests/pickle*.pkl
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@

# The full version, including alpha/beta/rc tags
# release = "1.3.2"
# See: https://github.com/pypa/setuptools_scm/#usage-from-sphinx
from importlib.metadata import version # noqa: E402 isort: skip

release = version("python-graphblas")
del version

# -- General configuration ---------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ dependencies:
# - pyupgrade
# - ruff
# - scalene
# - setuptools-git-versioning
# - snakeviz
# - sphinx-lint
# - sympy
Expand Down
17 changes: 12 additions & 5 deletions graphblas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys as _sys
from importlib import import_module as _import_module

from ._version import get_versions


class replace:
"""Singleton to indicate ``replace=True`` when updating objects.
Expand Down Expand Up @@ -82,13 +80,25 @@ def __getattr__(name):
if _init_params is None:
_init("suitesparse", None, automatic=True)
return
if name == "__version__":
from importlib.metadata import version

try:
return globals().setdefault("__version__", version("python-graphblas"))
except Exception as exc: # pragma: no cover (safety)
raise AttributeError(
"`graphblas.__version__` not available. This may mean python-graphblas was "
"incorrectly installed or not installed at all. For local development, you may "
"want to do an editable install via `python -m pip install -e path/to/graphblas`."
) from exc
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


def __dir__():
names = globals().keys() | _SPECIAL_ATTRS
if backend is not None and backend != "suitesparse":
names.remove("ss")
names.add("__version__")
return list(names)


Expand Down Expand Up @@ -186,7 +196,4 @@ def _load(name):
globals()[name] = _import_module(f".{name}", __name__)


__version__ = get_versions()["version"]
del get_versions

__all__ = [key for key in __dir__() if not key.startswith("_")]
Loading

0 comments on commit ac9fbb2

Please sign in to comment.