mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 21:58:01 -06:00
Build: Really try to make sure unwanted binaries are gone.
part of CURA-12229
This commit is contained in:
parent
cf836c29cb
commit
2aed655c8b
1 changed files with 57 additions and 0 deletions
57
conanfile.py
57
conanfile.py
|
@ -217,6 +217,56 @@ class CuraConan(ConanFile):
|
||||||
python_installs=self._python_installs(),
|
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:
|
||||||
|
os.remove(file)
|
||||||
|
print(f"deleted file: {file}")
|
||||||
|
for dir_ in to_remove_dirs:
|
||||||
|
os.remove(dir_)
|
||||||
|
print(f"deleted dir_: {dir_}")
|
||||||
|
|
||||||
def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
|
def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
|
||||||
pyinstaller_metadata = self.conan_data["pyinstaller"]
|
pyinstaller_metadata = self.conan_data["pyinstaller"]
|
||||||
datas = []
|
datas = []
|
||||||
|
@ -416,8 +466,10 @@ class CuraConan(ConanFile):
|
||||||
|
|
||||||
for dependency in self.dependencies.host.values():
|
for dependency in self.dependencies.host.values():
|
||||||
for bindir in dependency.cpp_info.bindirs:
|
for bindir in dependency.cpp_info.bindirs:
|
||||||
|
self._delete_unwanted_binaries(bindir)
|
||||||
copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
|
copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
|
||||||
for libdir in dependency.cpp_info.libdirs:
|
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, "*.pyd", libdir, str(self._site_packages), keep_path = False)
|
||||||
copy(self, "*.pyi", 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)
|
copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
|
||||||
|
@ -507,6 +559,11 @@ echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
|
||||||
|
|
||||||
self._generate_cura_version(os.path.join(self._site_packages, "cura"))
|
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.cpp_info.res_paths[2], "MacOS", "cura.entitlements"))
|
entitlements_file = "'{}'".format(Path(self.cpp_info.res_paths[2], "MacOS", "cura.entitlements"))
|
||||||
self._generate_pyinstaller_spec(location = self._base_dir,
|
self._generate_pyinstaller_spec(location = self._base_dir,
|
||||||
entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
|
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