Skip to content

Commit 83ea464

Browse files
authored
Switch to Python Build Standalone for macOS wheels (#21716)
This is a follow-up of: - #21692 ... where a review comment rightfully suggested that: > Instead, we should run a normal single-arch Python distribution where > everything will just work by default and we can remove the renaming > logic. The source of distributions should be the > [python-build-standalone](https://github.com/astral-sh/python-build-standalone) > project which the makers of UV recently adopted. They are used by > everyone nowadays, even > [rules_python](https://github.com/bazel-contrib/rules_python/blob/cf594f780c91f13d48e77faad34df48ac57398da/python/versions.bzl#L29). The present change aims at embracing the above-recommended approach, which looks indeed promising because the need for bundling targeted architectures is then addressed without additional environment variables, while still allowing `delocate_wheel` to verify architecture requirements. Also, the PBS distribution happens to be pretty lightweight (16MB vs 71MB).
1 parent 6d8718a commit 83ea464

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.builders/build.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ def build_macos():
124124
'LDFLAGS': f'-L{prefix_path}/lib',
125125
'CFLAGS': f'-I{prefix_path}/include -O2',
126126
'CXXFLAGS': f'-I{prefix_path}/include -O2',
127-
# Use single-arch builds to avoid bundling extraneous binary payload and enable `require_archs` verification
128-
'ARCHFLAGS': f'-arch {os.uname().machine}',
129-
'_PYTHON_HOST_PLATFORM': f'macosx-{os.environ["MACOSX_DEPLOYMENT_TARGET"]}-{os.uname().machine}',
130127
# Build command for extra platform-specific build steps
131128
'DD_BUILD_COMMAND': f'bash {build_context_dir}/extra_build.sh'
132129
}

.github/workflows/resolve-build-deps.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,21 @@ jobs:
206206
brew install coreutils
207207
208208
- name: Set up Python
209+
# Use PBS as suggested by: https://github.com/DataDog/integrations-core/pull/21692#pullrequestreview-3358660684
210+
# PBS stands for "Python Build Standalone": https://astral.sh/blog/python-build-standalone
209211
env:
210-
# Despite the name, this is built for the macOS 11 SDK on arm64 and 10.9+ on intel
211-
PYTHON3_DOWNLOAD_URL: "https://www.python.org/ftp/python/3.13.10/python-3.13.10-macos11.pkg"
212+
PYTHON_PATCH: 10
213+
PBS_RELEASE: 20251202
214+
PBS_SHA256__aarch64: 799a3b76240496e4472dd60ed0cd5197e04637bea7fa16af68caeb989fadcb3a
215+
PBS_SHA256__x86_64: 705b39dd74490c3e9b4beb1c4f40bf802b50ba40fe085bdca635506a944d5e74
212216
run: |
213-
curl "$PYTHON3_DOWNLOAD_URL" -o python3.pkg
214-
sudo installer -pkg python3.pkg -target /
217+
set -u
218+
curl -fsSL -o pbs.tgz "https://github.com/astral-sh/python-build-standalone/releases/download/$PBS_RELEASE/cpython-$PYTHON_VERSION.$PYTHON_PATCH+$PBS_RELEASE-${{ matrix.job.arch }}-apple-darwin-install_only_stripped.tar.gz"
219+
echo "$PBS_SHA256__${{ matrix.job.arch }} *pbs.tgz" | shasum -a 256 -c -
220+
prefix=$(dirname "$(dirname "$DD_PYTHON3")")
221+
sudo mkdir -p "$prefix"
222+
sudo tar -xzf pbs.tgz -C "$prefix" --strip-components=1
223+
rm pbs.tgz
215224
216225
- name: Checkout code
217226
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

0 commit comments

Comments
 (0)