diff --git a/src/Makefile b/src/Makefile index 668d735..8f9d272 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,13 +9,12 @@ sdist: dist/msspec-$(VERSION).tar.gz frontend: $(INSTALL_PREFIX)/bin/msspec -dist/msspec-$(VERSION).tar.gz: VERSION +dist/msspec-$(VERSION).tar.gz: msspec/VERSION @echo "Creating Python source distribution..." - @+$(INSIDE_VENV) pip install build - @+$(INSIDE_VENV) $(PYTHON_EXE) -m build + @+$(INSIDE_VENV) pip install build && python -m build -$(INSTALL_PREFIX)/bin/msspec: msspec.sh.template VERSION +$(INSTALL_PREFIX)/bin/msspec: msspec.sh.template msspec/VERSION @echo "Installing frontend command..." @mkdir -p $(dir $@) @cat $< | sed -e 's#__VENV_PATH__#$(VENV_PATH)#' > $@ @@ -26,7 +25,7 @@ pybinding: @echo "Building Python binding for phagen and spec..." @+$(MAKE) -C msspec/phagen/fortran all @+$(MAKE) -C msspec/spec/fortran all - @echo "$(VERSION)" > VERSION + @echo "$(VERSION)" > msspec/VERSION results: msspec/results.txt @@ -54,7 +53,7 @@ clean:: # remove previous sdist @rm -rf dist @rm -rf *.egg* - @rm -f VERSION + @rm -f msspec/VERSION help: diff --git a/src/msspec/version.py b/src/msspec/version.py index bcd00c0..ebf350c 100644 --- a/src/msspec/version.py +++ b/src/msspec/version.py @@ -23,29 +23,37 @@ import os -from setuptools_scm import get_version from importlib.metadata import version import subprocess # find the version number -# 1- If it fails, try to read it from the distribution file -# 2- Try to read it from the git info -# 3- If it fails, try to read it from the VERSION file +# 1- Try to read it from the git info +# 2- If it fails, try to read it from the VERSION file +# 3- If it fails, try to read it from the distribution file PKGNAME = 'msspec' try: - __version__ = get_version(root='../..', relative_to=__file__) + cmd = ["git describe|sed 's/-\([0-9]\+\)-.*/.dev\\1/g'"] + result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True) + __version__ = result.stdout.decode('utf-8').strip() + if __version__ != "": + print("from git: ", __version__) + else: + raise NameError("Not a git repo") except Exception as err: + print(err) try: - __version__ = version(PKGNAME) + thisfile_path = os.path.abspath(__file__) + thisfile_dir = os.path.dirname(thisfile_path) + versionfile = os.path.join(thisfile_dir, "./VERSION") + with open(versionfile, "r") as fd: + __version__ = fd.readline().strip() + print("from VERSION: ", __version__) except Exception as err: try: - thisfile_path = os.path.abspath(__file__) - thisfile_dir = os.path.dirname(thisfile_path) - versionfile = os.path.join(thisfile_dir, "../VERSION") - with open(versionfile, "r") as fd: - __version__ = fd.readline().strip() + __version__ = version(PKGNAME) + print("from metadata: ", __version__) except Exception as err: print("Unable to get the version number!") __version__ = "0.0.0" diff --git a/src/options.mk b/src/options.mk index 15cb602..5e08919 100644 --- a/src/options.mk +++ b/src/options.mk @@ -41,7 +41,7 @@ F2PYFLAGS_DBG = --debug-capi --debug # /!\ DO NOT EDIT BELOW THAT LINE (unlesss you know what you're doing...) # # CORE CONFIGURATION # ################################################################################ -VERSION:=$(shell git describe) +VERSION:=$(shell git describe|sed 's/-\([0-9]\+\)-.*/.dev\1/g') VENV_PATH := $(INSTALL_PREFIX)/src/msspec_venv_$(VERSION) diff --git a/src/setup.cfg b/src/setup.cfg index ce2c01f..a4df7f2 100644 --- a/src/setup.cfg +++ b/src/setup.cfg @@ -50,5 +50,6 @@ install_requires = terminaltables [options.package_data] -msspec.phagen.fortran = *.so -msspec.spec.fortran = *.so +msspec.phagen = fortran/*.so +msspec.spec = fortran/*.so +msspec = VERSION