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

Linux Qt binding granurality #127

Merged
merged 11 commits into from
Jul 24, 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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ARG PYTHON_VERSION=3.9.13
ARG BUILD_DATE
ARG VERSION

ARG CUSTOM_QT_BINDING=""
ENV QT_BINDING=$CUSTOM_QT_BINDING

LABEL description="Docker Image to build and run AYON Launcher under Ubuntu"
LABEL org.opencontainers.image.name="ynput/ayon-launcher"
LABEL org.opencontainers.image.title="AYON Launcher Docker Image"
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM centos:7 AS builder
ARG PYTHON_VERSION=3.9.13

ARG CUSTOM_QT_BINDING=""
ENV QT_BINDING=$CUSTOM_QT_BINDING

LABEL description="Docker Image to build and run AYON Launcher under Centos 7"
LABEL org.opencontainers.image.name="ynput/ayon-launcher"
LABEL org.opencontainers.image.title="AYON Launcher Docker Image"
Expand All @@ -11,7 +14,6 @@ LABEL org.opencontainers.image.documentation="https://ayon.ynput.io"
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.version=$VERSION


USER root

# update base
Expand Down Expand Up @@ -89,8 +91,6 @@ RUN chmod +x /opt/ayon-launcher/tools/make.sh

WORKDIR /opt/ayon-launcher

ENV QT_BINDING=centos7

RUN source $HOME/.bashrc \
&& pyenv local ${PYTHON_VERSION}

Expand Down
3 changes: 3 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ARG PYTHON_VERSION=3.9.13
ARG BUILD_DATE
ARG VERSION

ARG CUSTOM_QT_BINDING=""
ENV QT_BINDING=$CUSTOM_QT_BINDING

LABEL description="Docker Image to build and run AYON Launcher under Debian"
LABEL org.opencontainers.image.name="ynput/ayon-launcher"
LABEL org.opencontainers.image.title="AYON Launcher Docker Image"
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM rockylinux:8 AS builder
ARG PYTHON_VERSION=3.9.13

ARG CUSTOM_QT_BINDING=""
ENV QT_BINDING=$CUSTOM_QT_BINDING

LABEL description="Docker Image to build and run AYON Launcher under RockyLinux 9"
LABEL org.opencontainers.image.name="ynput/ayon-launcher"
LABEL org.opencontainers.image.title="AYON Launcher Docker Image"
Expand All @@ -11,7 +14,6 @@ LABEL org.opencontainers.image.documentation="https://ayon.ynput.io"
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.version=$VERSION


USER root

# update base
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.rocky9
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM rockylinux:9 AS builder
ARG PYTHON_VERSION=3.9.13

ARG CUSTOM_QT_BINDING=""
ENV QT_BINDING=$CUSTOM_QT_BINDING

LABEL description="Docker Image to build and run AYON Launcher under RockyLinux 9"
LABEL org.opencontainers.image.name="ynput/ayon-launcher"
LABEL org.opencontainers.image.title="AYON Launcher Docker Image"
Expand All @@ -11,7 +14,6 @@ LABEL org.opencontainers.image.documentation="https://ayon.ynput.io"
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.version=$VERSION


USER root

# update base
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ We provide comprehensive build steps:
* [macOS](docs/build_guides/macos.md)
* [Linux](docs/build_guides/linux.md) - needs distribution specific steps

### Linux build
We do recommend to use docker build options for linux distributions. Prepared dockerfiles do all necessary steps for you.

**NOTE:** There might be cases when linux installer should use PySide2 instead of PySide6 (which is default). You can change this by using `--use-pyside2` in docker build command. Or you can use env variable `QT_BINDING=pyside2` for local build.
We do handle that case for Centos 7 build, but all other variants are using PySide6 by default.

Output of the build process is installer with metadata file that can be distributed to workstations.

Upload installer to server
Expand Down
2 changes: 2 additions & 0 deletions docs/build_guides/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**WARNING:** Linux needs distribution specific steps.

We highly recommend to use prepared docker build options for Linux. If you want to build AYON on your local machine, the following steps may not be fully working for every case.

## Requirements
---

Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ semver = "^2.13.0"
QtPy = "^2.3.0"
pywin32 = { version = "301", markers = "sys_platform == 'win32'" }
python3-xlib = { version="*", markers = "sys_platform == 'linux'"}
distro = { version="^1.9.0", markers = "sys_platform == 'linux'"}

[tool.poetry.dev-dependencies]
flake8 = "^6.0"
Expand Down Expand Up @@ -97,6 +98,10 @@ version = "6.7.1"
package = "PySide2"
version = "5.15.2"

[ayon.qtbinding.pyside2]
package = "PySide2"
version = "5.15.2"

[tool.pyright]
include = [
"vendor"
Expand Down
12 changes: 10 additions & 2 deletions tools/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,14 @@ docker_build() {
fi
fi

qtenv=""
for var in "$@"
do
if [[ "$var" == '--use-pyside2' ]]; then
$qtenv="pyside2"
break
fi
done
pushd "$repo_root" > /dev/null || return > /dev/null

echo -e "${BIYellow}---${RST} Cleaning build directory ..."
Expand All @@ -354,7 +362,7 @@ docker_build() {
local launcher_version="$(python <<< ${version_command})"

echo -e "${BIGreen}>>>${RST} Running docker build ..."
docker build --pull --iidfile $repo_root/build/docker-image.id --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$launcher_version -t ynput/ayon-launcher:$launcher_version -f $dockerfile .
docker build --pull --iidfile $repo_root/build/docker-image.id --build-arg CUSTOM_QT_BINDING=$qtenv --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$launcher_version -t ynput/ayon-launcher:$launcher_version -f $dockerfile .
if [ $? -ne 0 ] ; then
echo $?
echo -e "${BIRed}!!!${RST} Docker build failed."
Expand All @@ -380,7 +388,7 @@ docker_build() {

default_help() {
print_art
echo "Ayon desktop application tool"
echo "AYON desktop application tool"
echo ""
echo "Usage: ./make.sh [target]"
echo ""
Expand Down
7 changes: 6 additions & 1 deletion tools/manage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,14 @@ function New-DockerBuild {
New-Item -ItemType Directory -Path $build_dir
}

$qtbindingValue = ""
if ($arguments -contains "--use-pyside2") {
$qtbindingValue = "pyside2"
}

Write-Color -Text ">>> ", "Running Docker build ..." -Color Green, Gray, White

docker build --pull --iidfile $repo_root/build/docker-image.id --build-arg BUILD_DATE=$(Get-Date -UFormat %Y-%m-%dT%H:%M:%SZ) --build-arg VERSION=$(Get-Ayon-Version) -t ynput/ayon-launcher:$(Get-Ayon-Version) -f $dockerfile .
docker build --pull --iidfile $repo_root/build/docker-image.id --build-arg CUSTOM_QT_BINDING=$($qtbindingValue) --build-arg BUILD_DATE=$(Get-Date -UFormat %Y-%m-%dT%H:%M:%SZ) --build-arg VERSION=$(Get-Ayon-Version) -t ynput/ayon-launcher:$(Get-Ayon-Version) -f $dockerfile .
if ($LASTEXITCODE -ne 0) {
Write-Color -Text "!!! ", "Docker command failed.", $LASTEXITCODE -Color Red, Yellow, Red
Restore-Cwd
Expand Down
21 changes: 20 additions & 1 deletion tools/runtime_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,30 @@ def _pip_install(runtime_dep_root, package, version=None):
def install_qtbinding(pyproject, runtime_dep_root, platform_name):
_print("Handling Qt binding framework ...")

qt_variants = []
# Use QT_BINDING environment variable if set
# - existence is not validate, if does not exists it is just skipped
qt_package = os.getenv("QT_BINDING")
if qt_package:
qt_variants.append(qt_package)

# Special handling for specific distro (e.g. centos7 and rocky8)
if platform_name == "linux":
import distro

qt_variants.append(f"{distro.id()}{distro.major_version()}")

qt_binding_options = pyproject["ayon"]["qtbinding"]
qtbinding_def = qt_binding_options.get(qt_package)
qtbinding_def = None
for qt_variant in qt_variants:
qtbinding_def = qt_binding_options.get(qt_variant)
if qtbinding_def:
break

# Use platform default Qt binding
if not qtbinding_def:
qtbinding_def = pyproject["ayon"]["qtbinding"][platform_name]

package = qtbinding_def["package"]
version = qtbinding_def.get("version")

Expand Down