Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
367 changes: 367 additions & 0 deletions requirements-build.txt

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions scripts/build_linux_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DEFAULT_PYTHON_VERSION="3.10"
DOCKERFILE=$(realpath "$scriptDir/resources/package_for_linux/Dockerfile")
DEFAULT_DOCKER_IMAGE_NAME="pyexiv2bind_builder"
OUTPUT_PATH="$PROJECT_ROOT/dist"
BUILD_CONSTRAINTS="$PROJECT_ROOT/requirements-build.txt"

arch=$(uname -m)

Expand Down Expand Up @@ -68,11 +69,11 @@ generate_wheel(){
-v "$PROJECT_ROOT":/project:ro \
-v "$OUTPUT_PATH":/dist \
"$docker_image_name_to_use" \
build-wheel /project /dist "${python_versions_to_use[@]}"
build-wheel /project /dist "${python_versions_to_use[@]}" --build-constraints="requirements-build.txt"
echo "Built wheel can be found in '$OUTPUT_PATH'"
}
print_usage(){
echo "Usage: $0 [--project-root[=PROJECT_ROOT]] [--python-version[=PYTHON_VERSION]] [--help]"
echo "Usage: $0 [--project-root[=PROJECT_ROOT]] [--python-version[=PYTHON_VERSION]] [--build-constraints[=PATH]] [--help]"
}
#
show_help() {
Expand All @@ -84,6 +85,7 @@ show_help() {
echo " --python-version : Version of Python wheel to build. This can be specified "
echo " multiple times to build for multiple versions. "
echo " Defaults to \"$DEFAULT_PYTHON_VERSION\". "
echo " --build-constraints: Optional path to a constraints file passed to uv build. "
echo " --platform : Platform to build the wheel for. "
echo " Defaults to \"$DEFAULT_PLATFORM\". "
echo " --docker-image-name "
Expand Down Expand Up @@ -164,6 +166,14 @@ while [[ "$#" -gt 0 ]]; do
PLATFORM="$2"
shift 2
;;
--build-constraints=*)
BUILD_CONSTRAINTS="${1#*=}"
shift
;;
--build-constraints)
BUILD_CONSTRAINTS="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
show_help
Expand Down
16 changes: 14 additions & 2 deletions scripts/build_mac_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PROJECT_ROOT=$(realpath "$scriptDir/..")
DEFAULT_PYTHON_VENV="./wheel_builder_venv"
DEFAULT_BASE_PYTHON="python3"
DEFAULT_PYTHON_VERSION=3.10
BUILD_CONSTRAINTS="$PROJECT_ROOT/requirements-build.txt"

remove_venv(){
if [ -d $1 ]; then
echo "removing $1"
Expand Down Expand Up @@ -54,7 +56,7 @@ generate_wheel(){
output_path="./dist"
echo "Building wheel for Python $python_version on macOS $processor_type"
trap 'rm -rf "$out_temp_wheels_dir"' ERR SIGINT SIGTERM RETURN
_PYTHON_HOST_PLATFORM=$_PYTHON_HOST_PLATFORM MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET ARCHFLAGS=$ARCHFLAGS $uv_exec build --wheel --out-dir=$out_temp_wheels_dir --python=$python_version $project_root
_PYTHON_HOST_PLATFORM=$_PYTHON_HOST_PLATFORM MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET ARCHFLAGS=$ARCHFLAGS $uv_exec build --build-constraints="$BUILD_CONSTRAINTS" --wheel --out-dir=$out_temp_wheels_dir --python=$python_version $project_root
pattern="$out_temp_wheels_dir/*.whl"
files=( "$pattern" )
undelocate_wheel="${files[0]}"
Expand All @@ -70,7 +72,7 @@ generate_wheel(){


print_usage(){
echo "Usage: $0 [--uv path] [--python-version version]"
echo "Usage: $0 [--uv path] [--python-version version] [--build-constraints path]"
}


Expand All @@ -80,6 +82,7 @@ show_help() {
echo "Arguments:"
echo " --uv[=path] Path to uv executable. If not provided, defaults to 'uv' and if that is missing, a copy will be downloaded."
echo " --python-version[=version] Python version to generate wheel for. Default is $DEFAULT_PYTHON_VERSION."
echo " --build-constraints[=path] Optional path to a constraints file passed to uv build. Default is $BUILD_CONSTRAINTS."
echo " --help, -h Display this help message."
}

Expand Down Expand Up @@ -114,6 +117,15 @@ while [[ "$#" -gt 0 ]]; do
shift 2
;;

--build-constraints=*)
BUILD_CONSTRAINTS="${1#*=}"
shift
;;
--build-constraints)
BUILD_CONSTRAINTS="$2"
shift 2
;;

*)
shift
;;
Expand Down
58 changes: 53 additions & 5 deletions scripts/resources/package_for_linux/scripts/build-wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ REMOVE_FILES_FIRST=(\
)

print_usage(){
echo "Usage: $0 SOURCE_DIRECTORY OUTPUT_DIRECTORY PYTHON_VERSION [PYTHON_VERSION...] [--help]"
echo "Usage: $0 SOURCE_DIRECTORY OUTPUT_DIRECTORY PYTHON_VERSION [PYTHON_VERSION...] [--build-constraints=PATH] [--help]"
}

show_help() {
print_usage
echo " SOURCE_DIRECTORY : path to project source code. "
echo " OUTPUT_DIRECTORY : path to create wheel files. "
echo " PYTHON_VERSION : Python version to generate wheel file for. "
echo " --build-constraints: Optional path to a constraints file used building wheel. "
echo " "
echo " --help, -h : Display this help message. "
}
Expand Down Expand Up @@ -84,6 +85,8 @@ make_wheels() {
local build_constraints=$3
local python_versions=("${@:4}")
local output_manifest
echo "project_directory = $project_directory"
# exit 1
output_manifest="$(mktemp)"
touch output_manifest
mkdir -p "$dist_directory"
Expand Down Expand Up @@ -118,14 +121,59 @@ fix_up_wheels(){
auditwheel show "$file"
done
}
for arg in "$@"; do
if [[ "$arg" == "--help" || "$arg" == "-h" ]]; then
show_help
exit 0
fi
done

if [[ $# -lt 2 ]]; then
echo "Error: SOURCE_DIRECTORY and OUTPUT_DIRECTORY are required."
print_usage
exit 1
fi

source_directory="$1"
output_directory="$2"
python_versions_to_use=("${@:3}")
shift 2

build_constraints=""
python_versions_to_use=()
while [[ $# -gt 0 ]]; do
case "$1" in
--build-constraints=*)
build_constraints="${1#*=}"
shift
;;
--build-constraints)
build_constraints="$2"
shift 2
;;
--help|-h)
show_help
exit 0
;;
*)
python_versions_to_use+=("$1")
shift
;;
esac
done

if [[ ${#python_versions_to_use[@]} -eq 0 ]]; then
echo "Error: at least one Python version is required."
print_usage
exit 1
fi

echo "Building wheels for Python versions: ${python_versions_to_use[*]}"
make_shadow_copy "$source_directory" "$WORKSPACE"
build_constraints=/tmp/constraints.txt
uv export --frozen --only-group dev --no-hashes --format requirements.txt --no-emit-project --no-annotate --directory "${WORKSPACE}" > $build_constraints
make_wheels "$WORKSPACE" "/tmp/dist" "${build_constraints}" "${python_versions_to_use[@]}"
if [[ -z "$build_constraints" ]]; then
build_constraints=/tmp/constraints.txt
uv export --frozen --only-group dev --no-hashes --format requirements.txt --no-emit-project --no-annotate --directory "${WORKSPACE}" > "$build_constraints"
fi
make_wheels "$WORKSPACE" "/tmp/dist" "${WORKSPACE}/${build_constraints}" "${python_versions_to_use[@]}"
verify_package_with_twine "/tmp/dist" "${source_directory}"
fix_up_wheels "/tmp/dist" "${output_directory}"
echo 'Done'
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function CreateNewWheel {
[string]$OutputDir

)
uv build --python=$PythonVersion --wheel --out-dir=$OutputDir --config-setting=conan_cache=$CONAN_CACHE_DIR --verbose $SourcePath
uv build --python=$PythonVersion --wheel --out-dir=$OutputDir --config-setting=conan_cache=$CONAN_CACHE_DIR --verbose $SourcePath --build-constraints="$SourcePath/requirements-build.txt"
if ($LASTEXITCODE -ne 0) {
throw "An error creating Wheel for Python version $PythonVersion."
}
Expand Down
Loading
Loading