mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 07:09:01 +08:00
Add option to skip licenses download
CURA-12400 This is useful for development, because it can take a few minutes
This commit is contained in:
parent
eaeaa0d2b2
commit
18a37b2cc3
55
conanfile.py
55
conanfile.py
@ -43,6 +43,7 @@ class CuraConan(ConanFile):
|
|||||||
"cura_debug_mode": [True, False], # FIXME: Use profiles
|
"cura_debug_mode": [True, False], # FIXME: Use profiles
|
||||||
"internal": [True, False],
|
"internal": [True, False],
|
||||||
"i18n_extract": [True, False],
|
"i18n_extract": [True, False],
|
||||||
|
"skip_licenses_download": [True, False],
|
||||||
}
|
}
|
||||||
default_options = {
|
default_options = {
|
||||||
"enterprise": False,
|
"enterprise": False,
|
||||||
@ -52,6 +53,7 @@ class CuraConan(ConanFile):
|
|||||||
"cura_debug_mode": False, # Not yet implemented
|
"cura_debug_mode": False, # Not yet implemented
|
||||||
"internal": False,
|
"internal": False,
|
||||||
"i18n_extract": False,
|
"i18n_extract": False,
|
||||||
|
"skip_licenses_download": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_version(self):
|
def set_version(self):
|
||||||
@ -165,26 +167,27 @@ class CuraConan(ConanFile):
|
|||||||
sources_url = url_data["url"]
|
sources_url = url_data["url"]
|
||||||
dependency_description["sources_url"] = sources_url
|
dependency_description["sources_url"] = sources_url
|
||||||
|
|
||||||
# Download the sources to get the license file inside
|
if not self.options.skip_licenses_download:
|
||||||
self.output.info(f"Retrieving license for {package}")
|
# Download the sources to get the license file inside
|
||||||
response = requests.get(sources_url)
|
self.output.info(f"Retrieving license for {package}")
|
||||||
response.raise_for_status()
|
response = requests.get(sources_url)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
sources_path = os.path.join(temp_dir, "sources.tar.gz")
|
sources_path = os.path.join(temp_dir, "sources.tar.gz")
|
||||||
with open(sources_path, 'wb') as sources_file:
|
with open(sources_path, 'wb') as sources_file:
|
||||||
sources_file.write(response.content)
|
sources_file.write(response.content)
|
||||||
|
|
||||||
with tarfile.open(sources_path, 'r:gz') as sources_archive:
|
with tarfile.open(sources_path, 'r:gz') as sources_archive:
|
||||||
license_file = "LICENSE"
|
license_file = "LICENSE"
|
||||||
|
|
||||||
for source_file in sources_archive.getnames():
|
for source_file in sources_archive.getnames():
|
||||||
if Path(source_file).name == license_file:
|
if Path(source_file).name == license_file:
|
||||||
sources_archive.extract(source_file, temp_dir)
|
sources_archive.extract(source_file, temp_dir)
|
||||||
|
|
||||||
license_file_path = os.path.join(temp_dir, source_file)
|
license_file_path = os.path.join(temp_dir, source_file)
|
||||||
with open(license_file_path, 'r') as file:
|
with open(license_file_path, 'r') as file:
|
||||||
dependency_description["license_full"] = file.read()
|
dependency_description["license_full"] = file.read()
|
||||||
|
|
||||||
for source_url, check_source in [("source", False),
|
for source_url, check_source in [("source", False),
|
||||||
("Source", False),
|
("Source", False),
|
||||||
@ -266,7 +269,7 @@ class CuraConan(ConanFile):
|
|||||||
if not check_source or is_repository_source:
|
if not check_source or is_repository_source:
|
||||||
dependency_description["sources_url"] = source_url
|
dependency_description["sources_url"] = source_url
|
||||||
|
|
||||||
if is_repository_source:
|
if is_repository_source and not self.options.skip_licenses_download:
|
||||||
self.output.info(f"Retrieving license for {dependency.ref.name}")
|
self.output.info(f"Retrieving license for {dependency.ref.name}")
|
||||||
dependency_description["license_full"] = self._get_license_from_repository(source_url, str(dependency.ref.version))
|
dependency_description["license_full"] = self._get_license_from_repository(source_url, str(dependency.ref.version))
|
||||||
|
|
||||||
@ -278,18 +281,20 @@ class CuraConan(ConanFile):
|
|||||||
sources_url = dependency_data["sources_url"]
|
sources_url = dependency_data["sources_url"]
|
||||||
version = dependency_data["version"]
|
version = dependency_data["version"]
|
||||||
|
|
||||||
self.output.info(f"Retrieving license for {dependency_name}")
|
dependency_description = {
|
||||||
license_file = dependency_data["license_file"] if "license_file" in dependency_data else None
|
|
||||||
license_full = self._get_license_from_repository(sources_url, version, license_file)
|
|
||||||
|
|
||||||
dependencies[dependency_name] = {
|
|
||||||
"summary": dependency_data["summary"],
|
"summary": dependency_data["summary"],
|
||||||
"version": version,
|
"version": version,
|
||||||
"license": dependency_data["license"],
|
"license": dependency_data["license"],
|
||||||
"license_full": license_full,
|
|
||||||
"sources_url": sources_url,
|
"sources_url": sources_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not self.options.skip_licenses_download:
|
||||||
|
self.output.info(f"Retrieving license for {dependency_name}")
|
||||||
|
license_file = dependency_data["license_file"] if "license_file" in dependency_data else None
|
||||||
|
dependency_description["license_full"] = self._get_license_from_repository(sources_url, version, license_file)
|
||||||
|
|
||||||
|
dependencies[dependency_name] = dependency_description
|
||||||
|
|
||||||
def _dependencies_description(self):
|
def _dependencies_description(self):
|
||||||
dependencies = {}
|
dependencies = {}
|
||||||
|
|
||||||
@ -302,8 +307,8 @@ class CuraConan(ConanFile):
|
|||||||
self._make_conan_dependency_description(dependency, dependencies)
|
self._make_conan_dependency_description(dependency, dependencies)
|
||||||
|
|
||||||
if "extra_dependencies" in dependency.conan_data:
|
if "extra_dependencies" in dependency.conan_data:
|
||||||
for dependency in dependency.conan_data["extra_dependencies"]:
|
for dependency_name, dependency_data in dependency.conan_data["extra_dependencies"].items():
|
||||||
self._make_extra_dependency_description(dependency, dependencies)
|
self._make_extra_dependency_description(dependency_name, dependency_data, dependencies)
|
||||||
|
|
||||||
if "extra_dependencies" in self.conan_data:
|
if "extra_dependencies" in self.conan_data:
|
||||||
for dependency_name, dependency_data in self.conan_data["extra_dependencies"].items():
|
for dependency_name, dependency_data in self.conan_data["extra_dependencies"].items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user