-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Onboard to cibuildwheel and improve macOS build #8754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#This is a cmake tool chain file to demonstrate how to do cross-compiling for Raspberry Pi OS 64-bit. However, most Raspberry users are using 32-bit operating systems. If you are the case, please adjust the settings accordingly before use. | ||
SET(CMAKE_SYSTEM_NAME Linux) | ||
SET(CMAKE_SYSTEM_PROCESSOR aarch64) | ||
SET(CMAKE_SYSTEM_VERSION 1) | ||
SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc-8) | ||
SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-8) | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
SET(CMAKE_FIND_ROOT_PATH /data/piroot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ | |
import argparse | ||
import collections | ||
import hashlib | ||
import pathlib | ||
import os | ||
import shlex | ||
import sys | ||
import shutil | ||
from logger import get_logger | ||
|
||
|
||
|
@@ -110,13 +112,36 @@ def update_hash_with_file(file_info: FileInfo, hash_obj): | |
hash_obj.update(read_bytes) | ||
|
||
|
||
# Return true if we need to copy manylinux build scripts to context_path | ||
def is_manylinux(dockerfile_path, context_path): | ||
ret = False | ||
with open(dockerfile_path, mode="r") as f: | ||
for index, line in enumerate(f): | ||
if line.strip() == "#Build manylinux2014 docker image begin": | ||
ret = True | ||
break | ||
return ret and not os.path.exists(os.path.join(context_path, 'manylinux-entrypoint')) | ||
|
||
|
||
def find_manylinux_scripts(dockerfile_path): | ||
for p in pathlib.Path(dockerfile_path).resolve().parents: | ||
print(p / 'manylinux-entrypoint') | ||
if (p / 'manylinux-entrypoint').exists(): | ||
return p | ||
return None | ||
|
||
|
||
def generate_tag(dockerfile_path, context_path, docker_build_args_str): | ||
hash_obj = hashlib.sha256() | ||
hash_obj.update(docker_build_args_str.encode()) | ||
update_hash_with_file( | ||
make_file_info_from_path(dockerfile_path), hash_obj) | ||
update_hash_with_directory( | ||
make_file_info_from_path(context_path), hash_obj) | ||
if is_manylinux(dockerfile_path, context_path): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the files were already under context_path, this manylinux-specific change wouldn't be needed |
||
p = find_manylinux_scripts(dockerfile_path) | ||
update_hash_with_file(make_file_info_from_path(p / 'manylinux-entrypoint'), hash_obj) | ||
update_hash_with_directory(make_file_info_from_path(p / 'build_scripts'), hash_obj) | ||
return "image_content_digest_{}".format(hash_obj.hexdigest()) | ||
|
||
|
||
|
@@ -156,6 +181,16 @@ def main(): | |
run(args.docker_path, "pull", full_image_name) | ||
else: | ||
log.info("Building image...") | ||
if is_manylinux(args.dockerfile, args.context): | ||
manyliux_script_root = find_manylinux_scripts(args.dockerfile) | ||
log.info("Copying manylinux scripts from %s to %s ..." % (manyliux_script_root, args.dockerfile)) | ||
shutil.copy(manyliux_script_root / 'manylinux-entrypoint', | ||
pathlib.Path(args.context) / 'manylinux-entrypoint') | ||
dest_build_scripts_dir = pathlib.Path(args.context) / 'build_scripts' | ||
shutil.copytree(manyliux_script_root / 'build_scripts', dest_build_scripts_dir) | ||
if not (dest_build_scripts_dir / 'fixup-mirrors.sh').exists(): | ||
log.error("File copy failed") | ||
return -1 | ||
run(args.docker_path, "build", | ||
"--pull", | ||
*shlex.split(args.docker_build_args), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could the extra files just be put in the correct place before calling this script? would prefer to keep this script generic and less complex if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I create a bash script which is invoked just before this python file, and that script copies the files. And add the script to get-docker-image-steps.yml. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that might be better.
I looked at the PR a bit more closely - could we continue passing tools/ci_build/github/linux/docker as the context directory and just access (e.g. COPY) longer relative paths from the Dockerfiles?
if we modify the checked in directory structure in the process of building, it's another step that people need to know about in order to understand where the files come from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is to avoid rebuild all the docker images unnecessarily, so it tries to restrict the files a Dockerfile can access.