Skip to content
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

Updates and fixes for the pyside 3P package on Linux #251

Merged
merged 15 commits into from
Apr 12, 2024
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
2 changes: 1 addition & 1 deletion Scripts/extras/package_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


# used if LY_PACKAGE_SERVER_URLS is not set.
DEFAULT_LY_PACKAGE_SERVER_URLS = "https://d2c171ws20a1rv.cloudfront.net"
DEFAULT_LY_PACKAGE_SERVER_URLS = "https://d2c171ws20a1rv.cloudfront.net;https://d3t6xeg4fgfoum.cloudfront.net"
spham-amzn marked this conversation as resolved.
Show resolved Hide resolved

possible_download_errors = (ssl.SSLError, URLError, OSError)

Expand Down
27 changes: 21 additions & 6 deletions package-system/pyside2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@
# for its dependencies
#

FROM public.ecr.aws/ubuntu/ubuntu:20.04_stable

WORKDIR /data/workspace
# The cpu architecture to base the docker base script from
ARG INPUT_ARCHITECTURE=amd64

# The root to base the docker script base from
ARG INPUT_IMAGE=ubuntu:20.04
amzn-changml marked this conversation as resolved.
Show resolved Hide resolved

ARG PYTHON_FOLDER_NAME
ARG QT_FOLDER_NAME
ARG DOCKER_BUILD_SCRIPT

FROM ${INPUT_ARCHITECTURE}/${INPUT_IMAGE}

ARG INPUT_ARCHITECTURE
ARG INPUT_IMAGE

ARG PYTHON_FOLDER_NAME
ARG QT_FOLDER_NAME
ARG DOCKER_BUILD_SCRIPT

WORKDIR /data/workspace

# Initilize apt cache
RUN apt-get clean && apt-get update

Expand All @@ -38,8 +51,8 @@ RUN apt-get install -y cmake \
llvm-12 \
git \
libgl1-mesa-dev \
libpcre2-dev

libpcre2-dev \
chrpath

RUN apt-get install -y libclang-12-dev

Expand All @@ -62,7 +75,7 @@ ENV LLVM_CONFIG=/usr/bin/llvm-config-12
# paths. To work around this and make it appear that the dependent 3P python package
# was installed in this docker sctructure, we will instead create a symlink from the
# 3p package's original path to the actual one mapped to the workspace path
RUN if [ "$(uname -m)" = "aarch64" ]; then \
RUN if [ "${INPUT_ARCHITECTURE}" = "aarch64" ]; then \
mkdir -p /home/ubuntu/github/3p-package-source/package-system/python/linux_aarch64/package && \
cd /home/ubuntu/github/3p-package-source/package-system/python/linux_aarch64/package && \
ln -s /data/workspace/${PYTHON_FOLDER_NAME}/python python; \
Expand All @@ -77,5 +90,7 @@ ARG CACHEBUST=1

COPY ${DOCKER_BUILD_SCRIPT} /data/workspace/
COPY src /data/workspace/src/
COPY ${PYTHON_FOLDER_NAME} /data/workspace/${PYTHON_FOLDER_NAME}/
COPY ${QT_FOLDER_NAME} /data/workspace/${QT_FOLDER_NAME}/

ENTRYPOINT ["/bin/bash"]
152 changes: 138 additions & 14 deletions package-system/pyside2/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,54 @@

# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script

if [ "$(uname -m)" = "aarch64" ]
# This script will utilize Docker to build on either AMD64 or AARCH64 architectures.


DOCKER_BUILD_SCRIPT=docker_build_linux.sh
TARGET_BUILD_FOLDER=build

#
# Collect the required arguments for this ubuntu docker-base build script
#

# Get the base docker image name
DOCKER_IMAGE_NAME_BASE=$1
if [ "${DOCKER_IMAGE_NAME_BASE}" == "" ]
then
PYTHON_FOLDER_NAME=python-3.10.5-rev2-linux-aarch64
QT_FOLDER_NAME=qt-5.15.2-rev8-linux-aarch64
else
PYTHON_FOLDER_NAME=python-3.10.5-rev2-linux
QT_FOLDER_NAME=qt-5.15.2-rev8-linux
echo "Missing argument 1: Docker image name for this this process"
exit 1
fi

DOCKER_BUILD_SCRIPT=docker_build_linux.sh
DOCKER_IMAGE_NAME=pyside2_linux_3p
PYSIDE2_TOOL_PATCH=pyside2-tools.patch
# Get the ubuntu base version (16.04|18.04|20.04|22.04)
UBUNTU_BASE=$2
if [ "${UBUNTU_BASE}" == "" ]
then
echo "Missing argument 2: Ubuntu docker tag"
exit 1
fi

# Determine the host architecture
CURRENT_HOST_ARCH=$(uname -m)

# Use the host architecture if not supplied
TARGET_ARCH=${3:-$(uname -m)}

# Recompute the DOWNLOADED_PACKAGE_FOLDERS to apply to $WORKSPACE/temp inside the Docker script
DEP_PACKAGES_FOLDERNAMES_ONLY=${DOWNLOADED_PACKAGE_FOLDERS//$TEMP_FOLDER\//}
DEP_PACKAGES_DOCKER_FOLDERNAMES=${DOWNLOADED_PACKAGE_FOLDERS//$TEMP_FOLDER/"/data/workspace/temp"}

echo "Executing docker-based build from the following arguments"
echo " DOCKER_IMAGE_NAME_BASE = ${DOCKER_IMAGE_NAME_BASE}"
echo " UBUNTU_BASE = ${UBUNTU_BASE}"
echo " DOCKER_BUILD_SCRIPT = ${DOCKER_BUILD_SCRIPT}"
echo " TARGET_BUILD_FOLDER = ${TARGET_BUILD_FOLDER}"
echo " TARGET_ARCH = ${TARGET_ARCH}"
echo " TEMP_FOLDER = ${TEMP_FOLDER}"
echo " DOWNLOADED_PACKAGE_FOLDERS = ${DEP_PACKAGES_FOLDERNAMES_ONLY}"

#
# Make sure docker is installed
#
DOCKER_VERSION=$(docker --version)
if [ $? -ne 0 ]
then
Expand All @@ -33,6 +66,82 @@ then
fi
echo "Detected Docker Version $DOCKER_VERSION"

#
# Check the target architecture and determine if the necessary cross compilation requirements are met
#

# If the host and target architecture does not match, make sure the necessary cross compilation packages are installed
if [ "${CURRENT_HOST_ARCH}" != ${TARGET_ARCH} ]
then
echo "Checking cross compiling requirements."
for package_check in docker-ce qemu binfmt-support qemu-user-static
do
echo "Checking package $package_check"
dpkg -s $package_check > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo ""
echo "Missing package $package_check. Make sure to install it with your local package manager."
echo ""
exit 1
fi
done

# Only cross compilation of an ARM64 image on an x86_64 host is supported
if [ "${TARGET_ARCH}" = "aarch64" ]
then
# Make sure qemu-aarch64 is installed properly
QEMU_AARCH_COUNT=$(update-binfmts --display | grep qemu-aarch64 | wc -l)
if [ $QEMU_AARCH_COUNT -eq 0 ]
then
echo ""
echo "QEMU aarch64 binary format not registered."
echo "Run the following command to register"
echo ""
echo "sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes"
echo ""
exit 1
fi
echo ""
echo "Cross compiling aarch64 on an amd64 machine validated."
echo ""
fi
else
echo "Building ${TARGET_ARCH} natively."
fi


# Setup the docker arguments
if [ "${TARGET_ARCH}" = "x86_64" ]
then
echo "Processing Docker for amd64"

DOCKER_INPUT_ARCHITECTURE=amd64
TARGET_DOCKER_PLATFORM_ARG=linux/amd64
PYTHON_FOLDER_NAME=python-3.10.13-rev2-linux
QT_FOLDER_NAME=qt-5.15.2-rev9-linux

elif [ "${TARGET_ARCH}" = "aarch64" ]
then
echo "Processing Docker for aarch64"

DOCKER_INPUT_ARCHITECTURE=arm64v8
TARGET_DOCKER_PLATFORM_ARG=linux/arm64/v8
PYTHON_FOLDER_NAME=python-3.10.13-rev2-linux-aarch64
QT_FOLDER_NAME=qt-5.15.2-rev9-linux-aarch64

else
echo "Unsupported architecture ${TARGET_ARCH}"
exit 1
fi

# Build the Docker Image
DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME_BASE}_${DOCKER_INPUT_ARCHITECTURE}_3p
echo DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}

DOCKER_IMAGE_NAME=pyside2_linux_3p
PYSIDE2_TOOL_PATCH=pyside2-tools.patch

echo "Using dependent 3rd Party Library ${PYTHON_FOLDER_NAME}"
echo "Using dependent 3rd Party Library ${QT_FOLDER_NAME}"

Expand All @@ -55,11 +164,25 @@ else
fi
popd

popd

# Build the Docker Image
echo "Building the docker build script"
echo "Building the docker build script for ${DOCKER_IMAGE_NAME_BASE} on ${DOCKER_INPUT_ARCHITECTURE} for Ubuntu $1"
echo ""

CMD_DOCKER_BUILD="\
docker build --build-arg INPUT_DOCKER_BUILD_SCRIPT=${DOCKER_BUILD_SCRIPT}\
--build-arg INPUT_ARCHITECTURE=${DOCKER_INPUT_ARCHITECTURE}\
--build-arg INPUT_IMAGE=ubuntu:${UBUNTU_BASE}\
--build-arg PYTHON_FOLDER_NAME=\"${PYTHON_FOLDER_NAME}\"\
--build-arg QT_FOLDER_NAME=\"${QT_FOLDER_NAME}\"\
--build-arg DOCKER_BUILD_SCRIPT=\"${DOCKER_BUILD_SCRIPT}\"\
-f Dockerfile -t ${DOCKER_IMAGE_NAME}:latest temp"

echo "CWD=$(pwd)"
echo $CMD_DOCKER_BUILD
eval $CMD_DOCKER_BUILD

echo docker build --build-arg PYTHON_FOLDER_NAME=${PYTHON_FOLDER_NAME} --build-arg QT_FOLDER_NAME=${QT_FOLDER_NAME} --build-arg DOCKER_BUILD_SCRIPT=${DOCKER_BUILD_SCRIPT} -f ../Dockerfile -t ${DOCKER_IMAGE_NAME}:latest .
docker build --build-arg PYTHON_FOLDER_NAME=${PYTHON_FOLDER_NAME} --build-arg QT_FOLDER_NAME=${QT_FOLDER_NAME} --build-arg DOCKER_BUILD_SCRIPT=${DOCKER_BUILD_SCRIPT} -f ../Dockerfile -t ${DOCKER_IMAGE_NAME}:latest .
if [ $? -ne 0 ]
then
echo "Error occurred creating Docker image ${DOCKER_IMAGE_NAME}:latest."
Expand All @@ -77,8 +200,9 @@ fi

# Run the Docker Image
echo "Running build script in the docker image"
echo docker run -v $TEMP_FOLDER/src:/data/workspace/src -v $TEMP_FOLDER/$QT_FOLDER_NAME:/data/workspace/$QT_FOLDER_NAME -v $TEMP_FOLDER/$PYTHON_FOLDER_NAME:/data/workspace/$PYTHON_FOLDER_NAME --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/$DOCKER_BUILD_SCRIPT
docker run -v $TEMP_FOLDER/$QT_FOLDER_NAME:/data/workspace/$QT_FOLDER_NAME -v $TEMP_FOLDER/$PYTHON_FOLDER_NAME:/data/workspace/$PYTHON_FOLDER_NAME --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/$DOCKER_BUILD_SCRIPT

echo docker run -it --platform ${TARGET_DOCKER_PLATFORM_ARG} --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/$DOCKER_BUILD_SCRIPT
docker run --platform ${TARGET_DOCKER_PLATFORM_ARG} --tty ${DOCKER_IMAGE_NAME}:latest /data/workspace/$DOCKER_BUILD_SCRIPT
if [ $? -ne 0 ]
then
echo Failed to build from docker image ${DOCKER_IMAGE_NAME}:latest
Expand Down
24 changes: 15 additions & 9 deletions package-system/pyside2/build_config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"git_url": "https://code.qt.io/cgit/pyside/pyside-setup.git",
"git_url": "https://code.qt.io/pyside/pyside-setup",
"git_tag": "v5.15.2.1",
"package_name": "pyside2",
"package_version": "5.15.2.1-py3.10-rev4",
"package_version": "5.15.2.1-py3.10-rev7",
"package_url": "https://code.qt.io/cgit/pyside/pyside-setup.git",
amzn-changml marked this conversation as resolved.
Show resolved Hide resolved
"package_license": "custom",
"package_license_file": "pyside2/LICENSE.LGPLv3",
Expand Down Expand Up @@ -30,28 +30,34 @@
"Linux": {
"Linux": {
"depends_on_packages" :[
["python-3.10.5-rev2-linux", "eda1fdc9129fb70df2d63bd21d0876c83c4f7021864f22c85850f4a8ff8cf1bf", ""],
["qt-5.15.2-rev8-linux", "613d6a404b305ce0e715c57c936dc00318fb9f0d2d3f6609f8454c198f993095", ""]
["python-3.10.13-rev2-linux", "a7832f9170a3ac93fbe678e9b3d99a977daa03bb667d25885967e8b4977b86f8", ""],
["qt-5.15.2-rev9-linux", "db4bcd2003262f4d8c7d7da832758824fc24e53da5895edef743f67a64a5c734", ""]
],
"cmake_find_source": "Findpyside2.cmake",
"custom_build_cmd": [
"./build-linux.sh"
"./build-linux.sh",
"pyside2_5_15_2_1",
"20.04",
"x86_64"
],
"custom_install_cmd": [
"./package_linux.sh"
]
},
"Linux-aarch64": {
"depends_on_packages" :[
["python-3.10.5-rev2-linux-aarch64", "a02bfb612005af364872aac96e569cef1ad84ba65632d88d04b34a99d45b077c", ""],
["qt-5.15.2-rev8-linux-aarch64", "c437ee1c7a4fe84002352a2f8ed230c822a13dcc80735a4fecf3b3af6e34bb63", ""]
["python-3.10.13-rev2-linux-aarch64", "30bc2731e2ac54d8e22d36ab15e30b77aefe2dce146ef92d6f20adc0a9c5b14e", ""],
["qt-5.15.2-rev9-linux-aarch64", "da80840ecd3f7a074edecbb3dedb1ff36c568cfe4943e18d9559e9fca9f151bc", ""]
],
"cmake_find_source": "Findpyside2.cmake",
"custom_build_cmd": [
"./build-linux.sh"
"./build-linux.sh",
"pyside2_5_15_2_1",
"20.04",
"aarch64"
],
"custom_install_cmd": [
"./package_linux_aarch64.sh"
"./package_linux.sh"
]
}

Expand Down
76 changes: 0 additions & 76 deletions package-system/pyside2/build_linux_aarch64.sh

This file was deleted.

Loading
Loading