-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BLD: Initial linux wheel build setup (#5)
* BLD: Initial wheel build setup * Use standalone build mode * Add release job * Add `mlir_c_runner_utils` shared lib * Add ccache * Restore original `python/CMakeLists.txt` * Build only unversioned libraries * Build package for multiple OSes * `cibuildwheel` initial setup * Enable multiple python versions * Enable macos jobs * Remove micromamba step * Change macos 13 to 12 * Try ubuntu and macos together * Add wheel test step * Troubleshoot ubuntu * Reset time for ccache * Small cleanup * Prepare PR for merging
- Loading branch information
Showing
8 changed files
with
385 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: Wheel | ||
|
||
on: | ||
schedule: | ||
# At 09:00 on Monday. (see https://crontab.guru) | ||
- cron: '0 9 * * 1' | ||
|
||
defaults: | ||
run: | ||
shell: bash -leo pipefail {0} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-wheel: | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-24.04', 'macos-12', 'macos-14'] # TODO: 'windows-2022' | ||
arch: ['x86_64', 'aarch64'] | ||
python: ['3.10'] | ||
exclude: | ||
- os: 'ubuntu-24.04' # TODO: needs qemu setup | ||
arch: 'aarch64' | ||
- os: 'macos-12' | ||
arch: 'aarch64' | ||
- os: 'macos-14' | ||
arch: 'x86_64' | ||
- os: 'windows-2022' | ||
arch: 'aarch64' | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout Finch-mlir | ||
uses: actions/checkout@v4 | ||
with: | ||
path: 'Finch-mlir' | ||
|
||
- name: Checkout LLVM | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: llvm/llvm-project | ||
ref: '4091bc61e315f187829dca877dd908a07ba9cb91' # Latest commit as of 2024-10-17 | ||
path: 'llvm-project' | ||
|
||
- name: Setup ccache | ||
uses: hendrikmuhs/ccache-action@v1 | ||
with: | ||
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }} | ||
max-size: "1G" | ||
verbose: 2 | ||
variant: ccache | ||
|
||
- name: Configure ccache - ubuntu & macos | ||
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') | ||
shell: bash | ||
run: | | ||
if [ x"${{ contains(matrix.os, 'macos') }}" == x"true" ]; then | ||
echo "/usr/local/opt/ccache/libexec:/opt/homebrew/opt/ccache/libexec" >> $GITHUB_PATH | ||
else | ||
echo "/usr/lib/ccache:/usr/lib64/ccache:/usr/lib/ccache/bin" >> $GITHUB_PATH | ||
fi | ||
- name: Configure ccache | ||
shell: bash | ||
run: | | ||
ccache -p | ||
ccache -z | ||
# See https://github.com/hendrikmuhs/ccache-action/issues/146 | ||
ccache --set-config=compiler_check=content | ||
ccache --set-config=sloppiness=locale,time_macros | ||
- name: pip install standard tools | ||
shell: bash | ||
run: pip install cibuildwheel wheel | ||
|
||
- name: Set env variables | ||
run: | | ||
echo "HOST_CCACHE_DIR="$(ccache --get-config cache_dir)"" >> $GITHUB_ENV | ||
- name: set env variables - macos | ||
if: contains(matrix.os, 'macos') | ||
shell: bash | ||
run: | | ||
echo "MACOSX_DEPLOYMENT_TARGET=11.0" | tee -a $GITHUB_ENV | ||
- name: cibuildwheel run | ||
run: | | ||
mv ./Finch-mlir/setup.py . | ||
mv ./Finch-mlir/pyproject.toml . | ||
cibuildwheel --output-dir ./wheelhouse | ||
ccache -s | ||
- name: Reset datetime ccache | ||
# find: The environment is too large for exec(). | ||
if: ${{ !contains(matrix.os, 'windows') }} | ||
run: | | ||
ccache --print-stats | ||
find $HOST_CCACHE_DIR -exec touch -a -m -t 197001010000 {} \; | ||
- name: Upload wheel | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: wheelhouse/*.whl | ||
name: artifact_finch_mlir-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.python }} | ||
|
||
release-wheel: | ||
runs-on: 'ubuntu-latest' | ||
needs: build-wheel | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- name: Download all artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: artifact_finch_mlir-* | ||
path: wheelhouse | ||
merge-multiple: true | ||
|
||
- name: Create release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: 'wheelhouse/*.whl' | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: latest | ||
name: latest | ||
body: Latest release | ||
removeArtifacts: false | ||
allowUpdates: true | ||
replacesArtifacts: true | ||
makeLatest: true | ||
artifactErrorsFailBuild: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/build | ||
.vscode/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
add_subdirectory(CAPI) | ||
add_subdirectory(Finch) | ||
|
||
install(IMPORTED_RUNTIME_ARTIFACTS mlir_c_runner_utils | ||
LIBRARY DESTINATION lib | ||
) | ||
install(IMPORTED_RUNTIME_ARTIFACTS mlir_float16_utils | ||
LIBRARY DESTINATION lib | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel", | ||
"ninja", | ||
"cmake>=3.12", | ||
"pybind11>=2.10.4", | ||
"numpy", | ||
"PyYAML", | ||
] | ||
|
||
[tool.cibuildwheel] | ||
build-verbosity = 1 | ||
test-requires = [ | ||
"pytest", | ||
"pytest-cov", | ||
"PyYAML", | ||
"scipy", | ||
"sparse@git+https://github.com/pydata/sparse@updated-llvm-nightly-test" | ||
] | ||
test-command = "SPARSE_BACKEND=MLIR pytest --pyargs sparse.mlir_backend" | ||
|
||
[tool.cibuildwheel.linux] | ||
build = "cp310-* cp311-* cp312-*" | ||
skip = ["*-manylinux_i686", "*-musllinux*"] | ||
environment = { PATH = "/usr/lib/ccache:/usr/lib64/ccache:/usr/lib/ccache/bin:$PATH" } | ||
before-build = [ | ||
"pip install -r {project}/Finch-mlir/requirements/requirements.txt", | ||
"{project}/Finch-mlir/scripts/docker_prepare_ccache.sh" | ||
] | ||
environment-pass = ["HOST_CCACHE_DIR"] | ||
|
||
[tool.cibuildwheel.macos] | ||
build = "cp310-* cp311-* cp312-*" | ||
environment = { PATH = "/usr/local/opt/ccache/libexec:$PATH" } | ||
before-build = [ | ||
"pip install -r {project}/Finch-mlir/requirements/requirements.txt", | ||
] | ||
repair-wheel-command = [ | ||
"delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies" | ||
] | ||
|
||
[tool.cibuildwheel.windows] | ||
build = "cp310-* cp311-* cp312-*" | ||
before-build = [ | ||
"pip install delvewheel", | ||
"pip install -r {project}/Finch-mlir/requirements/requirements.txt", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
setuptools>=42 | ||
wheel | ||
ninja | ||
cmake>=3.12 | ||
pybind11>=2.10.4 | ||
numpy | ||
PyYAML |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
set -xe | ||
|
||
# manylinux prep | ||
if [[ -f "/etc/centos-release" ]]; then | ||
yum install -y epel-release | ||
# sometimes the epel server is down. retry 5 times | ||
for i in $(seq 1 5); do | ||
yum install -y curl-devel expat-devel libpng-devel ccache wget ninja-build git && s=0 && break || s=$? && sleep 15 | ||
done | ||
|
||
[ $s -eq 0 ] || exit $s | ||
|
||
if [[ -d "/usr/lib64/ccache" ]]; then | ||
[ ! -f "/usr/lib64/ccache/c++" ] && ln -s /usr/bin/ccache /usr/lib64/ccache/c++ | ||
[ ! -f "/usr/lib64/ccache/cc" ] && ln -s /usr/bin/ccache /usr/lib64/ccache/cc | ||
[ ! -f "/usr/lib64/ccache/gcc" ] && ln -s /usr/bin/ccache /usr/lib64/ccache/gcc | ||
[ ! -f "/usr/lib64/ccache/g++" ] && ln -s /usr/bin/ccache /usr/lib64/ccache/g++ | ||
export PATH="/usr/lib64/ccache:$PATH" | ||
elif [[ -d "/usr/lib/ccache" ]]; then | ||
[ ! -f "/usr/lib/ccache/c++" ] && ln -s /usr/bin/ccache /usr/lib/ccache/c++ | ||
[ ! -f "/usr/lib/ccache/cc" ] && ln -s /usr/bin/ccache /usr/lib/ccache/cc | ||
[ ! -f "/usr/lib/ccache/gcc" ] && ln -s /usr/bin/ccache /usr/lib/ccache/gcc | ||
[ ! -f "/usr/lib/ccache/g++" ] && ln -s /usr/bin/ccache /usr/lib/ccache/g++ | ||
export PATH="/usr/lib/ccache:$PATH" | ||
fi | ||
|
||
elif [[ -f "/etc/alpine-release" ]]; then | ||
# musllinux prep | ||
# ccache already present | ||
apk add curl-dev expat-dev libpng-dev ccache | ||
export PATH="/usr/lib/ccache/bin:$PATH" | ||
fi | ||
|
||
# hack until https://github.com/pypa/cibuildwheel/issues/1030 is fixed | ||
HOST_CCACHE_DIR="/host${HOST_CCACHE_DIR:-/home/runner/work/Finch-mlir/Finch-mlir/.ccache}" | ||
ccache -o cache_dir="$HOST_CCACHE_DIR" | ||
ccache -M 5 1 | ||
# Show ccache stats | ||
echo "Cache stats:" | ||
ccache --show-stats |
Oops, something went wrong.