From 8af1c3060226ccacf0ec37909f09f63b45d20b38 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sat, 19 Aug 2023 11:43:38 +0300 Subject: [PATCH] test --- Dockerfile | 44 +++++++++++++++++++ Dockerfile_x86_64 | 76 +++++++++++++++++++++++++++++++++ manylinux_x_y/Dockerfile_x86_64 | 40 ----------------- scripts/install_extra.sh | 7 +++ scripts/install_pipx.sh | 20 +++++++++ scripts/install_python.sh | 66 ++++++++++++++++++++++++++++ scripts/install_qt.sh | 5 +++ 7 files changed, 218 insertions(+), 40 deletions(-) create mode 100644 Dockerfile create mode 100644 Dockerfile_x86_64 delete mode 100644 manylinux_x_y/Dockerfile_x86_64 create mode 100644 scripts/install_extra.sh create mode 100755 scripts/install_pipx.sh create mode 100755 scripts/install_python.sh create mode 100755 scripts/install_qt.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f88df0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +FROM amd64/almalinux:8 as env + +ARG AQTINSTALL_VERSION=3.1.6 +ARG QT_VERSION=6.4.2 +ARG PYTHON_VERSION=3.9 + +RUN yum -y update \ + && yum -y groupinstall 'Development Tools' \ + && yum -y install \ + wget \ + openssl-devel \ + bzip2-devel \ + libffi-devel \ + cmake \ + clang \ + clang-devel \ + llvm \ + llvm-devel \ + mesa-libGL-devel \ + && dnf --enablerepo=powertools -y install ninja-build \ + && yum clean all \ + && rm -rf /var/cache/yum + +COPY ./scripts/install_python.sh ./scripts/install_pipx.sh ./scripts/install_qt.sh / +RUN /install_python.sh && rm -f /install_python.sh +RUN /install_pipx.sh && rm -f /install_pipx.sh +RUN pipx install aqtinstall==${AQTINSTALL_VERSION} +RUN /install_qt.sh && rm -f /install_qt.sh + +ENV PATH="/opt/Qt/${QT_VERSION}/gcc_64/bin:$PATH" + +RUN cd /opt \ + && git clone -b ${QT_VERSION} https://code.qt.io/pyside/pyside-setup.git \ + && cd pyside-setup \ + && pip3 install -r requirements.txt \ + && python3 setup.py build --parallel "$(nproc)" --limited-api yes \ + && mkdir -p /output \ + && export dir_name=qfpa-py${PYTHON_VERSION}-qt${QT_VERSION}-64bit-release \ + && tar czvf "/output/$dir_name.tar.gz" -C "./build/$dir_name/install" . + +RUN cd /opt/pyside-setup \ + && python3 setup.py build --parallel "$(nproc)" bdist_wheel --limited-api yes + +RUN cp /opt/pyside-setup/dist/* /output \ No newline at end of file diff --git a/Dockerfile_x86_64 b/Dockerfile_x86_64 new file mode 100644 index 0000000..18b09c3 --- /dev/null +++ b/Dockerfile_x86_64 @@ -0,0 +1,76 @@ +FROM amd64/almalinux:8 as env + +ARG AQTINSTALL_VERSION=3.1.6 +ARG QT_VERSION=6.4.2 +ARG PYTHON_VERSION=3.9 + +RUN yum -y update \ + && yum -y groupinstall 'Development Tools' \ + && yum -y install \ + wget \ + openssl-devel \ + bzip2-devel \ + libffi-devel \ + cmake \ + clang \ + clang-devel \ + llvm \ + llvm-devel \ + mesa-libGL-devel \ + && dnf --enablerepo=powertools -y install ninja-build \ + && yum clean all \ + && rm -rf /var/cache/yum + +# +COPY ./scripts/install_python.sh / +RUN \ + chmod +x /install_python.sh \ + && /install_python.sh \ + && rm -f /install_python.sh +# + +# +COPY ./scripts/install_pipx.sh / +RUN \ + chmod +x /install_pipx.sh \ + && /install_pipx.sh \ + && rm -f /install_pipx.sh +# + +# +RUN pipx install aqtinstall==${AQTINSTALL_VERSION} +COPY ./scripts/install_qt.sh / +RUN \ + chmod +x /install_qt.sh \ + && /install_qt.sh \ + && rm -f /install_qt.sh +# + +ENV PATH="/opt/Qt/${QT_VERSION}/gcc_64/bin:$PATH" + +RUN \ + ln -s $(which python3) /usr/local/bin/python \ + && ln -s $(which pip3) /usr/local/bin/pip + +RUN python3 -m pip install wheel setuptools + +COPY ./scripts/install_extra.sh / +RUN \ + chmod +x /install_extra.sh \ + && /install_extra.sh \ + && rm -f /install_extra.sh + +ENV PYSIDE_INSTALL_DIR="/usr/local" + +RUN git clone --recurse-submodules https://github.com/python-LimeReport/python-LimeReport \ + && cd python-LimeReport + +RUN pip install \ + --extra-index-url=https://python-limereport.github.io/pypi/ \ + --trusted-host python-limereport.github.io \ + shiboken6==${QT_VERSION} pyside6==${QT_VERSION} shiboken6_generator==${QT_VERSION} + +RUN \ + export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) \ + && cd python-LimeReport \ + && python -m pip wheel . --no-deps \ No newline at end of file diff --git a/manylinux_x_y/Dockerfile_x86_64 b/manylinux_x_y/Dockerfile_x86_64 deleted file mode 100644 index 3bcafd8..0000000 --- a/manylinux_x_y/Dockerfile_x86_64 +++ /dev/null @@ -1,40 +0,0 @@ -FROM quay.io/pypa/manylinux_2_28_x86_64 as env - -ARG AQTINSTALL_VERSION=3.1.6 -ARG QT_VERSION=6.4.0 -ARG PYTHON_VERSION=3.8 - -ENV PATH="/opt/python/cp38-cp38/bin:$PATH" - -RUN yum -y update \ - && yum -y groupinstall 'Development Tools' \ - && yum -y install cmake make ninja-build \ - && yum clean all \ - && rm -rf /var/cache/yum - -RUN pipx install aqtinstall==${AQTINSTALL_VERSION} \ - && cd ~ \ - && aqt install-qt --outputdir /opt/Qt linux desktop ${QT_VERSION} - -ENV PATH="/opt/Qt/${QT_VERSION}/gcc_64/bin:$PATH" - -RUN pip install \ - --index-url=https://download.qt.io/official_releases/QtForPython/ \ - --trusted-host download.qt.io \ - shiboken6 pyside6 shiboken6_generator - -# RUN cd /opt \ -# && git clone --depth 1 https://github.com/python-LimeReport/python-LimeReport.git \ -# && cd python-LimeReport \ -# && python -m pip wheel . --wheel-dir=/tmp/cibuildwheel/built_wheel --no-deps - - -# -# RUN cd /opt \ -# && git clone -b ${QT_VERSION} --single-branch --depth 1 https://code.qt.io/pyside/pyside-setup.git \ -# && cd pyside-setup \ -# && pip install -r requirements.txt \ -# && python setup.py build --qtpaths=/opt/Qt/${QT_VERSION}/gcc_64/bin/qtpaths --parallel $(nproc) bdist_wheel --limited-api yes \ -# && pip install dist/*.whl - -# ENV PYSIDE_INSTALL_DIR="/opt/pyside-setup/build/qfpa-py${PYTHON_VERSION}-qt${QT_VERSION}-64bit-release/install" \ No newline at end of file diff --git a/scripts/install_extra.sh b/scripts/install_extra.sh new file mode 100644 index 0000000..f82b201 --- /dev/null +++ b/scripts/install_extra.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +PYTHON_PLATFORM=$(python3 -c "from packaging.tags import sys_tags; print(next(sys_tags()).platform.lower().replace(\"-\", \"_\").replace(\".\", \"_\").replace(\" \", \"_\"))") + +echo "platform: $PYTHON_PLATFORM" + +curl -L https://github.com/python-LimeReport/pyside6/releases/download/py${PYTHON_VERSION}-qt${QT_VERSION}/extra-$PYTHON_PLATFORM.tar.gz | tar -h -zx -C /usr/local \ No newline at end of file diff --git a/scripts/install_pipx.sh b/scripts/install_pipx.sh new file mode 100755 index 0000000..83811a5 --- /dev/null +++ b/scripts/install_pipx.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +python3 -m pip install pipx +python3 -m pipx ensurepath + +source "$HOME/.bashrc" + +# +# cat < /usr/local/bin/pipx +# #!/bin/bash +# +# set -euo pipefail +# +# if [ \$(id -u) -eq 0 ]; then +# export PIPX_HOME=/opt/_internal/pipx +# export PIPX_BIN_DIR=/usr/local/bin +# fi +# ${TOOLS_PATH}/bin/pipx "\$@" +# EOF +# chmod 755 /usr/local/bin/pipx \ No newline at end of file diff --git a/scripts/install_python.sh b/scripts/install_python.sh new file mode 100755 index 0000000..326f31f --- /dev/null +++ b/scripts/install_python.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +PYTHON_INSTALL_PATH="${INSTALLPATH:-"/usr/local/python"}" +CURRENT_PATH="${PYTHON_INSTALL_PATH}/current" + +find_version_from_git_tags() { + local variable_name=$1 + local requested_version=${!variable_name} + if [ "${requested_version}" = "none" ]; then return; fi + local repository=$2 + local prefix=${3:-"tags/v"} + local separator=${4:-"."} + local last_part_optional=${5:-"false"} + if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then + local escaped_separator=${separator//./\\.} + local last_part + if [ "${last_part_optional}" = "true" ]; then + last_part="(${escaped_separator}[0-9]+)?" + else + last_part="${escaped_separator}[0-9]+" + fi + local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$" + local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)" + if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then + declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)" + else + set +e + declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" + set -e + fi + fi + if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then + echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2 + exit 1 + fi + echo "${variable_name}=${!variable_name}" +} + +add_symlink() { + if [[ ! -d "${CURRENT_PATH}" ]]; then + ln -s -r "${INSTALL_PATH}" "${CURRENT_PATH}" + fi + + if [ "${OVERRIDE_DEFAULT_VERSION}" = "true" ]; then + if [[ $(ls -l ${CURRENT_PATH}) != *"-> ${INSTALL_PATH}"* ]] ; then + rm "${CURRENT_PATH}" + ln -s -r "${INSTALL_PATH}" "${CURRENT_PATH}" + fi + fi +} + +VERSION="3.9" + +find_version_from_git_tags VERSION "https://github.com/python/cpython" + +mkdir -p /tmp/python-src +cd /tmp/python-src +tgz_filename="Python-${VERSION}.tgz" +tgz_url="https://www.python.org/ftp/python/${VERSION}/${tgz_filename}" +echo "Downloading ${tgz_filename}..." +curl -sSL -o "/tmp/python-src/${tgz_filename}" "${tgz_url}" +tar -xzf "/tmp/python-src/${tgz_filename}" -C "/tmp/python-src" --strip-components=1 +cd /tmp/python-src +./configure --enable-optimizations +make -j "$(nproc)" install +alias python=/usr/local/bin/python3 \ No newline at end of file diff --git a/scripts/install_qt.sh b/scripts/install_qt.sh new file mode 100755 index 0000000..53325ed --- /dev/null +++ b/scripts/install_qt.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +source "$HOME/.bashrc" + +/root/.local/bin/aqt install-qt --outputdir /opt/Qt linux desktop ${QT_VERSION} \ No newline at end of file