Skip to content

Commit 9aa668e

Browse files
authored
Allow build package to build M1 wheels (#5729)
This PR enable the build of M1 wheels to rely on `python -m build` instead of `python setup.py`. The default is still `python setup.py`. This is the same as #5071 and #5076 that were landed for linux wheels. We need this for torchcodec to support M1 wheels pytorch/torchcodec#230 CC @scotts @atalman
1 parent a73eb0b commit 9aa668e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/build_wheels_macos.yml

+31-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ on:
3939
description: "Name of the actual python package that is imported"
4040
default: ""
4141
type: string
42+
build-platform:
43+
description: Platform to build wheels, choose from 'python-build-package' or 'setup-py'
44+
required: false
45+
type: string
46+
default: 'setup-py'
47+
build-command:
48+
description: The build command to use if build-platform is python-build-package
49+
required: false
50+
default: "python -m build --wheel"
51+
type: string
4252
env-var-script:
4353
description: "Script that sets Domain-Specific Environment Variables"
4454
default: ""
@@ -156,7 +166,27 @@ jobs:
156166
# shellcheck disable=SC1090
157167
source "${BUILD_ENV_FILE}"
158168
${CONDA_RUN} python3 setup.py clean
159-
- name: Build the wheel (bdist_wheel)
169+
- name: Build the wheel (python-build-package)
170+
if: ${{ inputs.build-platform == 'python-build-package' }}
171+
working-directory: ${{ inputs.repository }}
172+
shell: bash -l {0}
173+
run: |
174+
set -euxo pipefail
175+
# shellcheck disable=SC1090
176+
source "${BUILD_ENV_FILE}"
177+
178+
if [[ "${{ inputs.package-name }}" = "torchaudio" ]]; then
179+
export USE_OPENMP="0"
180+
fi
181+
PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//')"
182+
export PYTORCH_VERSION
183+
184+
${CONDA_RUN} python -m pip install build
185+
echo "Successfully installed Python build package"
186+
187+
${CONDA_RUN} ${{ inputs.build-command }}
188+
- name: Build the wheel (setup-py)
189+
if: ${{ inputs.build-platform == 'setup-py' }}
160190
working-directory: ${{ inputs.repository }}
161191
run: |
162192
set -euxo pipefail

0 commit comments

Comments
 (0)