mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 11:47:50 -06:00
Merge remote-tracking branch 'origin/main' into CURA-11622_conan_v2
This commit is contained in:
commit
8e25302753
7873 changed files with 72834 additions and 12236 deletions
102
conanfile.py
102
conanfile.py
|
@ -168,6 +168,62 @@ class CuraConan(ConanFile):
|
|||
python_installs=self._python_installs(),
|
||||
))
|
||||
|
||||
def _delete_unwanted_binaries(self, root):
|
||||
dynamic_binary_file_exts = [".so", ".dylib", ".dll", ".pyd", ".pyi"]
|
||||
prohibited = [
|
||||
"qt5compat",
|
||||
"qtcharts",
|
||||
"qtcoap",
|
||||
"qtdatavis3d",
|
||||
"qtlottie",
|
||||
"qtmqtt",
|
||||
"qtnetworkauth",
|
||||
"qtquick3d",
|
||||
"qtquick3dphysics",
|
||||
"qtquicktimeline",
|
||||
"qtvirtualkeyboard",
|
||||
"qtwayland"
|
||||
]
|
||||
forbiddens = [x.encode() for x in prohibited]
|
||||
to_remove_files = []
|
||||
to_remove_dirs = []
|
||||
for root, dir_, files in os.walk(root):
|
||||
for filename in files:
|
||||
if not any([(x in filename) for x in dynamic_binary_file_exts]):
|
||||
continue
|
||||
pathname = os.path.join(root, filename)
|
||||
still_exist = True
|
||||
for forbidden in prohibited:
|
||||
if forbidden.lower() in str(pathname).lower():
|
||||
to_remove_files.append(pathname)
|
||||
still_exist = False
|
||||
break
|
||||
if not still_exist:
|
||||
continue
|
||||
with open(pathname, "rb") as file:
|
||||
bytez = file.read().lower()
|
||||
for forbidden in forbiddens:
|
||||
if bytez.find(forbidden) >= 0:
|
||||
to_remove_files.append(pathname)
|
||||
for dirname in dir_:
|
||||
for forbidden in prohibited:
|
||||
if forbidden.lower() == str(dirname).lower():
|
||||
pathname = os.path.join(root, dirname)
|
||||
to_remove_dirs.append(pathname)
|
||||
break
|
||||
for file in to_remove_files:
|
||||
try:
|
||||
os.remove(file)
|
||||
print(f"deleted file: {file}")
|
||||
except Exception as ex:
|
||||
print(f"WARNING: Attempt to delete file {file} results in: {str(ex)}")
|
||||
for dir_ in to_remove_dirs:
|
||||
try:
|
||||
rmdir(self, dir_)
|
||||
print(f"deleted dir_: {dir_}")
|
||||
except Exception as ex:
|
||||
print(f"WARNING: Attempt to delete folder {dir_} results in: {str(ex)}")
|
||||
|
||||
def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file, cura_source_folder):
|
||||
pyinstaller_metadata = self.conan_data["pyinstaller"]
|
||||
datas = []
|
||||
|
@ -240,13 +296,27 @@ class CuraConan(ConanFile):
|
|||
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
|
||||
cura_version = Version(version)
|
||||
|
||||
# filter all binary files in binaries on the blacklist
|
||||
blacklist = pyinstaller_metadata["blacklist"]
|
||||
filtered_binaries = [b for b in binaries if not any([all([(part in b[0].lower()) for part in parts]) for parts in blacklist])]
|
||||
|
||||
# In case the installer isn't actually pyinstaller (Windows at the moment), outright remove the offending files:
|
||||
specifically_delete = set(binaries) - set(filtered_binaries)
|
||||
for (unwanted_path, _) in specifically_delete:
|
||||
try:
|
||||
os.remove(unwanted_path)
|
||||
print(f"delete: {unwanted_path}")
|
||||
except Exception as ex:
|
||||
print(f"WARNING: Attempt to delete binary {unwanted_path} results in: {str(ex)}")
|
||||
|
||||
# Write the actual file:
|
||||
with open(os.path.join(location, "UltiMaker-Cura.spec"), "w") as f:
|
||||
f.write(pyinstaller.render(
|
||||
name = str(self.options.display_name).replace(" ", "-"),
|
||||
display_name = self._app_name,
|
||||
entrypoint = entrypoint_location,
|
||||
datas = datas,
|
||||
binaries = binaries,
|
||||
binaries = filtered_binaries,
|
||||
venv_script_path = str(self._script_dir),
|
||||
hiddenimports = pyinstaller_metadata["hiddenimports"],
|
||||
collect_all = pyinstaller_metadata["collect_all"],
|
||||
|
@ -325,8 +395,10 @@ class CuraConan(ConanFile):
|
|||
|
||||
for dependency in self.dependencies.host.values():
|
||||
for bindir in dependency.cpp_info.bindirs:
|
||||
self._delete_unwanted_binaries(bindir)
|
||||
copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
|
||||
for libdir in dependency.cpp_info.libdirs:
|
||||
self._delete_unwanted_binaries(libdir)
|
||||
copy(self, "*.pyd", libdir, str(self._site_packages), keep_path = False)
|
||||
copy(self, "*.pyi", libdir, str(self._site_packages), keep_path = False)
|
||||
copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
|
||||
|
@ -383,6 +455,34 @@ class CuraConan(ConanFile):
|
|||
copy(self, "*", uranium.resdirs[1], str(self._share_dir.joinpath("uranium", "plugins")), keep_path = True)
|
||||
copy(self, "*", uranium.libdirs[0], str(self._site_packages.joinpath("UM")), keep_path = True)
|
||||
|
||||
# Generate the GitHub Action version info Environment
|
||||
version = self.conf.get("user.cura:version", default = self.version, check_type = str)
|
||||
cura_version = Version(version)
|
||||
env_prefix = "Env:" if self.settings.os == "Windows" else ""
|
||||
activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||
""").render(cura_version_major = cura_version.major,
|
||||
cura_version_minor = cura_version.minor,
|
||||
cura_version_patch = cura_version.patch,
|
||||
cura_version_build = cura_version.build if cura_version.build != "" else "0",
|
||||
cura_version_full = self.version,
|
||||
cura_app_name = self._app_name,
|
||||
env_prefix = env_prefix)
|
||||
|
||||
ext = ".sh" if self.settings.os != "Windows" else ".ps1"
|
||||
save(self, os.path.join(self._script_dir, f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)
|
||||
|
||||
self._generate_cura_version(os.path.join(self._site_packages, "cura"))
|
||||
|
||||
self._delete_unwanted_binaries(self._site_packages)
|
||||
self._delete_unwanted_binaries(self.package_folder)
|
||||
self._delete_unwanted_binaries(self._base_dir)
|
||||
self._delete_unwanted_binaries(self._share_dir)
|
||||
|
||||
entitlements_file = "'{}'".format(Path(self.deploy_folder, "packaging", "MacOS", "cura.entitlements"))
|
||||
self._generate_pyinstaller_spec(location = self.deploy_folder,
|
||||
entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue