Files
Jon CratonandGitHub c759a00915 Target generic CPUs when building Python package (#1596)
This change adjusts the configuration for Python package builds to
target "generic" CPUs rather than the native CPU of this build
system. This should produce wheels with maximum CPU compatibility.

Prior to this change, CPUs lacking features found on the build system
would fail to run the Python package properly and fail with an
"Illegal Instruction" error message.
2025-07-31 19:43:33 -04:00

64 lines
3.6 KiB
Bash

# MAC: Aarch64 Manylinux and OSX
docker build -t wheelmaker:latest -f Dockerfile.manylinux .
docker run --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.10
docker run --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.11
docker run --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.12
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.10
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.11
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.12
# Metal
MACOSX_DEPLOYMENT_TARGET=15.0 maturin build -o wheels-metal -m mistralrs-pyo3/Cargo.toml --interpreter python3.10 --features metal
MACOSX_DEPLOYMENT_TARGET=15.0 maturin build -o wheels-metal -m mistralrs-pyo3/Cargo.toml --interpreter python3.11 --features metal
MACOSX_DEPLOYMENT_TARGET=15.0 maturin build -o wheels-metal -m mistralrs-pyo3/Cargo.toml --interpreter python3.12 --features metal
# Accelerate
maturin build -o wheels-accelerate -m mistralrs-pyo3/Cargo.toml --interpreter python3.10 --features accelerate
maturin build -o wheels-accelerate -m mistralrs-pyo3/Cargo.toml --interpreter python3.11 --features accelerate
maturin build -o wheels-accelerate -m mistralrs-pyo3/Cargo.toml --interpreter python3.12 --features accelerate
# WINDOWS: x86_64 Manylinux, Windows
docker build -t wheelmaker:latest -f Dockerfile.manylinux .
docker run -e RUSTFLAGS="-C target-cpu=generic" --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.10
docker run -e RUSTFLAGS="-C target-cpu=generic" --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.11
docker run -e RUSTFLAGS="-C target-cpu=generic" --rm -v .:/io wheelmaker build --release -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.12
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.10
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.11
maturin build -o wheels-cpu -m mistralrs-pyo3/Cargo.toml --interpreter python3.12
# CUDA
maturin build -o wheels-cuda -m mistralrs-pyo3/Cargo.toml --interpreter python3.10 --features cuda
maturin build -o wheels-cuda -m mistralrs-pyo3/Cargo.toml --interpreter python3.11 --features cuda
maturin build -o wheels-cuda -m mistralrs-pyo3/Cargo.toml --interpreter python3.12 --features cuda
# MKL
maturin build -o wheels-mkl -m mistralrs-pyo3/Cargo.toml --interpreter python3.10 --features mkl
maturin build -o wheels-mkl -m mistralrs-pyo3/Cargo.toml --interpreter python3.11 --features mkl
maturin build -o wheels-mkl -m mistralrs-pyo3/Cargo.toml --interpreter python3.12 --features mkl
### UPLOADING
# ⚠️⚠️⚠️⚠️ Be sure to update the `project.name` field in `pyproject.toml`!! ⚠️⚠️⚠️⚠️
# mistralrs, mistralrs-cuda, mistralrs-metal, mistralrs-mkl, mistralrs-accelerate
## testpypi:
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-NAME/*.whl
## pypi:
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-cuda/*.whl
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-mkl/*.whl
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-cuda/*.whl
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-metal/*.whl
# ⚠️ Need both x86_64 and aarch64 builds before this! ⚠️
# twine upload --repository pypi --password PASSWORD --username __token__ wheels-cpu/*.whl