diff --git a/.gitignore b/.gitignore index 69f88fd47..a520ac4b1 100644 --- a/.gitignore +++ b/.gitignore @@ -179,4 +179,7 @@ geodata.conf gldcore/autotest/output.csv python_extras/example/output.csv *.egg +gridlabd.egg-info/ +gldcore/link/python/dist/ +gldcore/link/python/gridlabd.egg-info/ gridlabd.egg-* diff --git a/gldcore/link/python/Makefile.mk b/gldcore/link/python/Makefile.mk index db439a638..f38ea0d71 100644 --- a/gldcore/link/python/Makefile.mk +++ b/gldcore/link/python/Makefile.mk @@ -1,8 +1,12 @@ -python-install: gldcore/build.h - @echo "python3 $(top_srcdir)/gldcore/link/python/setup.py --quiet install" - @( export SRCDIR=$(top_srcdir) ; python3 $(top_srcdir)/gldcore/link/python/setup.py --quiet install ) +$(top_srcdir)/gldcore/link/python/dist/gridlabd-$(notdir $(prefix))-.tar.gz: gldcore/build.h + @echo "building $@" + @python3 -m pip install build 1>/dev/null + @( export SRCDIR=$(realpath $(top_srcdir)) ; python3 -m build $(top_srcdir)/gldcore/link/python 1>/dev/null ) + +python-install: $(top_srcdir)/gldcore/link/python/dist/gridlabd-$(notdir $(prefix))-.tar.gz + @echo "installing $@" + @python3 -m pip install --ignore-installed $(top_srcdir)/gldcore/link/python/dist/gridlabd-*.whl python-clean: - @echo "python3 $(top_srcdir)/gldcore/link/python/setup.py clean" - @( export SRCDIR=$(top_srcdir) ; python3 $(top_srcdir)/gldcore/link/python/setup.py clean ) - -rm -rf $(SRCDIR)/build/lib.* + @echo "uninstalling $(top_srcdir)/gldcore/link/python" + @python3 -m pip uninstall gridlabd -y || (echo "Use '. utilities/cleanwc' instead to clean this build."; exit 1) diff --git a/gldcore/link/python/setup.py b/gldcore/link/python/setup.py index 52c278919..5e09ff875 100644 --- a/gldcore/link/python/setup.py +++ b/gldcore/link/python/setup.py @@ -137,9 +137,12 @@ def get_version(path=None): if info[0] == "#define": if info[1] == "BUILDNUM": build = int(info[2]) + elif info[1] == "BRANCH": + branch = info[2].replace('"','') except: build = 0 - return '%d.%d.%d.%d' % (major,minor,patch,build) + # TODO: this needs to be revised to match PEP 440 + return '%d.%d.%d-%d-%s' % (major,minor,patch,build,branch) setup ( name = 'gridlabd', version = get_version(),