conanfile.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. import os
  2. from io import StringIO
  3. from pathlib import Path
  4. from jinja2 import Template
  5. from conan import ConanFile
  6. from conan.tools.files import copy, rmdir, save, mkdir, rm, update_conandata
  7. from conan.tools.microsoft import unix_path
  8. from conan.tools.env import VirtualRunEnv, Environment, VirtualBuildEnv
  9. from conan.tools.scm import Version
  10. from conan.errors import ConanInvalidConfiguration, ConanException
  11. required_conan_version = ">=2.7.0"
  12. class CuraConan(ConanFile):
  13. name = "cura"
  14. license = "LGPL-3.0"
  15. author = "UltiMaker"
  16. url = "https://github.com/Ultimaker/cura"
  17. description = "3D printer / slicing GUI built on top of the Uranium framework"
  18. topics = ("conan", "python", "pyqt6", "qt", "qml", "3d-printing", "slicer")
  19. build_policy = "missing"
  20. exports = "LICENSE*", "*.jinja"
  21. settings = "os", "compiler", "build_type", "arch"
  22. generators = "VirtualPythonEnv"
  23. tool_requires = "gettext/0.22.5"
  24. python_requires = "translationextractor/[>=2.2.0]@ultimaker/stable"
  25. options = {
  26. "enterprise": [True, False],
  27. "staging": [True, False],
  28. "cloud_api_version": ["ANY"],
  29. "display_name": ["ANY"], # TODO: should this be an option??
  30. "cura_debug_mode": [True, False], # FIXME: Use profiles
  31. "internal": [True, False],
  32. "i18n_extract": [True, False],
  33. }
  34. default_options = {
  35. "enterprise": False,
  36. "staging": False,
  37. "cloud_api_version": "1",
  38. "display_name": "UltiMaker Cura",
  39. "cura_debug_mode": False, # Not yet implemented
  40. "internal": False,
  41. "i18n_extract": False,
  42. }
  43. def set_version(self):
  44. if not self.version:
  45. self.version = self.conan_data["version"]
  46. @property
  47. def _app_name(self):
  48. if self.options.enterprise:
  49. return str(self.options.display_name) + " Enterprise"
  50. return str(self.options.display_name)
  51. @property
  52. def _urls(self):
  53. if self.options.staging:
  54. return "staging"
  55. return "default"
  56. @property
  57. def _root_dir(self):
  58. return Path(self.deploy_folder if hasattr(self, "deploy_folder") else self.source_folder)
  59. @property
  60. def _base_dir(self):
  61. return self._root_dir.joinpath("venv")
  62. @property
  63. def _share_dir(self):
  64. return self._base_dir.joinpath("share")
  65. @property
  66. def _script_dir(self):
  67. if self.settings.os == "Windows":
  68. return self._base_dir.joinpath("Scripts")
  69. return self._base_dir.joinpath("bin")
  70. @property
  71. def _site_packages(self):
  72. if self.settings.os == "Windows":
  73. return self._base_dir.joinpath("Lib", "site-packages")
  74. py_version = Version(self.dependencies["cpython"].ref.version)
  75. return self._base_dir.joinpath("lib", f"python{py_version.major}.{py_version.minor}", "site-packages")
  76. @property
  77. def _py_interp(self):
  78. py_interp = self._script_dir.joinpath(Path(self.deps_user_info["cpython"].python).name)
  79. if self.settings.os == "Windows":
  80. py_interp = Path(*[f'"{p}"' if " " in p else p for p in py_interp.parts])
  81. return py_interp
  82. @property
  83. def _pyinstaller_spec_arch(self):
  84. if self.settings.os == "Macos":
  85. if self.settings.arch == "armv8":
  86. return "'arm64'"
  87. return "'x86_64'"
  88. return "None"
  89. def _conan_installs(self):
  90. self.output.info("Collecting conan installs")
  91. conan_installs = {}
  92. # list of conan installs
  93. for dependency in self.dependencies.host.values():
  94. conan_installs[dependency.ref.name] = {
  95. "version": str(dependency.ref.version),
  96. "revision": dependency.ref.revision
  97. }
  98. return conan_installs
  99. def _python_installs(self):
  100. self.output.info("Collecting python installs")
  101. python_installs = {}
  102. collect_python_installs = "collect_python_installs.py"
  103. code = f"import importlib.metadata; print(';'.join([(package.metadata['Name']+','+ package.metadata['Version']) for package in importlib.metadata.distributions()]))"
  104. save(self, collect_python_installs, code)
  105. buffer = StringIO()
  106. self.run(f"""python {collect_python_installs}""", env="virtual_python_env", stdout=buffer)
  107. rm(self, collect_python_installs, ".")
  108. packages = str(buffer.getvalue()).strip('\r\n').split(";")
  109. for package in packages:
  110. name, version = package.split(",")
  111. python_installs[name] = {"version": version}
  112. return python_installs
  113. def _generate_cura_version(self, location):
  114. with open(os.path.join(self.recipe_folder, "CuraVersion.py.jinja"), "r") as f:
  115. cura_version_py = Template(f.read())
  116. # If you want a specific Cura version to show up on the splash screen add the user configuration `user.cura:version=VERSION`
  117. # the global.conf, profile, package_info (of dependency) or via the cmd line `-c user.cura:version=VERSION`
  118. cura_version = Version(self.conf.get("user.cura:version", default = self.version, check_type = str))
  119. pre_tag = f"-{cura_version.pre}" if cura_version.pre else ""
  120. build_tag = f"+{cura_version.build}" if cura_version.build else ""
  121. internal_tag = f"+internal" if self.options.internal else ""
  122. cura_version = f"{cura_version.major}.{cura_version.minor}.{cura_version.patch}{pre_tag}{build_tag}{internal_tag}"
  123. self.output.info(f"Write CuraVersion.py to {self.recipe_folder}")
  124. with open(os.path.join(location, "CuraVersion.py"), "w") as f:
  125. f.write(cura_version_py.render(
  126. cura_app_name = self.name,
  127. cura_app_display_name = self._app_name,
  128. cura_version = cura_version,
  129. cura_version_full=self.version,
  130. cura_build_type="Enterprise" if self.options.enterprise else "",
  131. cura_debug_mode = self.options.cura_debug_mode,
  132. cura_cloud_api_root = self.conan_data["urls"][self._urls]["cloud_api_root"],
  133. cura_cloud_api_version = self.options.cloud_api_version,
  134. cura_cloud_account_api_root = self.conan_data["urls"][self._urls]["cloud_account_api_root"],
  135. cura_marketplace_root = self.conan_data["urls"][self._urls]["marketplace_root"],
  136. cura_digital_factory_url = self.conan_data["urls"][self._urls]["digital_factory_url"],
  137. cura_latest_url=self.conan_data["urls"][self._urls]["cura_latest_url"],
  138. conan_installs=self._conan_installs(),
  139. python_installs=self._python_installs(),
  140. ))
  141. def _delete_unwanted_binaries(self, root):
  142. dynamic_binary_file_exts = [".so", ".dylib", ".dll", ".pyd", ".pyi"]
  143. prohibited = [
  144. "qt5compat",
  145. "qtcharts",
  146. "qtcoap",
  147. "qtdatavis3d",
  148. "qtlottie",
  149. "qtmqtt",
  150. "qtnetworkauth",
  151. "qtquick3d",
  152. "quick3d",
  153. "qtquick3dphysics",
  154. "qtquicktimeline",
  155. "qtvirtualkeyboard",
  156. "qtwayland"
  157. ]
  158. forbiddens = [x.encode() for x in prohibited]
  159. to_remove_files = []
  160. to_remove_dirs = []
  161. for root, dir_, files in os.walk(root):
  162. for filename in files:
  163. if not any([(x in filename) for x in dynamic_binary_file_exts]):
  164. continue
  165. pathname = os.path.join(root, filename)
  166. still_exist = True
  167. for forbidden in prohibited:
  168. if forbidden.lower() in str(pathname).lower():
  169. to_remove_files.append(pathname)
  170. still_exist = False
  171. break
  172. if not still_exist:
  173. continue
  174. with open(pathname, "rb") as file:
  175. bytez = file.read().lower()
  176. for forbidden in forbiddens:
  177. if bytez.find(forbidden) >= 0:
  178. to_remove_files.append(pathname)
  179. for dirname in dir_:
  180. for forbidden in prohibited:
  181. if forbidden.lower() in str(dirname).lower():
  182. pathname = os.path.join(root, dirname)
  183. to_remove_dirs.append(pathname)
  184. break
  185. for file in to_remove_files:
  186. try:
  187. os.remove(file)
  188. print(f"deleted file: {file}")
  189. except Exception as ex:
  190. print(f"WARNING: Attempt to delete file {file} results in: {str(ex)}")
  191. for dir_ in to_remove_dirs:
  192. try:
  193. rmdir(self, dir_)
  194. print(f"deleted dir_: {dir_}")
  195. except Exception as ex:
  196. print(f"WARNING: Attempt to delete folder {dir_} results in: {str(ex)}")
  197. def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file,
  198. cura_source_folder):
  199. pyinstaller_metadata = self.conan_data["pyinstaller"]
  200. datas = []
  201. for data in pyinstaller_metadata["datas"].values():
  202. if (not self.options.internal and data.get("internal", False)) or (
  203. not self.options.enterprise and data.get("enterprise_only", False)):
  204. continue
  205. if "oses" in data and self.settings.os not in data["oses"]:
  206. continue
  207. if "package" in data: # get the paths from conan package
  208. if data["package"] == self.name:
  209. src_path = str(Path(cura_source_folder, data["src"]))
  210. else:
  211. if data["package"] not in self.dependencies:
  212. raise ConanException(f"Required package {data['package']} does not exist as a dependency")
  213. package_folder = self.dependencies[data['package']].package_folder
  214. if package_folder is None:
  215. raise ConanException(
  216. f"Unable to find package_folder for {data['package']}, check that it has not been skipped")
  217. src_path = os.path.join(self.dependencies[data["package"]].package_folder, data["src"])
  218. elif "root" in data: # get the paths relative from the install folder
  219. src_path = os.path.join(self.install_folder, data["root"], data["src"])
  220. else:
  221. raise ConanException(
  222. "Misformatted conan data for pyinstaller datas, expected either package or root option")
  223. if not Path(src_path).exists():
  224. raise ConanException(f"Missing folder {src_path} for pyinstaller data {data}")
  225. datas.append((str(src_path), data["dst"]))
  226. binaries = []
  227. for binary in pyinstaller_metadata["binaries"].values():
  228. if "package" in binary: # get the paths from conan package
  229. src_path = os.path.join(self.dependencies[binary["package"]].package_folder, binary["src"])
  230. elif "root" in binary: # get the paths relative from the sourcefolder
  231. src_path = str(Path(self.source_folder, binary["root"], binary["src"]))
  232. if self.settings.os == "Windows":
  233. src_path = src_path.replace("\\", "\\\\")
  234. else:
  235. raise ConanException(
  236. "Misformatted conan data for pyinstaller binaries, expected either package or root option")
  237. if not Path(src_path).exists():
  238. raise ConanException(f"Missing folder {src_path} for pyinstaller binary {binary}")
  239. for bin in Path(src_path).glob(binary["binary"] + "*[.exe|.dll|.so|.dylib|.so.]*"):
  240. binaries.append((str(bin), binary["dst"]))
  241. for bin in Path(src_path).glob(binary["binary"]):
  242. binaries.append((str(bin), binary["dst"]))
  243. # Make sure all Conan dependencies which are shared are added to the binary list for pyinstaller
  244. for _, dependency in self.dependencies.host.items():
  245. for bin_paths in dependency.cpp_info.bindirs:
  246. binaries.extend([(f"{p}", ".") for p in Path(bin_paths).glob("**/*.dll")])
  247. for lib_paths in dependency.cpp_info.libdirs:
  248. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.so*")])
  249. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.dylib*")])
  250. # Copy dynamic libs from lib path
  251. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.dylib*")])
  252. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.so*")])
  253. # Collect all dll's from PyQt6 and place them in the root
  254. binaries.extend([(f"{p}", ".") for p in Path(self._site_packages, "PyQt6", "Qt6").glob("**/*.dll")])
  255. with open(os.path.join(self.recipe_folder, "UltiMaker-Cura.spec.jinja"), "r") as f:
  256. pyinstaller = Template(f.read())
  257. version = self.conf.get("user.cura:version", default = self.version, check_type = str)
  258. cura_version = Version(version)
  259. # filter all binary files in binaries on the blacklist
  260. blacklist = pyinstaller_metadata["blacklist"]
  261. filtered_binaries = [b for b in binaries if
  262. not any([all([(part in b[0].lower()) for part in parts]) for parts in blacklist])]
  263. # In case the installer isn't actually pyinstaller (Windows at the moment), outright remove the offending files:
  264. specifically_delete = set(binaries) - set(filtered_binaries)
  265. for (unwanted_path, _) in specifically_delete:
  266. try:
  267. os.remove(unwanted_path)
  268. print(f"delete: {unwanted_path}")
  269. except Exception as ex:
  270. print(f"WARNING: Attempt to delete binary {unwanted_path} results in: {str(ex)}")
  271. hiddenimports = pyinstaller_metadata["hiddenimports"]
  272. collect_all = pyinstaller_metadata["collect_all"]
  273. if self.settings.os == "Windows":
  274. hiddenimports += pyinstaller_metadata["hiddenimports_WINDOWS_ONLY"]
  275. collect_all += pyinstaller_metadata["collect_all_WINDOWS_ONLY"]
  276. # Write the actual file:
  277. with open(os.path.join(location, "UltiMaker-Cura.spec"), "w") as f:
  278. f.write(pyinstaller.render(
  279. name = str(self.options.display_name).replace(" ", "-"),
  280. display_name = self._app_name,
  281. entrypoint = entrypoint_location,
  282. datas = datas,
  283. binaries=filtered_binaries,
  284. venv_script_path = str(self._script_dir),
  285. hiddenimports=hiddenimports,
  286. collect_all=collect_all,
  287. icon = icon_path,
  288. entitlements_file = entitlements_file,
  289. osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None",
  290. upx = str(self.settings.os == "Windows"),
  291. strip = False, # This should be possible on Linux and MacOS but, it can also cause issues on some distributions. Safest is to disable it for now
  292. target_arch = self._pyinstaller_spec_arch,
  293. macos = self.settings.os == "Macos",
  294. version = f"'{version}'",
  295. short_version = f"'{cura_version.major}.{cura_version.minor}.{cura_version.patch}'",
  296. ))
  297. def export(self):
  298. update_conandata(self, {"version": self.version})
  299. def export_sources(self):
  300. copy(self, "*", os.path.join(self.recipe_folder, "plugins"), os.path.join(self.export_sources_folder, "plugins"))
  301. copy(self, "*", os.path.join(self.recipe_folder, "resources"), os.path.join(self.export_sources_folder, "resources"), excludes = "*.mo")
  302. copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests"))
  303. copy(self, "*", os.path.join(self.recipe_folder, "cura"), os.path.join(self.export_sources_folder, "cura"), excludes="CuraVersion.py")
  304. copy(self, "*", os.path.join(self.recipe_folder, "packaging"), os.path.join(self.export_sources_folder, "packaging"))
  305. copy(self, "*", os.path.join(self.recipe_folder, ".run_templates"), os.path.join(self.export_sources_folder, ".run_templates"))
  306. copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
  307. def validate(self):
  308. if self.options.i18n_extract and self.settings.os == "Windows" and not self.conf.get(
  309. "tools.microsoft.bash:path", check_type=str):
  310. raise ConanInvalidConfiguration("Unable to extract translations on Windows without Bash installed")
  311. def requirements(self):
  312. for req in self.conan_data["requirements"]:
  313. if self.options.internal and "fdm_materials" in req:
  314. continue
  315. self.requires(req)
  316. if self.options.internal:
  317. for req in self.conan_data["requirements_internal"]:
  318. self.requires(req)
  319. if self.options.enterprise:
  320. for req in self.conan_data["requirements_enterprise"]:
  321. self.requires(req)
  322. self.requires("cpython/3.12.2")
  323. def layout(self):
  324. self.folders.source = "."
  325. self.folders.build = "build"
  326. self.folders.generators = os.path.join(self.folders.build, "generators")
  327. self.cpp.package.libdirs = [os.path.join("site-packages", "cura")]
  328. self.cpp.package.bindirs = ["bin"]
  329. self.cpp.package.resdirs = ["resources", "plugins", "packaging"]
  330. def generate(self):
  331. copy(self, "cura_app.py", self.source_folder, str(self._script_dir))
  332. self._generate_cura_version(str(Path(self.source_folder, "cura")))
  333. # Copy CuraEngine.exe to bindirs of Virtual Python Environment
  334. curaengine = self.dependencies["curaengine"].cpp_info
  335. copy(self, "CuraEngine.exe", curaengine.bindirs[0], self.source_folder, keep_path=False)
  336. copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path=False)
  337. # Copy the external plugins that we want to bundle with Cura
  338. if self.options.enterprise:
  339. rmdir(self, str(Path(self.source_folder, "plugins", "NativeCADplugin")))
  340. native_cad_plugin = self.dependencies["native_cad_plugin"].cpp_info
  341. copy(self, "*", native_cad_plugin.resdirs[0], str(Path(self.source_folder, "plugins", "NativeCADplugin")),
  342. keep_path=True)
  343. copy(self, "bundled_*.json", native_cad_plugin.resdirs[1],
  344. str(Path(self.source_folder, "resources", "bundled_packages")), keep_path=False)
  345. # Copy resources of cura_binary_data
  346. cura_binary_data = self.dependencies["cura_binary_data"].cpp_info
  347. copy(self, "*", cura_binary_data.resdirs[0], str(self._share_dir.joinpath("cura")), keep_path = True)
  348. copy(self, "*", cura_binary_data.resdirs[1], str(self._share_dir.joinpath("uranium")), keep_path = True)
  349. if self.settings.os == "Windows":
  350. copy(self, "*", cura_binary_data.resdirs[2], str(self._share_dir.joinpath("windows")), keep_path = True)
  351. for dependency in self.dependencies.host.values():
  352. for bindir in dependency.cpp_info.bindirs:
  353. self._delete_unwanted_binaries(bindir)
  354. copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
  355. for libdir in dependency.cpp_info.libdirs:
  356. self._delete_unwanted_binaries(libdir)
  357. copy(self, "*.pyd", libdir, str(self._site_packages), keep_path = False)
  358. copy(self, "*.pyi", libdir, str(self._site_packages), keep_path = False)
  359. copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
  360. # Copy materials (flat)
  361. rmdir(self, str(Path(self.source_folder, "resources", "materials")))
  362. fdm_materials = self.dependencies["fdm_materials"].cpp_info
  363. copy(self, "*", fdm_materials.resdirs[0], self.source_folder)
  364. # Copy internal resources
  365. if self.options.internal:
  366. cura_private_data = self.dependencies["cura_private_data"].cpp_info
  367. copy(self, "*", cura_private_data.resdirs[0], str(self._share_dir.joinpath("cura")))
  368. if self.options.i18n_extract:
  369. vb = VirtualBuildEnv(self)
  370. vb.generate()
  371. pot = self.python_requires["translationextractor"].module.ExtractTranslations(self)
  372. pot.generate()
  373. def build(self):
  374. if self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
  375. self.output.warning(
  376. "Skipping generation of binary translation files because Bash could not be found and is required")
  377. return
  378. for po_file in Path(self.source_folder, "resources", "i18n").glob("**/*.po"):
  379. mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_folder))
  380. mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)
  381. mkdir(self, str(unix_path(self, Path(mo_file).parent)))
  382. self.run(f"msgfmt {po_file} -o {mo_file} -f", env="conanbuild")
  383. def deploy(self):
  384. ''' Note: this deploy step is actually used to prepare for building a Cura distribution with pyinstaller, which is not
  385. the original purpose in the Conan philosophy '''
  386. copy(self, "*", os.path.join(self.package_folder, self.cpp.package.resdirs[2]),
  387. os.path.join(self.deploy_folder, "packaging"), keep_path=True)
  388. # Copy resources of Cura (keep folder structure) needed by pyinstaller to determine the module structure
  389. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.bindirs[0]), str(self._base_dir), keep_path = False)
  390. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.libdirs[0]), str(self._site_packages.joinpath("cura")), keep_path = True)
  391. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[0]), str(self._share_dir.joinpath("cura", "resources")), keep_path = True)
  392. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[1]), str(self._share_dir.joinpath("cura", "plugins")), keep_path = True)
  393. # Copy the cura_resources resources from the package
  394. rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  395. cura_resources = self.dependencies["cura_resources"].cpp_info
  396. for res_dir in cura_resources.resdirs:
  397. copy(self, "*", res_dir, str(self._share_dir.joinpath("cura", "resources", Path(res_dir).name)), keep_path = True)
  398. # Copy resources of Uranium (keep folder structure)
  399. uranium = self.dependencies["uranium"].cpp_info
  400. copy(self, "*", uranium.resdirs[0], str(self._share_dir.joinpath("uranium", "resources")), keep_path = True)
  401. copy(self, "*", uranium.resdirs[1], str(self._share_dir.joinpath("uranium", "plugins")), keep_path = True)
  402. copy(self, "*", uranium.libdirs[0], str(self._site_packages.joinpath("UM")), keep_path = True)
  403. self._generate_cura_version(os.path.join(self._site_packages, "cura"))
  404. self._delete_unwanted_binaries(self._site_packages)
  405. self._delete_unwanted_binaries(self.package_folder)
  406. self._delete_unwanted_binaries(self._base_dir)
  407. self._delete_unwanted_binaries(self._share_dir)
  408. entitlements_file = "'{}'".format(Path(self.deploy_folder, "packaging", "MacOS", "cura.entitlements"))
  409. self._generate_pyinstaller_spec(location=self.deploy_folder,
  410. entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  411. icon_path = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.resdirs[2], self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  412. entitlements_file=entitlements_file if self.settings.os == "Macos" else "None",
  413. cura_source_folder=self.package_folder)
  414. def package(self):
  415. copy(self, "cura_app.py", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.bindirs[0]))
  416. copy(self, "*", src = os.path.join(self.source_folder, "cura"), dst = os.path.join(self.package_folder, self.cpp.package.libdirs[0]))
  417. copy(self, "*", src = os.path.join(self.source_folder, "resources"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  418. copy(self, "*.mo", os.path.join(self.build_folder, "resources"), os.path.join(self.package_folder, "resources"))
  419. copy(self, "*", src = os.path.join(self.source_folder, "plugins"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[1]))
  420. copy(self, "*", src = os.path.join(self.source_folder, "packaging"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[2]))
  421. copy(self, "pip_requirements_*.txt", src=self.generators_folder,
  422. dst=os.path.join(self.package_folder, self.cpp.package.resdirs[-1]))
  423. # Remove the fdm_materials from the package
  424. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials"))
  425. # Remove the cura_resources resources from the package
  426. rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  427. cura_resources = self.dependencies["cura_resources"].cpp_info
  428. for res_dir in cura_resources.resdirs:
  429. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], Path(res_dir).name))
  430. def package_info(self):
  431. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "site-packages"))
  432. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "plugins"))
  433. def package_id(self):
  434. self.info.options.rm_safe("enable_i18n")