aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShyamnath Premnadh <shyamnath.premnadh@qt.io>2023-04-17 17:03:06 +0200
committerShyamnath Premnadh <shyamnath.premnadh@qt.io>2023-04-18 18:16:20 +0200
commita6c176fe8a48b8d5f5b7ffaa50b1bc8ab53321f2 (patch)
treec685c34ada4115f2266acc9a319537dbf546e323
parent5ee8cbc57c89c9242f93e58c8972448f817b6437 (diff)
Tooling: Simplify adding new tools
- Amends a48de6afbf127831aa46c1c006d777861bbbe9cb - Simplify the developer doc for adding new tools - Make build_scripts/__init__.py the primary place to add new tools for the build process Pick-to: 6.5 Change-Id: I1e8bd9e069471bf51a186c067773d7fbc2588769 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--build_scripts/__init__.py14
-rw-r--r--build_scripts/platforms/linux.py10
-rw-r--r--build_scripts/platforms/macos.py7
-rw-r--r--build_scripts/platforms/unix.py13
-rw-r--r--build_scripts/platforms/windows_desktop.py7
-rw-r--r--build_scripts/utils.py7
-rw-r--r--sources/pyside6/doc/developer/add_tool.rst46
7 files changed, 55 insertions, 49 deletions
diff --git a/build_scripts/__init__.py b/build_scripts/__init__.py
index 939e83d3f..6ab4c90c8 100644
--- a/build_scripts/__init__.py
+++ b/build_scripts/__init__.py
@@ -12,21 +12,19 @@ PYSIDE_PYTHON_TOOLS = ["metaobjectdump",
"qml",
"qtpy2cpp",
"genpyi"]
+
PYSIDE_UNIX_BIN_TOOLS = ["lupdate",
"lrelease",
"qmllint",
"qmlformat",
"qmlls"]
-# tools that are bundled as .app in macOS
-# keys represent tool name
-# value represents the path to the tool in the macOS app bundle
-PYSIDE_UNIX_BUNDLED_TOOLS = {name: f"{name.capitalize()}.app/Contents/MacOS/{name.capitalize()}"
- for name in ["assistant",
- "designer",
- "linguist"]}
+# tools that are bundled as .app in macOS, but are normal executables in Linux and Windows
+PYSIDE_UNIX_BUNDLED_TOOLS = ["assistant",
+ "designer",
+ "linguist"]
-PYSIDE_LINUX_BIN_TOOLS = PYSIDE_UNIX_BIN_TOOLS + [name for name in PYSIDE_UNIX_BUNDLED_TOOLS.keys()]
+PYSIDE_LINUX_BIN_TOOLS = PYSIDE_UNIX_BIN_TOOLS + PYSIDE_UNIX_BUNDLED_TOOLS
PYSIDE_UNIX_LIBEXEC_TOOLS = ["uic",
"rcc",
diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py
index b346baf8a..bf778670d 100644
--- a/build_scripts/platforms/linux.py
+++ b/build_scripts/platforms/linux.py
@@ -8,7 +8,7 @@ from ..config import config
from ..options import OPTION
from ..utils import (copy_icu_libs, copydir, copyfile, find_files_using_glob,
linux_patch_executable)
-from .. import PYSIDE
+from .. import PYSIDE, PYSIDE_UNIX_BUNDLED_TOOLS
def prepare_standalone_package_linux(pyside_build, _vars, cross_build=False, is_android=False):
@@ -73,10 +73,10 @@ def prepare_standalone_package_linux(pyside_build, _vars, cross_build=False, is_
# Patching designer to use the Qt libraries provided in the wheel
if config.is_internal_pyside_build() and not OPTION['NO_QT_TOOLS']:
- assistant_path = destination_dir / "assistant"
- linux_patch_executable(pyside_build._patchelf_path, assistant_path)
- designer_path = destination_dir / "designer"
- linux_patch_executable(pyside_build._patchelf_path, designer_path)
+
+ for tool in PYSIDE_UNIX_BUNDLED_TOOLS:
+ tool_path = destination_dir / tool
+ linux_patch_executable(pyside_build._patchelf_path, tool_path)
if pyside_build.is_webengine_built(built_modules):
copydir("{qt_data_dir}/resources",
diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py
index 53cc32308..dbe60d343 100644
--- a/build_scripts/platforms/macos.py
+++ b/build_scripts/platforms/macos.py
@@ -9,7 +9,7 @@ from ..config import config
from ..options import OPTION
from ..utils import (copydir, copyfile, macos_add_rpath,
macos_fix_rpaths_for_library)
-from .. import PYSIDE
+from .. import PYSIDE, PYSIDE_UNIX_BUNDLED_TOOLS
def _macos_patch_executable(name, _vars=None):
@@ -62,9 +62,8 @@ def prepare_standalone_package_macos(pyside_build, _vars):
# Patching designer to use the Qt libraries provided in the wheel
if config.is_internal_pyside_build() and not OPTION['NO_QT_TOOLS']:
- _macos_patch_executable('assistant', _vars)
- _macos_patch_executable('designer', _vars)
- _macos_patch_executable('linguist', _vars)
+ for tool in PYSIDE_UNIX_BUNDLED_TOOLS:
+ _macos_patch_executable(tool, _vars)
# <qt>/lib/* -> <setup>/{st_package_name}/Qt/lib
if pyside_build.qt_is_framework_build():
diff --git a/build_scripts/platforms/unix.py b/build_scripts/platforms/unix.py
index 50a6fadc6..753daf898 100644
--- a/build_scripts/platforms/unix.py
+++ b/build_scripts/platforms/unix.py
@@ -11,6 +11,7 @@ from ..utils import copydir, copyfile, copy_qt_metatypes, makefile
from .. import PYSIDE, SHIBOKEN
from .linux import prepare_standalone_package_linux
from .macos import prepare_standalone_package_macos
+from .. import PYSIDE_UNIX_BIN_TOOLS, PYSIDE_UNIX_LIBEXEC_TOOLS, PYSIDE_UNIX_BUNDLED_TOOLS
def _macos_copy_gui_executable(name, _vars=None):
@@ -149,15 +150,15 @@ def prepare_packages_posix(pyside_build, _vars, cross_build=False):
lib_exec_filters = []
if not OPTION['NO_QT_TOOLS']:
- lib_exec_filters.extend(['uic', 'rcc', 'qmltyperegistrar', 'qmlimportscanner'])
+ lib_exec_filters.extend(PYSIDE_UNIX_LIBEXEC_TOOLS)
executables.extend(copydir(
"{install_dir}/bin/", destination_dir,
- _filter=["lrelease", "lupdate", "qmllint", "qmlformat", "qmlls"],
+ _filter=PYSIDE_UNIX_BIN_TOOLS,
recursive=False, _vars=_vars))
- # Copying assistant/designer
- executables.extend(_copy_gui_executable('assistant', _vars=_vars))
- executables.extend(_copy_gui_executable('designer', _vars=_vars))
- executables.extend(_copy_gui_executable('linguist', _vars=_vars))
+
+ # Copying assistant/designer/linguist
+ for tool in PYSIDE_UNIX_BUNDLED_TOOLS:
+ executables.extend(_copy_gui_executable(tool, _vars=_vars))
copy_qt_metatypes(destination_qt_dir, _vars)
diff --git a/build_scripts/platforms/windows_desktop.py b/build_scripts/platforms/windows_desktop.py
index ed6acafb7..ee293aca2 100644
--- a/build_scripts/platforms/windows_desktop.py
+++ b/build_scripts/platforms/windows_desktop.py
@@ -12,7 +12,7 @@ from ..config import config
from ..options import OPTION
from ..utils import (copydir, copyfile, copy_qt_metatypes,
download_and_extract_7z, filter_match, makefile)
-from .. import PYSIDE, SHIBOKEN
+from .. import PYSIDE, SHIBOKEN, PYSIDE_WINDOWS_BIN_TOOLS
def prepare_packages_win32(pyside_build, _vars):
@@ -125,10 +125,7 @@ def prepare_packages_win32(pyside_build, _vars):
# <install>/bin/*.exe,*.dll -> {st_package_name}/
filters = ["pyside*.exe", "pyside*.dll"]
if not OPTION['NO_QT_TOOLS']:
- filters.extend(["lrelease.exe", "lupdate.exe", "uic.exe",
- "rcc.exe", "qmllint.exe", "qmltyperegistrar.exe",
- "assistant.exe", "designer.exe", "qmlimportscanner.exe",
- "linguist.exe", "qmlformat.exe", "qmlls.exe"])
+ filters.extend([f"{tool}.exe" for tool in PYSIDE_WINDOWS_BIN_TOOLS])
copydir("{install_dir}/bin/", destination_qt_dir,
_filter=filters,
recursive=False, _vars=_vars)
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 335e0e16c..ef23b0f71 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -1146,10 +1146,13 @@ def available_pyside_tools(qt_tools_path: Path, package_for_wheels: bool = False
pyside_tools.extend([tool for tool in PYSIDE_UNIX_LIBEXEC_TOOLS
if tool_exist(lib_exec_path / tool)])
if sys.platform == 'darwin':
+ def name_to_path(name):
+ return f"{name.capitalize()}.app/Contents/MacOS/{name.capitalize()}"
+
pyside_tools.extend([tool for tool in PYSIDE_UNIX_BIN_TOOLS
if tool_exist(bin_path / tool)])
- pyside_tools.extend([tool_name for tool_name, tool_path in PYSIDE_UNIX_BUNDLED_TOOLS.items()
- if tool_exist(bin_path / tool_path)])
+ pyside_tools.extend([tool for tool in PYSIDE_UNIX_BUNDLED_TOOLS
+ if tool_exist(bin_path / name_to_path(tool))])
else:
pyside_tools.extend([tool for tool in PYSIDE_LINUX_BIN_TOOLS
if tool_exist(bin_path / tool)])
diff --git a/sources/pyside6/doc/developer/add_tool.rst b/sources/pyside6/doc/developer/add_tool.rst
index bceccbdce..a894226c5 100644
--- a/sources/pyside6/doc/developer/add_tool.rst
+++ b/sources/pyside6/doc/developer/add_tool.rst
@@ -10,32 +10,40 @@ tools to solve issues, or improve some project workflows.
Add a new tool
--------------
+Tools not available to end users
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This depicts the tools that are not shipped with Qt for Python wheels and are used to aid
+Qt for Python development
+
- Place your tool in the ``tools`` directory.
- If your project has more than one file, create a directory.
- Create a ``.pyproject`` file including all the relevant files
for your tool.
-- If you would like to interface the tool for end users,
- you need to create an entry point for the wheel creation,
- and also copy the files in the wheel creation process.
-
-
-Add a Qt tool wrapper
----------------------
-
-- Add script and optional library under ``sources/pyside-tools``.
-- Install the files (``sources/pyside-tools/CMakeLists.txt``).
-- Include the tool in the deprecated 'setup.py bdist_wheel' process:
-
- - Add the tool in ``build_scripts/__init__.py``.
- - Copy the files to the wheels in ``build_scripts/platforms/*.py``.
+Tools available to end users
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- - Add an entry to ``sources/pyside6/doc/gettingstarted/package_details.rst``.
-
-- Include the tool in the new wheel creation process:
+- Place your tool in the ``sources/pyside-tools`` directory.
+- If your project has more than one file, create a directory.
+- Create a ``.pyproject`` file including all the relevant files
+ for your tool.
+- Add the relevant files in ``sources/pyside-tools/CMakeLists.txt``.
+- Add the tool in ``sources/pyside-tools/pyside_tool.py``.
+- Add the tool in ``build_scripts/__init__.py`` to create the setuptools entry points
+ i.e. this enable using the tool from the console as "pyside6-<tool_name>"
+- Add an entry to ``sources/pyside6/doc/gettingstarted/package_details.rst``.
+- Include the necessary Qt binaries explicitly on ``build_scripts/wheel_files.py``
+- Build with ``--standalone``, verify it is working.
- - Add an entry to ``create_wheels.py``.
- - Include the Qt binaries explicitly on ``build_scripts/wheel_files.py``
+Add a Qt tool wrapper
+---------------------
+- Add the relevant files in ``sources/pyside-tools/CMakeLists.txt``.
+- Add the tool in ``sources/pyside-tools/pyside_tool.py``.
+- Add the tool in ``build_scripts/__init__.py`` to create the setuptools entry points
+ i.e. this enable using the tool from the console as "pyside6-<tool_name>"
+- Add an entry to ``sources/pyside6/doc/gettingstarted/package_details.rst``.
+- Include the necessary Qt binaries explicitly on ``build_scripts/wheel_files.py``
- Build with ``--standalone``, verify it is working.