Skip to content

Build and Publish Wheels (Linux aarch64) #6

Build and Publish Wheels (Linux aarch64)

Build and Publish Wheels (Linux aarch64) #6

name: Build and Publish Wheels (Linux aarch64)
on:
workflow_dispatch:
jobs:
build-linux-aarch64:
name: Linux Python aarch64 ${{ matrix.python-version }} - Build Wheels
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
PYTHON_VERSION_CODE: cp38-cp38
PYTHON_VERSION_NUMBER: "3.8"
PYTHON: /opt/python/cp38-cp38/bin/python3.8
PYTHON_PATH: /opt/python/cp38-cp38/bin/
PYTHON_INCLUDE: /opt/python/cp38-cp38/include/python3.8/
PYTHON_LIB: /opt/python/cp38-cp38/lib/python3.8
- python-version: "3.9"
PYTHON_VERSION_CODE: cp39-cp39
PYTHON_VERSION_NUMBER: "3.9"
PYTHON: /opt/python/cp39-cp39/bin/python3.9
PYTHON_PATH: /opt/python/cp39-cp39/bin/
PYTHON_INCLUDE: /opt/python/cp39-cp39/include/python3.9/
PYTHON_LIB: /opt/python/cp39-cp39/lib/python3.9
- python-version: "3.10"
PYTHON_VERSION_CODE: cp310-cp310
PYTHON_VERSION_NUMBER: "3.10"
PYTHON: /opt/python/cp310-cp310/bin/python3.10
PYTHON_PATH: /opt/python/cp310-cp310/bin/
PYTHON_INCLUDE: /opt/python/cp310-cp310/include/python3.10/
PYTHON_LIB: /opt/python/cp310-cp310/lib/python3.10
- python-version: "3.11"
PYTHON_VERSION_CODE: cp311-cp311
PYTHON_VERSION_NUMBER: "3.11"
PYTHON: /opt/python/cp311-cp311/bin/python3.11
PYTHON_PATH: /opt/python/cp311-cp311/bin/
PYTHON_INCLUDE: /opt/python/cp311-cp311/include/python3.11/
PYTHON_LIB: /opt/python/cp311-cp311/lib/python3.11
steps:
- name: Install QEMU deps
run: |
sudo apt-get update -q -y
sudo apt-get -qq install -y qemu qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes
- name: Check out the repo
uses: actions/checkout@v2
- name: Set variables
run: |
VER=$(cat ./VERSION.txt)
echo "VERSION=$VER"
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Test environment
run: |
echo "VERSION=${{ env.VERSION }}"
echo "PYTHON_VERSION_CODE=${{ matrix.PYTHON_VERSION_CODE }}"
echo "PYTHON_VERSION_NUMBER=${{ matrix.PYTHON_VERSION_NUMBER }}"
- name: Run docker build
run: |
docker run --rm --tty -v $(pwd):/nimblephysics \
-e PYTHON=${{ matrix.PYTHON }} \
-e PYTHON_VERSION_CODE=${{ matrix.PYTHON_VERSION_CODE }} \
-e PYTHON_INCLUDE=${{ matrix.PYTHON_INCLUDE }} \
-e PYTHON_LIB=${{ matrix.PYTHON_LIB }} \
-e PYTHON_VERSION_NUMBER=${{ matrix.PYTHON_VERSION_NUMBER }} \
-e PYTHON_PATH=${{ matrix.PYTHON_PATH }} \
keenon/diffdart:base_aarch64 \
/bin/bash -c '\
cd /nimblephysics;\
VER=$(cat ./VERSION.txt);\
PATH="${PYTHON_PATH}:${PATH}";\
CPATH="${PYTHON_INCLUDE}";\
echo "VER=$VER";\
echo "PYTHON=$PYTHON";\
echo "PYTHON_VERSION_CODE=$PYTHON_VERSION_CODE";\
echo "PYTHON_INCLUDE=$PYTHON_INCLUDE";\
echo "PYTHON_LIB=$PYTHON_LIB";\
echo "PYTHON_VERSION_NUMBER=$PYTHON_VERSION_NUMBER";\
echo "PYTHON_PATH=$PYTHON_PATH";\
echo "PATH=$PATH";\
echo "CPATH=$CPATH";\
${PYTHON} -m pip install pytest wheel auditwheel==5.1.2 pybind11-stubgen==0.16.2 numpy torch;\
cd /;\
git clone https://github.com/pybind/pybind11.git;\
pushd pybind11;\
git checkout v2.11.1;\
mkdir build;\
pushd build;\
cmake -DPYTHON_LIBRARY=$PYTHON_LIB -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE -DPYTHON_EXECUTABLE=$PYTHON ..;\
make install -j4;\
cd /nimblephysics;\
${PYTHON} setup.py sdist bdist_wheel;\
${PYTHON} -m auditwheel repair dist/nimblephysics-${VER}-${PYTHON_VERSION_CODE}-linux_aarch64.whl;\
'
- name: Publish artifact
uses: actions/upload-artifact@v2
with:
name: nimblephysics-${{ env.VERSION }}-${{ matrix.PYTHON_VERSION_CODE }}-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
path: wheelhouse/nimblephysics-${{ env.VERSION }}-${{ matrix.PYTHON_VERSION_CODE }}-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-linux-aarch64]
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: wheelhouse
- name: Display structure of downloaded files before flattening
run: ls -R
working-directory: wheelhouse
- name: Flatten files
run: |
mkdir wheelhouse2
find wheelhouse -type f -exec mv {} wheelhouse2 \;
rm -rf wheelhouse
mv wheelhouse2 wheelhouse
- name: Display structure of downloaded files after flattening
run: ls -R
working-directory: wheelhouse
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
skip_existing: true
verbose: true