diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 69f50f752..5e66c7b08 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -15,24 +15,18 @@ jobs: steps: - uses: actions/checkout@v2 - # this is to fix GIT not liking owner of the checkout dir - - name: Set ownership - run: | - chown -R $(id -u):$(id -g) $PWD - - - name: Update pip - run: python3 -m pip install --upgrade pip - - - name: install gridlabd + - name: Build gridlabd run: | + set +x + chown -R $(id -u):$(id -g) $PWD /github/home autoreconf -isf ./configure - make -j$(($(nproc)*3)) system + make -j$(($(nproc)*3)) python-install system - name: Install openfido run: curl -sL https://raw.githubusercontent.com/openfido/cli/main/install.sh | bash - - name: Validate build + - name: Validate system run: | gridlabd -D keep_progress=TRUE -T 0 --validate -D github_actions=yes || ( utilities/save_validation_errors ; false ) diff --git a/.gitignore b/.gitignore index 3a94432da..51ae8189c 100644 --- a/.gitignore +++ b/.gitignore @@ -140,6 +140,10 @@ fault_check.txt # files that should be ignored by git *_ignore.* +# requirements files +requirements.txt +python/venv + # specific outputs that should be ignored python/example.png models/ieee123/config/local.glm diff --git a/Makefile.am b/Makefile.am index 8475f4fdf..d0e252b05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,6 +10,14 @@ # Authors: # DP Chassin (dchassin@slac.stanford.edu) +# !!! must match version specified in configure.ac +PYVER = 3.10 +PYCFLAGS = $(shell python3.10-config --cflags) +PYLDFLAGS = $(shell python3.10-config --ldflags) + +SYSPYTHON = python$(PYVER) +PYTHONCONFIG = $(SYSPYTHON)-config + AM_INIT_AUTOMAKE = subdir-objects AUTOMAKE_OPTIONS = -Wno-portability ACLOCAL_AMFLAGS = -I m4 @@ -18,27 +26,30 @@ CC = $(PTHREAD_CC) CXX = $(PTHREAD_CXX) AM_CPPFLAGS = -Wall -fPIC -AM_CPPFLAGS += -I$(top_srcdir)/source -I$(top_srcdir)/build-dir/source +AM_CPPFLAGS += -I$(top_srcdir)/source #-I$(top_srcdir)/build-dir/source AM_CPPFLAGS += $(GLD_CPPFLAGS) +AM_CPPFLAGS += $(PYCFLAGS) AM_CFLAGS = -Wall -AM_CFLAGS += -I$(top_srcdir)/source -I$(top_srcdir)/build-dir/source +AM_CFLAGS += -I$(top_srcdir)/source #-I$(top_srcdir)/build-dir/source AM_CFLAGS += $(PTHREAD_CFLAGS) -AM_CFLAGS += $(GLD_CFLAGS) -I$(top_srcdir)/build-dir/source +AM_CFLAGS += $(GLD_CFLAGS) #-I$(top_srcdir)/build-dir/source +AM_CFLAGS += $(PYCFLAGS) AM_CXXFLAGS = -Wall -fPIC AM_CXXFLAGS += $(PTHREAD_CFLAGS) -AM_CXXFLAGS += $(GLD_CXXFLAGS) -I$(top_srcdir)/build-dir/source +AM_CXXFLAGS += $(GLD_CXXFLAGS) #-I$(top_srcdir)/build-dir/source +AM_CXXFLAGS += $(PYCFLAGS) -AM_LDFLAGS = +AM_LDFLAGS = $(PYLDFLAGS) AM_LDFLAGS += -no-undefined AM_LDFLAGS += -module AM_LDFLAGS += -avoid-version AM_LDFLAGS += -export-dynamic -AM_LDFLAGS += $(GLD_LDFLAGS) +AM_LDFLAGS += $(GLD_LDFLAGS) -lpython$(PYVER) # makefile fragments populate these variables -BUILT_SOURCES = +BUILT_SOURCES = CLEANFILES = EXTRA_DIST = dist_pkgdata_DATA = @@ -49,8 +60,6 @@ bin_PROGRAMS = bin_SCRIPTS = dist_doc_DATA = -python_requirements = $(shell find $(top_srcdir) -name requirements.txt -print) - docs_targets = # required modules @@ -71,6 +80,55 @@ include $(top_srcdir)/modules.mk # custom modules (see ./customize) include $(top_srcdir)/custom.mk +BUILT_SOURCES += python-requirements + +# +# Post install report +# + +install-exec-hook: | index docs + @cp ${top_srcdir}/{COPYRIGHT,LICENSE} $(prefix) + @echo "" + @echo "Install complete. Here are some useful commands now:" + @echo "" + @echo "To include this version in your command path:" + @echo " export PATH='$(DESTDIR)$(bindir):$$PATH'" + @echo "" + @echo "To run this version directly without using the command path:" + @echo " $(DESTDIR)$(bindir)/gridlabd" + @echo "" + @echo "To make this version the default for all users on this system:" + @echo " $(DESTDIR)$(bindir)/gridlabd version set $(shell basename $(exec_prefix))" + @echo "" + +# +# Python setup +# + +PYENV=$(bindir)/pkgenv +PYBIN=$(PYENV)/bin +PYLIB=$(PYENV)/lib +PYINC=$(PYENV)/include +ENVPYTHON=$(PYBIN)/python$(PYVER) +PYACTIVATE=source $(PYBIN)/activate + +python-requirements: | $(PYENV) + +# NB: it's ok to use the runner's python to generate the requirements.txt file +requirements.txt: python/requirements.csv + @python3 -m pip -q install pandas==2.0.0 + @python3 python/requirements.py $< >$@ + +$(PYENV): requirements.txt + @echo "Processing python requirements..." + @mkdir -p $(PYBIN) $(PYLIB) $(PYINC) + @$(SYSPYTHON) -m venv --symlinks $(PYENV) + @$(ENVPYTHON) -m pip install --upgrade pip + @$(ENVPYTHON) -m pip install pandas==2.0.0 + @$(ENVPYTHON) python/requirements.py --buildenv | bash + @$(ENVPYTHON) -m pip install -r requirements.txt + @touch $(PYENV) + # for doxygen commands include $(top_srcdir)/aminclude.mk @@ -285,24 +343,9 @@ distclean-local: python-clean libtool: $(LIBTOOL_DEPS) $(SHELL) $(PWD)/config.status libtool > /dev/null -install-exec-hook: index python-requirements docs - @cp ${top_srcdir}/{COPYRIGHT,LICENSE} $(prefix) - @echo "" - @echo "Install complete. Here are some useful commands now:" - @echo "" - @echo "To include this version in your command path:" - @echo " export PATH='$(DESTDIR)$(bindir):$$PATH'" - @echo "" - @echo "To run this version directly without using the command path:" - @echo " $(DESTDIR)$(bindir)/gridlabd" - @echo "" - @echo "To make this version the default for all users on this system:" - @echo " $(DESTDIR)$(bindir)/gridlabd version set $(shell basename $(exec_prefix))" - @echo "" - -python-requirements: $(python_requirements) - @echo "Updating python requirements..." - @$(bindir)/pkgenv/bin/python3 -m pip install -q -r $(subst $(subst ,, ), -r ,$(python_requirements)) +# +# Run this after changes that affect build-aux/version.sh output +# reconfigure: distclean autoreconf -isf && $(PWD)/configure --quiet diff --git a/build-aux/version.sh b/build-aux/version.sh index 1537e3b2d..4ccb6370d 100755 --- a/build-aux/version.sh +++ b/build-aux/version.sh @@ -36,6 +36,15 @@ case $1 in echo "$PKG" ;; --package-name | -P) echo "$NAM" ;; + --sysspec ) + if [ "$(uname -s)" == "Darwin" ]; then + echo darwin$(uname -r | cut -f1 -d.)-$(uname -m) + elif [ -f "/etc/os-release" ]; then + echo $(grep ^ID= /etc/os-release | cut -f2 -d= | tr -d '"')-$(grep ^VERSION_ID= /etc/os-release | cut -f2 -d= | tr -d '"')-$(uname -m) + else + echo $(uname -s)$(uname -r)-$(uname -m) + fi + ;; --help | -h) echo "Syntax: build-aux/version.sh