Skip to content

Commit

Permalink
Compile PyQt6 with Qml support
Browse files Browse the repository at this point in the history
The wheels for PyQt6 from the pypi artifactory are linked against
the limited Python ABI. The CPython interpreter we compile as part
of Cura is not compiled with the Py_LIMITED_ABI flag. This results
on Windows that the PyQt6 module try to use the python3.dll in the
system, while our CPython deps is compiled as python310.dll.

To make sure that PyQt6 runs and uses our CPython library we need
to compile and link PyQt6 against our Conan dependencies. This means
that we also need to compile Qt6 and make sure that PyQt6 is compiled
without the Py_LIMITED_ABI definition. For this to work we need to
patch the pyproject.toml (using our Conan pyprojecttoolchain generator
https://github.com/Ultimaker/conan-ultimaker-index/blob/CURA-8831_pyqt6_recipe/recipes/pyprojecttoolchain/conanfile.py )
and patch the SIP definition files to replace all `use_limited_api=True`
arguments with `use_limited_api=True`. Furthermore, we need enable at
the very least the `qtdeclarative` module for Qml support.

Adding the PyQt6/6.3.1 as a Conan dependency to Cura and Uranium and
removing the PyQt6* requirements from the requirement.txt except:
PyQt6-sip will solve the following GH issue

Fixes Ultimaker/Cura#12773
Fixes Ultimaker/Cura#12745
Fixes Ultimaker/Cura#13047

Mind you we're still missing some PyQt6 modules atm so Cura will
start up and doesn't complain about missing dll's anymore but at
the time it doesn't render text yet. This is probably because
harfbuzz and glib are disabled.

These are currently disabled because of some issues with the
Conan recipe for automake and autoconf when using msys2.
See conan-io/conan-center-index#9048 and conan-io/conan-center-index#10028

A possible workaround for that is to modify the Qt6 dependency which
uses automake and autoconf, remove those as dependencies when compiling
on Windows and adding the option for:
`msys2:packages=base-devel,binutils,gcc,autoconf,automake`

Contributes to CURA-8831
  • Loading branch information
jellespijker committed Aug 25, 2022
1 parent 6ae4cbd commit 6cd39f8
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions recipes/pyqt6/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conan.tools.files import files, replace_in_file
from conan.tools.layout import cmake_layout
from conan.tools.microsoft import VCVars, is_msvc
from conans.tools import chdir, vcvars
from conans.tools import chdir

required_conan_version = ">=1.33.0"

Expand All @@ -32,14 +32,17 @@ class PyQt6Conan(ConanFile):
default_options = {
"shared": True,
"fPIC": True,
"py_build_requires": '"sip >=6.5, <7", "PyQt-builder >=1.11, <2", "PyQt6-sip >=13.4, <14"',
"py_build_requires": '"sip >=6.5, <7", "PyQt-builder >=1.11, <2"',
"py_build_backend": "sipbuild.api",
}

def layout(self):
cmake_layout(self)
self.folders.source = "source"

def build_requirements(self):
self.tool_requires(f"qt/{self.version}")

def requirements(self):
self.requires("cpython/3.10.4")
self.requires(f"qt/{self.version}")
Expand All @@ -54,11 +57,19 @@ def requirements(self):
def configure(self):
self.options["cpython"].shared = self.options.shared
self.options["qt"].shared = self.options.shared

# Disbabled harfbuzz and glib for now since these require the use of a bash such as msys2. If we still need
self.options["qt"].qtdeclarative = True
self.options["qt"].qtimageformats = True
self.options["qt"].qtshadertools = True
self.options["qt"].qtsvg = True
self.options["qt"].qtlanguageserver = True
self.options["qt"].qtnetworkauth = True
self.options["qt"].qt3d = True
self.options["qt"].qtquick3d = True

# Disabled harfbuzz and glib for now since these require the use of a bash such as msys2. If we still need
# these libraries. We should fix these recipes such that they don't use automake and autoconf on Windows and
# add the configure option: `-o msys2:packages=base-devel,binutils,gcc,autoconf,automake`
# These recipes are older version and don't handle the the run/build environment and the win_bash config options
# These recipes are older version and don't handle the run/build environment and the win_bash config options
# well. Preinstalling these packages is a quick and dirty solution but a viable one due to the time constraints
self.options["qt"].with_harfbuzz = False
self.options["qt"].with_glib = False
Expand All @@ -81,7 +92,7 @@ def source(self):
def generate(self):
if is_msvc(self):
ms = VCVars(self)
ms.generate(scope = "run")
ms.generate(scope = "build")

# Generate the pyproject.toml and override the shipped pyproject.toml, This allows us to link to our CPython
# lib
Expand All @@ -99,7 +110,7 @@ def generate(self):

def build(self):
with chdir(self.source_folder):
self.run(f"""sip-install --pep484-pyi --verbose --confirm-license --no-tools""", run_environment = True, env = "conanrun")
self.run(f"""sip-install --pep484-pyi --verbose --confirm-license --no-tools""", run_environment=True)

def package(self):
# already installed by our use of the `sip-install` command during build
Expand Down

0 comments on commit 6cd39f8

Please sign in to comment.