diff options
| author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-09-20 17:00:39 +0200 |
|---|---|---|
| committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-10-07 13:54:03 +0200 |
| commit | 1e5fe140b485209a30d7dd38b3334440c58cbb05 (patch) | |
| tree | 43511980e289c57b6208ad0bf9b0c09ea58a483e /sources/pyside6/tests | |
| parent | 9a10caa1e22773ce7563f82680c67596293178e4 (diff) | |
Deployment: Support Design Studio projects
- new class 'DesignStudio' to handle Design Studio projects.
- Currently uses a way of monkey patching to override the 'main.py'
to use 'main_patch.py' which has the same content but with
'app_dir' set to the parent of `main.py``. The reason for doing this
is that Nuitka requires the `main.py` to be in the same directory
as other resources required for the project.
Once the corresponding patch, to alternate between evaluating
'app_dir' based on whether the application is deployed or called
through the Python interpreter, is merged then this temporary fix
of creating 'main_patch.py' can be removed.
- Add tests.
Pick-to: 6.7
Change-Id: I79e6572bdbbf4576fbdd9039a4922997a22139f8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
| -rw-r--r-- | sources/pyside6/tests/tools/pyside6-deploy/test_pyside6_deploy.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/sources/pyside6/tests/tools/pyside6-deploy/test_pyside6_deploy.py b/sources/pyside6/tests/tools/pyside6-deploy/test_pyside6_deploy.py index 9bf917b32..9d98a2b73 100644 --- a/sources/pyside6/tests/tools/pyside6-deploy/test_pyside6_deploy.py +++ b/sources/pyside6/tests/tools/pyside6-deploy/test_pyside6_deploy.py @@ -444,5 +444,97 @@ class TestLongCommand(DeployTestBase): if line.startswith("# nuitka-project:")]), 517) +@unittest.skipIf(sys.platform == "darwin" and int(platform.mac_ver()[0].split('.')[0]) <= 11, + "Test only works on macOS version 12+") +@patch("deploy_lib.config.QtDependencyReader.find_plugin_dependencies") +class DSProjectTest(DeployTestBase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + # setup a test DS Python project + base_path = Path(cls.temp_dir) / "PythonProject" + + files = [ + base_path / "Python" / "autogen" / "settings.py", + base_path / "Python" / "main.py", + base_path / "PythonProject" / "test.qml", + base_path / "PythonProjectContent" / "test.qml" + ] + + # Create the files + for file in files: + file.parent.mkdir(parents=True, exist_ok=True) + file.touch(exist_ok=True) + + cls.temp_example = base_path + + def setUp(self): + os.chdir(self.temp_example) + self.temp_example = self.temp_example.resolve() + self.main_file = self.temp_example / "Python" / "main.py" + self.main_patch_file = self.temp_example / "Python" / "main_patch.py" + self.deployment_files = self.temp_example / "Python" / "deployment" + + self.expected_run_cmd = ( + f"{sys.executable} -m nuitka {self.main_patch_file} --follow-imports" + f" --enable-plugin=pyside6 --output-dir={self.deployment_files} --quiet" + f" --noinclude-qt-translations" + f" --include-data-dir={self.temp_example / 'PythonProjectContent'}=" + "./PythonProjectContent" + f" --include-data-dir={self.temp_example / 'Python'}=./Python" + f" --include-data-dir={self.temp_example / 'PythonProject'}=./PythonProject" + f" {self.dlls_ignore_nuitka}" + f" --noinclude-dlls=*/qml/QtQuickEffectMaker/*" + f" --include-qt-plugins=qml" + ) + + if sys.platform != "win32": + self.expected_run_cmd += ( + " --noinclude-dlls=libQt6Charts* --noinclude-dlls=libQt6Quick*" + " --noinclude-dlls=libQt6Quick3D* --noinclude-dlls=libQt6Sensors*" + " --noinclude-dlls=libQt6Test* --noinclude-dlls=libQt6WebEngine*" + ) + else: + self.expected_run_cmd += ( + " --noinclude-dlls=Qt6Charts* --noinclude-dlls=Qt6Quick*" + " --noinclude-dlls=Qt6Quick3D* --noinclude-dlls=Qt6Sensors*" + " --noinclude-dlls=Qt6Test* --noinclude-dlls=Qt6WebEngine*" + ) + + if sys.platform.startswith("linux"): + self.expected_run_cmd += f" --linux-icon={str(self.linux_icon)} --onefile" + elif sys.platform == "darwin": + self.expected_run_cmd += (f" --macos-app-icon={str(self.macos_icon)}" + " --macos-create-app-bundle --standalone") + elif sys.platform == "win32": + self.expected_run_cmd += f" --windows-icon-from-ico={str(self.win_icon)} --onefile" + + if is_pyenv_python(): + self.expected_run_cmd += " --static-libpython=no" + + self.config_file = self.temp_example / "Python" / "pysidedeploy.spec" + + def testDryRun(self, mock_plugins): + with patch("deploy_lib.config.run_qmlimportscanner") as mock_qmlimportscanner: # noqa: F841 + original_output = self.deploy.main(self.main_file, dry_run=True, force=True) + self.assertEqual(original_output, self.expected_run_cmd) + + @patch("deploy_lib.dependency_util.QtDependencyReader.get_qt_libs_dir") + def testConfigFile(self, mock_sitepackages, mock_plugins): + mock_sitepackages.return_value = Path(_get_qt_lib_dir()) + # create config file + with patch("deploy_lib.config.run_qmlimportscanner") as mock_qmlimportscanner: # noqa: F841 + init_result = self.deploy.main(self.main_file, init=True, force=True) + self.assertEqual(init_result, None) + + # test config file contents + config_obj = self.deploy_lib.BaseConfig(config_file=self.config_file) + + self.assertTrue(config_obj.get_value("app", "input_file").endswith("main.py")) + self.assertTrue(config_obj.get_value("app", "project_dir").endswith("PythonProject")) + self.config_file.unlink() + + if __name__ == "__main__": unittest.main() |
