diff --git a/conanfile.py b/conanfile.py index 81d5a54f01..2dc0f36637 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,7 +17,7 @@ from conan.tools.env import VirtualRunEnv, Environment, VirtualBuildEnv from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration, ConanException -required_conan_version = ">=2.7.0" +required_conan_version = ">=2.7.0" # When changing the version, also change the one in conandata.yml/extra_dependencies class CuraConan(ConanFile): @@ -148,6 +148,28 @@ class CuraConan(ConanFile): # That will not work for ALL open-source projects, but should already get a large majority of them return (url.startswith("https://github.com/") or url.startswith("https://gitlab.com/")) and "conan-center-index" not in url + def _retrieve_pip_license(self, package, sources_url, dependency_description): + # Download the sources to get the license file inside + self.output.info(f"Retrieving license for {package}") + response = requests.get(sources_url) + response.raise_for_status() + + with tempfile.TemporaryDirectory() as temp_dir: + sources_path = os.path.join(temp_dir, "sources.tar.gz") + with open(sources_path, 'wb') as sources_file: + sources_file.write(response.content) + + with tarfile.open(sources_path, 'r:gz') as sources_archive: + license_file = "LICENSE" + + for source_file in sources_archive.getnames(): + if Path(source_file).name == license_file: + sources_archive.extract(source_file, temp_dir) + + license_file_path = os.path.join(temp_dir, source_file) + with open(license_file_path, 'r') as file: + dependency_description["license_full"] = file.read() + def _make_pip_dependency_description(self, package, version, dependencies): url = ["https://pypi.org/pypi", package] if version is not None: @@ -168,26 +190,7 @@ class CuraConan(ConanFile): dependency_description["sources_url"] = sources_url if not self.options.skip_licenses_download: - # Download the sources to get the license file inside - self.output.info(f"Retrieving license for {package}") - response = requests.get(sources_url) - response.raise_for_status() - - with tempfile.TemporaryDirectory() as temp_dir: - sources_path = os.path.join(temp_dir, "sources.tar.gz") - with open(sources_path, 'wb') as sources_file: - sources_file.write(response.content) - - with tarfile.open(sources_path, 'r:gz') as sources_archive: - license_file = "LICENSE" - - for source_file in sources_archive.getnames(): - if Path(source_file).name == license_file: - sources_archive.extract(source_file, temp_dir) - - license_file_path = os.path.join(temp_dir, source_file) - with open(license_file_path, 'r') as file: - dependency_description["license_full"] = file.read() + self._retrieve_pip_license(package, sources_url, dependency_description) for source_url, check_source in [("source", False), ("Source", False), @@ -200,6 +203,7 @@ class CuraConan(ConanFile): url = data["info"]["project_urls"][source_url] if check_source and not self._is_repository_url(url): # That will not work for ALL open-source projects, but should already get a large majority of them + self.output.warning(f"Source URL for {package} ({url}) doesn't seem to be a supported repository") continue dependency_description["sources_url"] = url break @@ -299,11 +303,6 @@ class CuraConan(ConanFile): def _dependencies_description(self): dependencies = {} - pip_requirements_summary = os.path.abspath(Path(self.generators_folder, "pip_requirements_summary.yml") ) - with open(pip_requirements_summary, 'r') as file: - for package_name, package_version in yaml.safe_load(file).items(): - self._make_pip_dependency_description(package_name, package_version, dependencies) - for dependency in [self] + list(self.dependencies.values()): self._make_conan_dependency_description(dependency, dependencies) @@ -311,6 +310,11 @@ class CuraConan(ConanFile): for dependency_name, dependency_data in dependency.conan_data["extra_dependencies"].items(): self._make_extra_dependency_description(dependency_name, dependency_data, dependencies) + pip_requirements_summary = os.path.abspath(Path(self.generators_folder, "pip_requirements_summary.yml") ) + with open(pip_requirements_summary, 'r') as file: + for package_name, package_version in yaml.safe_load(file).items(): + self._make_pip_dependency_description(package_name, package_version, dependencies) + return dependencies def _generate_cura_version(self, location): diff --git a/cura/UI/OpenSourceDependenciesModel.py b/cura/UI/OpenSourceDependenciesModel.py index 5c48234804..0ef4880d55 100644 --- a/cura/UI/OpenSourceDependenciesModel.py +++ b/cura/UI/OpenSourceDependenciesModel.py @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Ultimaker B.V. +# Copyright (c) 2025 UltiMaker # Cura is released under the terms of the LGPLv3 or higher. from typing import List diff --git a/cura/UI/OpenSourceDependency.py b/cura/UI/OpenSourceDependency.py index 88d7d6abab..c9bd5704a1 100644 --- a/cura/UI/OpenSourceDependency.py +++ b/cura/UI/OpenSourceDependency.py @@ -1,4 +1,4 @@ -# Copyright (c) 2025 Ultimaker B.V. +# Copyright (c) 2025 UltiMaker # Cura is released under the terms of the LGPLv3 or higher. from PyQt6.QtCore import QObject, pyqtProperty, pyqtEnum diff --git a/resources/qml/Dialogs/AboutDialog.qml b/resources/qml/Dialogs/AboutDialog.qml index f039719d64..6f1078425d 100644 --- a/resources/qml/Dialogs/AboutDialog.qml +++ b/resources/qml/Dialogs/AboutDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2023 UltiMaker +// Copyright (c) 2025 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.4 @@ -116,9 +116,7 @@ UM.Dialog { id: componentLicenseDialog - LicenseDialog - { - } + LicenseDialog { } } onLinkActivated: diff --git a/resources/qml/Dialogs/LicenseDialog.qml b/resources/qml/Dialogs/LicenseDialog.qml index ea8b83958e..d443cb4998 100644 --- a/resources/qml/Dialogs/LicenseDialog.qml +++ b/resources/qml/Dialogs/LicenseDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2023 UltiMaker +// Copyright (c) 2025 UltiMaker // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.4