Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix versioning for realsies #19

Merged
merged 9 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.vscode
.idea

bennu.deb
pybennu.deb
build
*.autosave
#*.pyc
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions build_bennu_deb.sh
Original file line number Diff line number Diff line change
@@ -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 ../
2 changes: 1 addition & 1 deletion cmake/CpackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sandia National Laboratories <emulytics@san
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libasio-dev, libboost-date-time-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev")
set(CPACK_DEBIAN_PACKAGE_SECTION misc)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_FILE_NAME "bennu-${CPACK_DEBIAN_PACKAGE_VERSION}_amd64_${timestamp}")
set(CPACK_PACKAGE_FILE_NAME "bennu-${CPACK_DEBIAN_PACKAGE_VERSION}_amd64")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL})

include(CPack)
33 changes: 8 additions & 25 deletions src/pybennu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif

BUILD_DIR = $(CURDIR)/build
DIST_DIR = $(CURDIR)/dist
POST = $(CURDIR)/dist/postinst
POST = $(CURDIR)/postinst

##
# Packaging
Expand All @@ -36,17 +36,17 @@ POST = $(CURDIR)/dist/postinst
define PACKAGE_DESCRIPTION
Modeling and simulation application for SCADA/ICS.
endef
TIMESTAMP = $(shell date +%Y%m%d_%H-%M-%S)
PACKAGE_SECTION = python
PACKAGE_PRIORITY = extra
PACKAGE_PRIORITY = optional
PACKAGE_COMPRESSION = bzip2
PACKAGE_FULL_VERSION := 6.0.0.$(shell git rev-parse --short HEAD)
# 6.0.1707507794.8a88a442
PACKAGE_FULL_VERSION := 6.0.$(shell date +%s).$(shell git rev-parse --short HEAD)
PACKAGE_NAME = pybennu
PACKAGE_FILENAME = $(PACKAGE_NAME)_$(PACKAGE_FULL_VERSION)_amd64_$(TIMESTAMP).deb
PACKAGE_FILENAME = $(PACKAGE_NAME)_$(PACKAGE_FULL_VERSION)_amd64.deb
PACKAGE_VENDOR = SNL
PACKAGE_MAINTAINER = Sandia National Laboratories <[email protected]>
PACKAGE_LICENSE = GPLv3
PACKAGE_URL = https://github.com/sandialabs/sceptre-bennu.git
PACKAGE_URL = https://github.com/sandialabs/sceptre-bennu
PACKAGE_ARCHITECTURE = amd64

##
Expand All @@ -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."
Expand Down Expand Up @@ -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 \
Expand Down
34 changes: 34 additions & 0 deletions src/pybennu/postinst
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion src/pybennu/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]',
license = 'GPLv3',
Expand Down