Skip to content

Commit

Permalink
Split builder setup and actual build and make the former optional
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezz committed Jan 19, 2024
1 parent a674904 commit bbee48b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
25 changes: 23 additions & 2 deletions .builders/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -91,13 +93,32 @@ def build_macos():
shutil.copytree(HERE / 'scripts', mount_dir / 'scripts')
shutil.copytree(HERE / 'patches', mount_dir / 'patches')

prefix_path = build_context_dir / 'prefix'
env = {
**os.environ,
'DD_PREFIX_CACHE': args.cache_dir or '',
'DD_MOUNT_DIR': mount_dir,
# Paths to pythons
'DD_PY3_BUILDENV_PATH': build_context_dir / 'py3' / 'bin' / 'python',
'DD_PY2_BUILDENV_PATH': build_context_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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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" "$@"
4 changes: 3 additions & 1 deletion .github/workflows/build-deps-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bbee48b

Please sign in to comment.