Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Fix python module build method #1072

Merged
merged 10 commits into from
Jan 13, 2022
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,5 @@ gldcore/autotest/output.csv
python_extras/example/output.csv
*.egg
gridlabd.egg-info/
gldcore/link/python/dist/
gldcore/link/python/gridlabd.egg-info/
16 changes: 10 additions & 6 deletions gldcore/link/python/Makefile.mk
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion gldcore/link/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down