From fc94392c1094a89e260f62fc7e1aa018bda1be66 Mon Sep 17 00:00:00 2001 From: hmacdope Date: Fri, 2 Aug 2024 16:33:56 +1000 Subject: [PATCH 1/4] fix version and add test --- mtenn/__init__.py | 2 ++ mtenn/_version.py | 2 +- mtenn/tests/test_version.py | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 mtenn/tests/test_version.py diff --git a/mtenn/__init__.py b/mtenn/__init__.py index 38fbc62..fed3437 100644 --- a/mtenn/__init__.py +++ b/mtenn/__init__.py @@ -1 +1,3 @@ """Modular Training and Evaluation of Neural Networks""" + +from ._version_git import __version__ \ No newline at end of file diff --git a/mtenn/_version.py b/mtenn/_version.py index d3ec452..fa93c21 100644 --- a/mtenn/_version.py +++ b/mtenn/_version.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.6.0+0.gc18b034.dirty" diff --git a/mtenn/tests/test_version.py b/mtenn/tests/test_version.py new file mode 100644 index 0000000..13ca4a1 --- /dev/null +++ b/mtenn/tests/test_version.py @@ -0,0 +1,4 @@ +import mtenn + +def test_version(): + assert mtenn.__version__ \ No newline at end of file From 1e703aa6bf4a96a528714eb20fae9eecd2ec1121 Mon Sep 17 00:00:00 2001 From: hmacdope Date: Tue, 6 Aug 2024 09:13:39 +1000 Subject: [PATCH 2/4] fiux --- mtenn/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtenn/_version.py b/mtenn/_version.py index fa93c21..906d362 100644 --- a/mtenn/_version.py +++ b/mtenn/_version.py @@ -1 +1 @@ -__version__ = "0.6.0+0.gc18b034.dirty" +__version__ = "0.6.0" From b133c8650e2080f772e290aa5f9e3a752325a2c6 Mon Sep 17 00:00:00 2001 From: hmacdope Date: Tue, 6 Aug 2024 09:18:03 +1000 Subject: [PATCH 3/4] remove write of version file --- mtenn/__init__.py | 3 +- mtenn/_version.py | 1 - mtenn/_version_git.py | 97 ------------------------------------------- pyproject.toml | 12 +++--- 4 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 mtenn/_version.py delete mode 100644 mtenn/_version_git.py diff --git a/mtenn/__init__.py b/mtenn/__init__.py index fed3437..312f0ee 100644 --- a/mtenn/__init__.py +++ b/mtenn/__init__.py @@ -1,3 +1,4 @@ """Modular Training and Evaluation of Neural Networks""" -from ._version_git import __version__ \ No newline at end of file +from importlib.metadata import version +__version__ = version("mtenn") \ No newline at end of file diff --git a/mtenn/_version.py b/mtenn/_version.py deleted file mode 100644 index 906d362..0000000 --- a/mtenn/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.6.0" diff --git a/mtenn/_version_git.py b/mtenn/_version_git.py deleted file mode 100644 index 2b0b7b6..0000000 --- a/mtenn/_version_git.py +++ /dev/null @@ -1,97 +0,0 @@ -# Compute a version number from a git repo or archive - -# This file is released into the public domain. Generated by: -# versiongit-2.1 (https://github.com/dls-controls/versiongit) -import re -import sys -from pathlib import Path -from subprocess import STDOUT, CalledProcessError, check_output - -# These will be filled in if git archive is run or by setup.py cmdclasses -GIT_REFS = "$Format:%D$" -GIT_SHA1 = "$Format:%h$" - -# Git describe gives us sha1, last version-like tag, and commits since then -CMD = "git describe --tags --dirty --always --long --match=[0-9]*[-.][0-9]*" - - -def get_version_from_git(path=None): - """Try to parse version from git describe, fallback to git archive tags""" - tag, plus, suffix = "0.0", "untagged", "" - if not GIT_SHA1.startswith("$"): - # git archive or the cmdclasses below have filled in these strings - sha1 = GIT_SHA1 - for ref_name in GIT_REFS.split(", "): - if ref_name.startswith("tag: "): - # git from 1.8.3 onwards labels archive tags "tag: TAGNAME" - tag, plus = ref_name[5:], "0" - else: - if path is None: - # If no path to git repo, choose the directory this file is in - path = Path(__file__).absolute().parent - # output is TAG-NUM-gHEX[-dirty] or HEX[-dirty] - try: - cmd_out = check_output(CMD.split(), stderr=STDOUT, cwd=path) - except Exception as e: - sys.stderr.write("%s: %s\n" % (type(e).__name__, str(e))) - if isinstance(e, CalledProcessError): - sys.stderr.write("-> %s" % e.output.decode()) - return "0.0+unknown", None, e - else: - out = cmd_out.decode().strip() - if out.endswith("-dirty"): - out = out[:-6] - suffix = ".dirty" - if "-" in out: - # There is a tag, extract it and the other pieces - match = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", out) - tag, plus, sha1 = match.groups() - else: - # No tag, just sha1 - sha1 = out - # Replace dashes in tag for dots - tag = tag.replace("-", ".") - if plus != "0" or suffix: - # Not on a tag, add additional info - tag = f"{tag}+{plus}.g{sha1}{suffix}" - return tag, sha1, None - - -__version__, git_sha1, git_error = get_version_from_git() - - -def get_cmdclass(build_py=None, sdist=None): - """Create cmdclass dict to pass to setuptools.setup that will write a - _version_static.py file in our resultant sdist, wheel or egg""" - if build_py is None: - from setuptools.command.build_py import build_py - if sdist is None: - from setuptools.command.sdist import sdist - - def make_version_static(base_dir: str, pkg: str): - vg = Path(base_dir) / pkg.split(".")[0] / "_version_git.py" - if vg.is_file(): - lines = open(vg).readlines() - with open(vg, "w") as f: - for line in lines: - # Replace GIT_* with static versions - if line.startswith("GIT_SHA1 = "): - f.write("GIT_SHA1 = '%s'\n" % git_sha1) - elif line.startswith("GIT_REFS = "): - f.write("GIT_REFS = 'tag: %s'\n" % __version__) - else: - f.write(line) - - class BuildPy(build_py): - def run(self): - build_py.run(self) - for pkg in self.packages: - make_version_static(self.build_lib, pkg) - - class Sdist(sdist): - def make_release_tree(self, base_dir, files): - sdist.make_release_tree(self, base_dir, files) - for pkg in self.distribution.packages: - make_version_static(base_dir, pkg) - - return dict(build_py=BuildPy, sdist=Sdist) diff --git a/pyproject.toml b/pyproject.toml index 00a101e..2dc55c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,17 +27,15 @@ exclude = ["mtenn.tests"] [tool.versioningit] default-version = "1+unknown" +[tool.versioningit] +default-version = "1+unknown" + [tool.versioningit.format] distance = "{base_version}+{distance}.{vcs}{rev}" dirty = "{base_version}+{distance}.{vcs}{rev}.dirty" distance-dirty = "{base_version}+{distance}.{vcs}{rev}.dirty" [tool.versioningit.vcs] -# The method key: -method = "git" # <- The method name -# Parameters to pass to the method: +method = "git" match = ["*"] -default-tag = "0.0.0" - -[tool.versioningit.write] -file = "mtenn/_version.py" +default-tag = "0.0.0" \ No newline at end of file From 3a04c5574491e8958f59874574746f0b9238c668 Mon Sep 17 00:00:00 2001 From: hmacdope Date: Tue, 6 Aug 2024 09:18:41 +1000 Subject: [PATCH 4/4] whoops --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2dc55c3..57a9ace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,9 +27,6 @@ exclude = ["mtenn.tests"] [tool.versioningit] default-version = "1+unknown" -[tool.versioningit] -default-version = "1+unknown" - [tool.versioningit.format] distance = "{base_version}+{distance}.{vcs}{rev}" dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"