diff options
author | Christian Tismer <tismer@stackless.com> | 2024-01-16 13:21:00 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2024-01-18 13:44:36 +0100 |
commit | a6b47fbd8f3f4a4b93ded10cbdf2c3358de20e16 (patch) | |
tree | 8fee3127de3c5dbeba6bdac8e200c1ad0811790e | |
parent | ae59d6e758d6be23e009fe3d7a6f744261d7c437 (diff) |
shiboken: Allow to disable pyi file generation for debugging
When developing difficult stuff like Lazy Initialization,
it is convenient to have an option that ignores PYI generation.
This way, translation can be successful, and pyi generation
can then be debugged.
Task-number: PYSIDE-2404
Change-Id: I68bd10af3754de3988556c4558d1331564f5dadb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 2bb8b0f7bef8521cd8ffc395169d2dd152d59a92)
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | build_scripts/main.py | 15 | ||||
-rw-r--r-- | build_scripts/options.py | 9 | ||||
-rw-r--r-- | sources/pyside6/cmake/Macros/PySideModules.cmake | 2 |
4 files changed, 18 insertions, 10 deletions
@@ -113,6 +113,8 @@ using `setup.py build`: or macOS only). * `--verbose-build`, will output the compiler invocation with command line arguments, etc. + * `--disable-pyi`, will suppress the generation of .pyi files. This allows + debugging when the project builds but the pyi generator complains. ## Requirements diff --git a/build_scripts/main.py b/build_scripts/main.py index 4594c6ade..cc77c40bb 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -692,12 +692,14 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin): "(default yes if applicable, i.e. Python " "version >= 3.8 and release build if on Windows)") + if OPTION["DISABLE_PYI"]: + cmake_cmd.append("-DDISABLE_PYI=yes") + if OPTION["LOG_LEVEL"] == LogLevel.VERBOSE: cmake_cmd.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON") else: cmake_cmd.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF") - if OPTION['COMPILER_LAUNCHER']: compiler_launcher = OPTION['COMPILER_LAUNCHER'] cmake_cmd.append(f"-DCMAKE_C_COMPILER_LAUNCHER={compiler_launcher}") @@ -856,8 +858,7 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin): if OPTION["LOG_LEVEL"] == LogLevel.VERBOSE and self.make_generator == "Ninja": make_doc_cmd.append("-v") if run_process(make_doc_cmd) != 0: - raise SetupError("Error generating documentation " - f"for {extension}") + raise SetupError(f"Error generating documentation for {extension}") else: log.info("Sphinx not found, skipping documentation build") else: @@ -1003,8 +1004,8 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin): # (lib/libclang.lib), whereas we want to copy the shared # library (bin/libclang.dll). clang_lib_path = Path(re.sub(r'lib/libclang.lib$', - 'bin/libclang.dll', - clang_lib_path)) + 'bin/libclang.dll', + clang_lib_path)) else: clang_lib_path = Path(clang_lib_path) # shiboken6 links against libclang.so.6 or a similarly @@ -1092,6 +1093,7 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin): message = "Patched rpath to '$ORIGIN/' in" if sys.platform.startswith('linux'): + def rpath_cmd(srcpath): final_rpath = '' # Command line rpath option takes precedence over @@ -1110,6 +1112,7 @@ class PysideBuild(_build, CommandMixin, BuildInfoCollectorMixin): elif sys.platform == 'darwin': message = "Updated rpath in" + def rpath_cmd(srcpath): final_rpath = '' # Command line rpath option takes precedence over @@ -1271,7 +1274,7 @@ class PysideRstDocs(Command, CommandMixin): if self.name == PYSIDE: self.sphinx_src = self.out_dir / "rst" example_gallery = config.setup_script_dir / "tools" / "example_gallery" / "main.py" - assert(example_gallery.is_file()) + assert example_gallery.is_file() example_gallery_cmd = [sys.executable, os.fspath(example_gallery)] if OPTION["LOG_LEVEL"] == LogLevel.QUIET: example_gallery_cmd.append("--quiet") diff --git a/build_scripts/options.py b/build_scripts/options.py index e49dd61cc..b45894db7 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -24,6 +24,7 @@ Additional options: --cmake-toolchain-file Path to CMake toolchain to enable cross-compiling --shiboken-host-path Path to host shiboken package when cross-compiling --qt-host-path Path to host Qt installation when cross-compiling + --disable-pyi Disable .pyi file generation """ @@ -159,6 +160,7 @@ OPTION = { "VERBOSE_BUILD": has_option('verbose-build'), "SNAPSHOT_BUILD": has_option("snapshot-build"), "LIMITED_API": option_value("limited-api"), + "DISABLE_PYI": has_option("disable-pyi"), "PACKAGE_TIMESTAMP": option_value("package-timestamp"), # This is used automatically by setuptools.command.install object, to # specify the final installation location. @@ -442,8 +444,8 @@ class CommandMixin(object): # qtpaths is available. This happens when building the host # tools in the overall cross-building process. use_cmake = False - if (using_cmake_toolchain_file or - (not self.qmake and not self.qtpaths and self.qt_target_path)): + if (using_cmake_toolchain_file or (not self.qmake + and not self.qtpaths and self.qt_target_path)): use_cmake = True QtInfo().setup(qtpaths_abs_path, self.cmake, qmake_abs_path, @@ -541,7 +543,8 @@ class CommandMixin(object): # explicitly. This is to help with the building of host tools # while cross-compiling. # Skip this process for the 'build_rst_docs' command - if not self.is_cross_compile and not self.qt_target_path and 'build_rst_docs' not in sys.argv: + if not (self.is_cross_compile and not self.qt_target_path + and 'build_rst_docs' not in sys.argv): # Enforce usage of qmake in QtInfo if it was given explicitly. if self.qmake: self.has_qmake_option = True diff --git a/sources/pyside6/cmake/Macros/PySideModules.cmake b/sources/pyside6/cmake/Macros/PySideModules.cmake index a54f529f9..bf6054a76 100644 --- a/sources/pyside6/cmake/Macros/PySideModules.cmake +++ b/sources/pyside6/cmake/Macros/PySideModules.cmake @@ -280,7 +280,7 @@ macro(create_pyside_module) # Don't generate the files when cross-building because the target python can not be executed # on the host machine (usually, unless you use some userspace qemu based mechanism). # TODO: Can we do something better here to still get pyi files? - if(NOT PYSIDE_IS_CROSS_BUILD) + if(NOT (PYSIDE_IS_CROSS_BUILD OR DISABLE_PYI)) set(generate_pyi_options ${module_NAME} --sys-path "${pysidebindings_BINARY_DIR}" "${SHIBOKEN_PYTHON_MODULE_DIR}/..") # use the layer above shiboken6 |