Skip to content

Commit

Permalink
version (#1165)
Browse files Browse the repository at this point in the history
* merging upstream

* bringing version to cookiecutter standards and changing how xonsh is initialized in init
  • Loading branch information
sbillinge committed Sep 20, 2024
1 parent 6237ce2 commit 812261a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 47 deletions.
28 changes: 19 additions & 9 deletions src/regolith/__init__.py
Original file line number Diff line number Diff line change
@@ -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
43 changes: 5 additions & 38 deletions src/regolith/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 812261a

Please sign in to comment.