From 812261a7584597abf5c188c14bd29bec37e3fb18 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Fri, 20 Sep 2024 17:22:25 -0400 Subject: [PATCH] version (#1165) * merging upstream * bringing version to cookiecutter standards and changing how xonsh is initialized in init --- src/regolith/__init__.py | 28 +++++++++++++++++--------- src/regolith/version.py | 43 +++++----------------------------------- 2 files changed, 24 insertions(+), 47 deletions(-) diff --git a/src/regolith/__init__.py b/src/regolith/__init__.py index 0d5143d00..9c855482f 100644 --- a/src/regolith/__init__.py +++ b/src/regolith/__init__.py @@ -1,12 +1,22 @@ -# stup import hooks -import xonsh.imphooks -from xonsh.built_ins import XSH -from xonsh.execer import Execer +# import xonsh.imphooks +# from xonsh.built_ins import XSH +# from xonsh.execer import Execer -XSH.load(execer=Execer()) -execer = XSH.execer -xonsh.imphooks.install_import_hooks(execer=execer) +from xonsh.main import setup -__version__ = "0.8.2" +from regolith.version import __version__ -del xonsh +"""A Research group database management system""" + +# Silence the pyflakes syntax checker +assert __version__ or True + +setup() +del setup + +# Initialize the Xonsh environment +# # execer = Execer(config=None) +# # XSH.load(execer=execer) +# # xonsh.imphooks.install_import_hooks(execer=execer) +# +# del xonsh diff --git a/src/regolith/version.py b/src/regolith/version.py index 04517257c..cebe0c8fa 100644 --- a/src/regolith/version.py +++ b/src/regolith/version.py @@ -3,7 +3,7 @@ # # regolith by DANSE Diffraction group # Simon J. L. Billinge -# (c) 2011 The Trustees of Columbia University +# (c) 2011-2024 The Trustees of Columbia University # in the City of New York. All rights reserved. # # File coded by: Pavol Juhas @@ -14,45 +14,12 @@ ############################################################################## """ -Definition of __version__, __date__, __timestamp__, __git_commit__. - -Notes ------ -Variable `__gitsha__` is deprecated as of version 3.0. -Use `__git_commit__` instead. +Definition of __version__ """ -__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] - -import os.path -from importlib.resources import as_file, files - -# obtain version information from the version.cfg file -cp = dict(version="", date="", commit="", timestamp="0") -if __package__ is not None: - ref = files(__package__) / "version.cfg" - with as_file(ref) as fcfg: - if not os.path.isfile(fcfg): # pragma: no cover - from warnings import warn - - warn("Package metadata not found.") - fcfg = os.devnull - with open(fcfg) as fp: - kwords = [ - [w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line - ] - assert all(w[0] in cp for w in kwords), "received unrecognized keyword" - cp.update(kwords) - del kwords - -__version__ = cp["version"] -__date__ = cp["date"] -__git_commit__ = cp["commit"] -__timestamp__ = int(cp["timestamp"]) - -# TODO remove deprecated __gitsha__ in version 3.1. -__gitsha__ = __git_commit__ +# obtain version information +from importlib.metadata import version -del cp +__version__ = version("regolith") # End of file