From d3cebb0ad41b49619e40e5b737877e0dfe5d48b3 Mon Sep 17 00:00:00 2001 From: Alex Lopez Date: Fri, 19 Jan 2024 11:31:06 +0100 Subject: [PATCH] Split builder setup and actual build and make the former optional --- .builders/build.py | 25 +++++++++++++++++-- .../macos/{build.sh => builder_setup.sh} | 14 ----------- .github/workflows/build-deps-macos.yml | 4 ++- 3 files changed, 26 insertions(+), 17 deletions(-) rename .builders/images/macos/{build.sh => builder_setup.sh} (89%) diff --git a/.builders/build.py b/.builders/build.py index 564d5e06e4e49e..73de9fd6000464 100644 --- a/.builders/build.py +++ b/.builders/build.py @@ -70,7 +70,9 @@ def build_macos(): parser.add_argument('output_dir') parser.add_argument('--python', default='3') parser.add_argument('--cache-dir', - help='Path to directory to load or save a build cache.') + help='Path to directory to load or save a build environment cache.') + parser.add_argument('--skip-setup', default=False, + help='Skip builder setup, assuming it has already been set up.') args = parser.parse_args() context_path = HERE / 'images' / 'macos' @@ -91,13 +93,32 @@ def build_macos(): shutil.copytree(HERE / 'scripts', mount_dir / 'scripts') shutil.copytree(HERE / 'patches', mount_dir / 'patches') + prefix_path = mount_dir / 'prefix' env = { **os.environ, 'DD_PREFIX_CACHE': args.cache_dir or '', 'DD_MOUNT_DIR': mount_dir, + # Paths to pythons + 'DD_PY3_BUILDENV_PATH': mount_dir / 'py3' / 'bin' / 'python', + 'DD_PY2_BUILDENV_PATH': mount_dir / 'py2' / 'bin' / 'python', + # Path where we'll install libraries that we build + 'DD_PREFIX_PATH': prefix_path, + # Common compilation flags + 'LDFLAGS': f'-Wl,-rpath,{prefix_path}/lib -L{prefix_path}/lib', + 'CFLAGS': f'-I{prefix_path}/include -O2', + # Build command for extra platform-specific build steps + 'DD_BUILD_COMMAND': f'bash {mount_dir}/extra_build.sh' } + + if not args.skip_setup: + check_process( + ['bash', str(HERE / 'images' / 'macos' / 'builder_setup.sh')], + env=env, + cwd=build_context_dir, + ) + check_process( - ['bash', str(HERE / 'images' / 'macos' / 'build.sh'), '--python', args.python], + [os.environ['DD_PYTHON3'], str(mount_dir / 'scripts' / 'build_wheels.py'), '--python', args.python], env=env, cwd=build_context_dir, ) diff --git a/.builders/images/macos/build.sh b/.builders/images/macos/builder_setup.sh similarity index 89% rename from .builders/images/macos/build.sh rename to .builders/images/macos/builder_setup.sh index a02b694db653a1..3987092b5079b8 100644 --- a/.builders/images/macos/build.sh +++ b/.builders/images/macos/builder_setup.sh @@ -2,24 +2,13 @@ set -euxo pipefail -export MACOSX_DEPLOYMENT_TARGET="10.12" - "${DD_PYTHON3}" -m pip install --no-warn-script-location --upgrade pip "${DD_PYTHON3}" -m pip install --no-warn-script-location virtualenv "${DD_PYTHON3}" -m virtualenv py3 -export DD_PY3_BUILDENV_PATH="$(pwd)/py3/bin/python" "${DD_PYTHON2}" -m pip install --no-warn-script-location --upgrade pip "${DD_PYTHON2}" -m pip install --no-warn-script-location virtualenv "${DD_PYTHON2}" -m virtualenv py2 -export DD_PY2_BUILDENV_PATH="$(pwd)/py2/bin/python" - -# Path where we'll install libraries that we build -export DD_PREFIX_PATH="$(pwd)/prefix" - -export LDFLAGS="-Wl,-rpath,${DD_PREFIX_PATH}/lib -L${DD_PREFIX_PATH}/lib" -export CFLAGS="-I${DD_PREFIX_PATH}/include -O2" -export PATH="${DD_PREFIX_PATH}/bin:${PATH}" "${DD_PYTHON3}" -m pip install --no-warn-script-location -r "runner_dependencies.txt" @@ -125,6 +114,3 @@ else fi fi -export DD_BUILD_COMMAND="bash $(pwd)/extra_build.sh" - -"${DD_PYTHON3}" "${DD_MOUNT_DIR}/scripts/build_wheels.py" "$@" diff --git a/.github/workflows/build-deps-macos.yml b/.github/workflows/build-deps-macos.yml index 729753ea68356e..b1660f0b4f3020 100644 --- a/.github/workflows/build-deps-macos.yml +++ b/.github/workflows/build-deps-macos.yml @@ -34,7 +34,9 @@ jobs: env: DD_PYTHON3: "/Library/Frameworks/Python.framework/Versions/3.11/bin/python3" DD_PYTHON2: "/Library/Frameworks/Python.framework/Versions/2.7/bin/python" + # This sets the minimum mac os version compatible for all built artifacts + MACOSX_DEPLOYMENT_TARGET: "10.12" run: | ${DD_PYTHON3} -m pip install packaging ${DD_PYTHON3} .builders/build.py --python 3 out_py3 - ${DD_PYTHON3} .builders/build.py --python 2 out_py2 + ${DD_PYTHON3} .builders/build.py --skip-setup --python 2 out_py2