From 515e46def199e2c65edd99017e21d8e5e2b4b980 Mon Sep 17 00:00:00 2001 From: Lukas Sommer Date: Wed, 21 Apr 2021 10:36:13 +0200 Subject: [PATCH] Automatic build of tagged releases; --- .github/workflows/release-build-linux.yml | 134 ++++++++++++++++++++++ python-interface/setup.py.in | 14 ++- 2 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-build-linux.yml diff --git a/.github/workflows/release-build-linux.yml b/.github/workflows/release-build-linux.yml new file mode 100644 index 00000000..971b8fae --- /dev/null +++ b/.github/workflows/release-build-linux.yml @@ -0,0 +1,134 @@ +name: release-build-linux +on: + push: + tags: + - "v*" + +jobs: + + release-build-spnc: + runs-on: self-hosted + steps: + - name: Install Prerequisites + run: | + sudo apt update + apt install -y git gcc clang cmake ninja-build zlib1g zlib1g-dev python3 lld doxygen graphviz autoconf automake libtool python3-venv python3-pip python3-dev pkg-config libelf-dev libelf1 + + - name: Pull LLVM + uses: actions/checkout@v2 + with: + repository: llvm/llvm-project + ref: f8d3f47e1fd09392aa30df83849b25acd8c59a25 + path: llvm/llvm-src + + - name: Build LLVM + run: | + cd llvm + mkdir -p llvm-bin + cd llvm-bin + cmake -G Ninja -DLLVM_ENABLE_PROJECTS="mlir;clang;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_RTTI=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DLLVM_OPTIMIZED_TABLEGEN=ON ../llvm-src/llvm/ + ninja + echo "$GITHUB_WORKSPACE/llvm/llvm-bin/bin" >> $GITHUB_PATH + + - name: Pull Pybind11 + uses: actions/checkout@v2 + with: + repository: pybind/pybind11 + path: pybind11 + + - name: Build Pybind11 + run: | + cd pybind11 + mkdir -p build + cd build + cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/pybind11/install -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 .. + make -j + make install + + - name: Pull spdlog + uses: actions/checkout@v2 + with: + repository: gabime/spdlog + path: spdlog + + - name: Build spdlog + run: | + cd spdlog + mkdir -p build + cd build + cmake -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/spdlog/install -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. + make -j + make install + + - name: Pull capnproto + uses: actions/checkout@v2 + with: + repository: sandstorm-io/capnproto + path: capnproto + + - name: Build capnproto + run: | + cd capnproto/c++ + autoreconf -i + ./configure --prefix=$GITHUB_WORKSPACE/capnproto/install --disable-shared --with-pic + make -j + make install + + - name: Pull spnc + uses: actions/checkout@v2 + with: + path: spn-compiler + + - name: Build spnc + run: | + cd spn-compiler + mkdir -p build + cd build + cmake -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/llvm/llvm-bin/lib/cmake/llvm;$GITHUB_WORKSPACE/llvm/llvm-bin/lib/cmake/mlir;$GITHUB_WORKSPACE/pybind11/install/share/cmake/pybind11;$GITHUB_WORKSPACE/spdlog/install/lib/cmake/spdlog;$GITHUB_WORKSPACE/capnproto/install" -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_ASSERTIONS=ON -DSPNC_BUILD_DOC=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF .. + make -j + + - name: Test spnc + run: | + cd spn-compiler/build + make check-spnc-mlir + + - name: Setup Python venv + run: | + mkdir -p python + cd python + python3 -m venv venv + + - name: Test xspn + run: | + cd spn-compiler/xspn + source $GITHUB_WORKSPACE/python/venv/bin/activate + pip install -r requirements.txt + pip install wheel setuptools + python -m pytest + + - name: Package xspn + run: | + cd spn-compiler/xspn + source $GITHUB_WORKSPACE/python/venv/bin/activate + python setup.py bdist_wheel + + - name: Test Python interface + run: | + cd spn-compiler/python-interface + source $GITHUB_WORKSPACE/python/venv/bin/activate + python -m pytest + + - name: Package Python interface + run: | + cd spn-compiler/python-interface + source $GITHUB_WORKSPACE/python/venv/bin/activate + python setup.py bdist_wheel + + - name: Upload release + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + spn-compiler/python-interface/dist/spnc*.whl + spn-compiler/xspn/dist/xspn*.whl diff --git a/python-interface/setup.py.in b/python-interface/setup.py.in index 41661fb2..43444140 100644 --- a/python-interface/setup.py.in +++ b/python-interface/setup.py.in @@ -1,7 +1,7 @@ # # Auto-generated by CMake, do not edit! # -import setuptools +from setuptools import setup, Distribution, find_packages import shutil import os @@ -20,7 +20,14 @@ if not os.path.isfile(spncpyLib): with open("requirements.txt", "r") as rf: requirements = rf.readlines() -setuptools.setup( +# Specify that this has external modules to +# make sure that the resulting wheel is named +# with the platform name. +class BinaryDistribution(Distribution): + def has_ext_modules(foo): + return True + +setup( name="spnc", version="0.1", author="Embedded Systems and Applications Group, TU Darmstadt", @@ -33,11 +40,12 @@ setuptools.setup( "Operating System :: POSIX :: Linux", "Programming Language :: C++" ], - packages=setuptools.find_packages(include=["spnc", "spnc.*"]), + packages=find_packages(include=["spnc", "spnc.*"]), package_data={"spnc" : binaryPackages}, include_package_data=True, install_requires=requirements, setup_requires=["pytest-runner"], tests_require=["pytest"], test_suite="test", + distclass=BinaryDistribution ) \ No newline at end of file