Skip to content

Wheels

Wheels #1333

Workflow file for this run

name: Wheels
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
release:
types:
- published
# Ensures Surelog/wheels are compatible with macOS 10.15+
env:
MACOSX_DEPLOYMENT_TARGET: "10.15"
jobs:
build_surelog:
name: Build Surelog for ${{ matrix.platform.os }} ${{ matrix.platform.arch}}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-latest
arch: aarch64
- os: macos-13
arch: universal
- os: windows-latest
arch: x86_64
steps:
- uses: actions/checkout@v4
# This facilitates building Linux+arm64 wheels
# https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
# Explicitly use "shell: bash" to make this work on Windows
- name: Get Surelog version
id: get-surelog
run: |
echo "version=$(python3 setup/_tools.py --tool surelog --field git-commit)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
id: surelog-cache
with:
path: |
siliconcompiler/tools/surelog/bin/surelog*
siliconcompiler/tools/surelog/lib/surelog/sv/builtin.sv
key: ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ steps.get-surelog.outputs.version }}
- name: Setup Java
if: (matrix.platform.os == 'macos-13' || matrix.platform.os == 'windows-latest') && steps.surelog-cache.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-package: jre
architecture: x64
- name: Setup Python
if: (matrix.platform.os == 'macos-13' || matrix.platform.os == 'windows-latest') && steps.surelog-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: 3.8
architecture: x64
cache: pip
- name: Build Surelog (Windows)
if: matrix.platform.os == 'windows-latest' && steps.surelog-cache.outputs.cache-hit != 'true'
run: |
.github/workflows/bin/install_surelog_win.bat
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
git config --system core.longpaths true
- name: Build Surelog (macOS)
if: matrix.platform.os == 'macos-13' && steps.surelog-cache.outputs.cache-hit != 'true'
run: .github/workflows/bin/install_surelog_macos.sh
- name: Build Surelog (Linux x86)
if: matrix.platform.os == 'ubuntu-latest' && matrix.platform.arch == 'x86_64'&& steps.surelog-cache.outputs.cache-hit != 'true'
uses: docker://quay.io/pypa/manylinux2014_x86_64:latest
with:
args: ./.github/workflows/bin/install_surelog_linux.sh
- name: Build Surelog (Linux arm64)
if: matrix.platform.os == 'ubuntu-latest' && matrix.platform.arch == 'aarch64' && steps.surelog-cache.outputs.cache-hit != 'true'
uses: docker://quay.io/pypa/manylinux2014_aarch64:latest
with:
args: ./.github/workflows/bin/install_surelog_linux.sh
build_wheels:
name: Wheels on ${{ matrix.platform.os }} ${{ matrix.platform.arch}} ${{ matrix.python-version }}
runs-on: ${{ matrix.platform.os }}
needs: build_surelog
strategy:
fail-fast: false
matrix:
python-version: [cp38, cp39, cp310, cp311, cp312]
platform:
- os: ubuntu-latest
arch: x86_64
- os: ubuntu-latest
arch: aarch64
- os: macos-13
arch: universal
- os: windows-latest
arch: x86_64
env:
CIBW_ARCHS_LINUX: ${{ matrix.platform.arch }}
steps:
- uses: actions/checkout@v4
# This facilitates building Linux+arm64 wheels
# https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
# Explicitly use "shell: bash" to make this work on Windows
- name: Get Surelog version
id: get-surelog
run: |
echo "version=$(python3 setup/_tools.py --tool surelog --field git-commit)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
id: surelog-cache
with:
path: |
siliconcompiler/tools/surelog/bin/surelog*
siliconcompiler/tools/surelog/lib/surelog/sv/builtin.sv
key: ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ steps.get-surelog.outputs.version }}
# We should be guaranteed a hit after build_surelog executes
- name: Verify Surelog cache hit
if: steps.surelog-cache.outputs.cache-hit != 'true'
run: exit 1
- name: Setup env (Windows)
if: matrix.platform.os == 'windows-latest'
run: |
choco install -y graphviz
.github/workflows/bin/install_klayout_win.bat
- name: Setup env (macOS)
if: matrix.platform.os == 'macos-13'
run: |
brew install graphviz
brew install --cask klayout
# https://github.com/ponty/PyVirtualDisplay/blob/master/.github/workflows/main.yml#L45
brew install --cask xquartz
echo "/opt/X11/bin" >> $GITHUB_PATH
mkdir -p /tmp/.X11-unix
sudo chmod 1777 /tmp/.X11-unix
sudo chown root /tmp/.X11-unix
- uses: pypa/cibuildwheel@v2.17
env:
CIBW_BEFORE_ALL_LINUX: >
src_path="{package}" {package}/.github/workflows/bin/setup_wheel_env_linux.sh
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD: ${{ matrix.python-version }}*
CIBW_SKIP: "pp* *win32 *i686 *-musllinux_*"
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_TEST_SKIP: "*_arm64"
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: >
pytest {package}/tests/ -m "not eda" &&
pytest {package}/tests/tools/test_surelog.py &&
pytest {package}/tests/flows/test_show.py -k "not openroad"
# On Linux, check if KL is installed before running show tests (not included for ARM64)
CIBW_TEST_COMMAND_LINUX:
pytest {package}/tests/ -m "not eda" &&
pytest {package}/tests/tools/test_surelog.py &&
if command -v klayout; then pytest {package}/tests/flows/test_show.py -k "not openroad"; fi
# "if: always()" ensures that we always upload any wheels that have
# been created, even if cibuildwheel action fails
- name: Upload wheels
if: always()
uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: siliconcompiler-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.python-version }}
retention-days: 14
publish:
needs: [build_wheels]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published' && !contains(github.event.release.body, 'NOPUBLISH')
steps:
- uses: actions/download-artifact@v4
with:
pattern: siliconcompiler-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@v1.8.14
with:
user: __token__
password: ${{ secrets.PYPI_DEPLOY }}
- name: Add wheels to GitHub release artifacts
uses: softprops/action-gh-release@v2
with:
files: dist/*.whl
package_offline:
# We want to run this on the official PEP Python-wheel building platform to
# ensure the downloaded wheels have the broadest compatibility. Using the
# '--platform' tag for 'pip download' doesn't work for us, since it requires
# setting --only-binary=:all: and some of our deps aren't available as
# wheels on some platforms.
needs: [build_wheels]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: [cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311, cp312-cp312]
steps:
- uses: actions/download-artifact@v4
with:
pattern: siliconcompiler-*
path: dist
merge-multiple: true
- name: Package SC
run: |
docker run --name sc_package -dit quay.io/pypa/manylinux2014_x86_64:latest
docker cp ./dist/siliconcompiler*${{matrix.python}}*linux*x86_64.whl sc_package:/
export wheel=$(docker exec sc_package bash -c "ls siliconcompiler*")
docker exec sc_package mkdir sc_dependencies
docker exec sc_package $python -m pip download pip -d sc_dependencies
docker exec sc_package $python -m pip download $wheel -d sc_dependencies
docker exec sc_package tar czvf sc_dependencies-${{matrix.python}}.tar.gz sc_dependencies $wheel
docker cp sc_package:sc_dependencies-${{matrix.python}}.tar.gz ./
docker stop sc_package
docker rm sc_package
env:
python: /opt/python/${{matrix.python}}/bin/python
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: sc_plus_dependencies-${{matrix.python}}
path: sc_dependencies*.tar.gz
retention-days: 14
- name: Add wheels to GitHub release artifacts
if: github.event_name == 'release' && github.event.action == 'published' && !contains(github.event.release.body, 'NOPUBLISH')
uses: softprops/action-gh-release@v2
with:
files: sc_dependencies*.tar.gz