diff --git a/.gitignore b/.gitignore index 6da9743..798b8f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ .vscode .idea +bennu.deb +pybennu.deb build *.autosave #*.pyc diff --git a/CMakeLists.txt b/CMakeLists.txt index 208e9ab..9e14340 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,16 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) +# unix timestamp +string(TIMESTAMP BUILD_TIMESTAMP "%s") + # CMake requires semantic versions with integer components # Set it to something static so stuff works -set(bennu_VERSION "6.0.0") +# Example: 6.0.1707507861 +set(bennu_VERSION "6.0.${BUILD_TIMESTAMP}") # Add commit hash to the version for use by the Deb package builder -# Example: 6.0.0.f7055755 +# Example: 6.0.1707507861.94edd945 set(bennu_VERSION_WITH_COMMIT "${bennu_VERSION}.${bennu_SHORT_HASH}") project(bennu diff --git a/build_bennu_deb.sh b/build_bennu_deb.sh new file mode 100755 index 0000000..8871a93 --- /dev/null +++ b/build_bennu_deb.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -ex + +mkdir -p ./build +cd ./build +cmake ../ +make -j "$(nproc)" +sudo make package +cp ./*.deb ../bennu.deb +cd ../ diff --git a/cmake/CpackConfig.cmake b/cmake/CpackConfig.cmake index a6bf2e3..2461ae7 100644 --- a/cmake/CpackConfig.cmake +++ b/cmake/CpackConfig.cmake @@ -17,7 +17,7 @@ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories PACKAGE_LICENSE = GPLv3 -PACKAGE_URL = https://github.com/sandialabs/sceptre-bennu.git +PACKAGE_URL = https://github.com/sandialabs/sceptre-bennu PACKAGE_ARCHITECTURE = amd64 ## @@ -63,7 +63,7 @@ endef ## # Targets ## -.PHONY: dist test docs +.PHONY: packagetools pytools root clean clean-build clean-pyc deb dist sdist install install-dev uninstall wheelhouse bull help: @echo "clean - Remove python and build file artifacts." @@ -107,24 +107,7 @@ clean-pyc: @find . -name ".cache" -exec rm -rfv {} + deb: packagetools - @mkdir -p dist/ - @echo 'printf "\n--- RUNNING PYBENNU AFTER INSTALL SCRIPT ---\n\n"' > $(POST) - @echo 'mv /root/libzmq* /usr/lib/x86_64-linux-gnu' >> $(POST) - @echo 'printf "\n\tINSTALLING ZMQ WITH DRAFT SUPPORT...\n\n"' >> $(POST) - @echo 'wget --no-check-certificate https://raw.githubusercontent.com/zeromq/pyzmq/main/examples/draft/install.sh' >> $(POST) - @echo 'sed -i -e "s/wget/wget --no-check-certificate/g" install.sh' >> $(POST) - @echo 'sed -i -e "s/make -j/make -j $(nproc)/g" install.sh' >> $(POST) - @echo 'sed -i -e "s/pip install/pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org -I/g" install.sh' >> $(POST) - @echo 'chmod +x install.sh' >> $(POST) - @echo './install.sh' >> $(POST) - @echo 'printf "\n\tINSTALLING HELICS/PYHELICS...\n\n"' >> $(POST) - @echo 'wget --no-check-certificate -O pyhelics.tgz https://github.com/GMLC-TDC/pyhelics/releases/download/v2.7.1/helics-2.7.1.tar.gz' >> $(POST) - @echo 'mkdir -p /tmp/pyhelics && tar -C /tmp/pyhelics -xzf pyhelics.tgz && rm pyhelics.tgz' >> $(POST) - @echo 'cd /tmp/pyhelics/helics-2.7.1 && sed -i "s/helics-apps/helics-apps~=2.7.1/" /tmp/pyhelics/helics-2.7.1/setup.py' >> $(POST) - @echo 'pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org /tmp/pyhelics/helics-2.7.1/' >> $(POST) - @echo 'printf "\n\tINSTALLING PYBENNU PIP DEPENDENCIES...\n\n"' >> $(POST) - @echo 'pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org bitarray elasticsearch>=5.3.0 helics~=2.7.1 matplotlib>=1.5.3 networkx>=1.11 numpy>=1.11.2 opendssdirect.py~=0.6.1 py-expression-eval~=0.3.14 PYPOWER>=5.0.1 pyserial>=3.4 pyyaml>=3.12 requests>=2.20 scipy>=0.18.1 sysv_ipc' >> $(POST) - @echo 'printf "\nDONE!!\n\n"' >> $(POST) + @mkdir -p $(DIST_DIR) @$(FPM) \ --verbose \ -f \ diff --git a/src/pybennu/postinst b/src/pybennu/postinst new file mode 100755 index 0000000..dee84a8 --- /dev/null +++ b/src/pybennu/postinst @@ -0,0 +1,34 @@ +set -ex + +printf "\n--- RUNNING PYBENNU AFTER INSTALL SCRIPT ---\n\n" +if [[ ! -f /usr/lib/x86_64-linux-gnu/libzmq.a ]]; then + mv /root/libzmq.a /usr/lib/x86_64-linux-gnu/ +fi +if [[ ! -f /usr/lib/x86_64-linux-gnu/libzmq.so.5.1.5 ]]; then + mv /root/libzmq.so.5.1.5 /usr/lib/x86_64-linux-gnu/ +fi +# mv /root/libzmq* /usr/lib/x86_64-linux-gnu + +# TODO: we should statically include our own version of install.sh +# instead of downloading it every build and running sed on it +printf "\n\tINSTALLING ZMQ WITH DRAFT SUPPORT...\n\n" +wget --no-check-certificate https://raw.githubusercontent.com/zeromq/pyzmq/main/examples/draft/install.sh +sed -i -e "s/wget/wget --no-check-certificate/g" install.sh +sed -i -e "s/pip install/pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org -I/g" install.sh +chmod +x install.sh +./install.sh +rm ./install.sh + +printf "\n\tINSTALLING HELICS/PYHELICS...\n\n" +wget --no-check-certificate -O pyhelics.tgz https://github.com/GMLC-TDC/pyhelics/releases/download/v2.7.1/helics-2.7.1.tar.gz +mkdir -p /tmp/pyhelics +tar -C /tmp/pyhelics -xzf pyhelics.tgz +rm pyhelics.tgz +cd /tmp/pyhelics/helics-2.7.1 +sed -i "s/helics-apps/helics-apps~=2.7.1/" /tmp/pyhelics/helics-2.7.1/setup.py +pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org /tmp/pyhelics/helics-2.7.1/ + +printf "\n\tINSTALLING PYBENNU PIP DEPENDENCIES...\n\n" +pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org bitarray 'elasticsearch>=5.3.0' 'helics~=2.7.1' 'matplotlib>=1.5.3' 'networkx>=1.11' 'numpy>=1.11.2' 'opendssdirect.py~=0.6.1' 'py-expression-eval~=0.3.14' 'PYPOWER>=5.0.1' 'pyserial>=3.4' 'pyyaml>=3.12' 'requests>=2.20' 'scipy>=0.18.1' sysv_ipc + +printf "\nDONE!!\n\n" \ No newline at end of file diff --git a/src/pybennu/setup.py b/src/pybennu/setup.py index 2974464..274e1c1 100644 --- a/src/pybennu/setup.py +++ b/src/pybennu/setup.py @@ -155,7 +155,7 @@ def run(self): # https://github.com/pypa/setuptools_scm version = '6.0.0', description = 'bennu python providers and utilities', - url = 'https://github.com/sandialabs/sceptre-bennu.git', + url = 'https://github.com/sandialabs/sceptre-bennu', author = 'Sandia National Laboratories', author_email = 'emulytics@sandia.gov', license = 'GPLv3',