conanfile.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. # FIXME: Remove specific branch once merged to main
  23. python_requires = "translationextractor/[>=2.2.0]@ultimaker/cura_11622"
  24. options = {
  25. "enterprise": [True, False],
  26. "staging": [True, False],
  27. "devtools": [True, False], # FIXME: Split this up in testing and (development / build (pyinstaller) / system installer) tools
  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. "enable_i18n": [True, False],
  33. }
  34. default_options = {
  35. "enterprise": False,
  36. "staging": False,
  37. "devtools": False,
  38. "cloud_api_version": "1",
  39. "display_name": "UltiMaker Cura",
  40. "cura_debug_mode": False, # Not yet implemented
  41. "internal": False,
  42. "enable_i18n": False,
  43. }
  44. def set_version(self):
  45. if not self.version:
  46. self.version = self.conan_data["version"]
  47. @property
  48. def _i18n_options(self):
  49. return self.conf.get("user.i18n:options", default = {"extract": True, "build": True}, check_type = dict)
  50. # FIXME: These env vars should be defined in the runenv.
  51. _cura_env = None
  52. @property
  53. def _cura_run_env(self):
  54. if self._cura_env:
  55. return self._cura_env
  56. self._cura_env = Environment()
  57. self._cura_env.define("QML2_IMPORT_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "qml")))
  58. self._cura_env.define("QT_PLUGIN_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "plugins")))
  59. self._cura_env.define("CURA_DATA_ROOT", str(self._share_dir.joinpath("cura")))
  60. if self.settings.os == "Linux":
  61. self._cura_env.define("QT_QPA_FONTDIR", "/usr/share/fonts")
  62. self._cura_env.define("QT_QPA_PLATFORMTHEME", "xdgdesktopportal")
  63. self._cura_env.define("QT_XKB_CONFIG_ROOT", "/usr/share/X11/xkb")
  64. return self._cura_env
  65. @property
  66. def _app_name(self):
  67. if self.options.enterprise:
  68. return str(self.options.display_name) + " Enterprise"
  69. return str(self.options.display_name)
  70. @property
  71. def _urls(self):
  72. if self.options.staging:
  73. return "staging"
  74. return "default"
  75. @property
  76. def _base_dir(self):
  77. return Path(self.source_folder, "venv")
  78. @property
  79. def _share_dir(self):
  80. return self._base_dir.joinpath("share")
  81. @property
  82. def _script_dir(self):
  83. if self.settings.os == "Windows":
  84. return self._base_dir.joinpath("Scripts")
  85. return self._base_dir.joinpath("bin")
  86. @property
  87. def _site_packages(self):
  88. if self.settings.os == "Windows":
  89. return self._base_dir.joinpath("Lib", "site-packages")
  90. py_version = Version(self.dependencies["cpython"].ref.version)
  91. return self._base_dir.joinpath("lib", f"python{py_version.major}.{py_version.minor}", "site-packages")
  92. @property
  93. def _py_interp(self):
  94. py_interp = self._script_dir.joinpath(Path(self.deps_user_info["cpython"].python).name)
  95. if self.settings.os == "Windows":
  96. py_interp = Path(*[f'"{p}"' if " " in p else p for p in py_interp.parts])
  97. return py_interp
  98. @property
  99. def _pyinstaller_spec_arch(self):
  100. if self.settings.os == "Macos":
  101. if self.settings.arch == "armv8":
  102. return "'arm64'"
  103. return "'x86_64'"
  104. return "None"
  105. def _conan_installs(self):
  106. self.output.info("Collecting conan installs")
  107. conan_installs = {}
  108. # list of conan installs
  109. for dependency in self.dependencies.host.values():
  110. conan_installs[dependency.ref.name] = {
  111. "version": str(dependency.ref.version),
  112. "revision": dependency.ref.revision
  113. }
  114. return conan_installs
  115. def _python_installs(self):
  116. self.output.info("Collecting python installs")
  117. python_installs = {}
  118. # list of python installs
  119. run_env = VirtualRunEnv(self)
  120. env = run_env.environment()
  121. env.prepend_path("PYTHONPATH", str(self._site_packages.as_posix()))
  122. venv_vars = env.vars(self, scope = "run")
  123. outer = '"' if self.settings.os == "Windows" else "'"
  124. inner = "'" if self.settings.os == "Windows" else '"'
  125. buffer = StringIO()
  126. with venv_vars.apply():
  127. self.run(f"""python -c {outer}import importlib.metadata; print({inner};{inner}.join([(package.metadata[{inner}Name{inner}]+{inner},{inner}+ package.metadata[{inner}Version{inner}]) for package in importlib.metadata.distributions()])){outer}""",
  128. env = "conanrun",
  129. stdout = buffer)
  130. packages = str(buffer.getvalue()).strip('\r\n').split(";")
  131. for package in packages:
  132. name, version = package.split(",")
  133. python_installs[name] = {"version": version}
  134. return python_installs
  135. def _generate_cura_version(self, location):
  136. with open(os.path.join(self.recipe_folder, "CuraVersion.py.jinja"), "r") as f:
  137. cura_version_py = Template(f.read())
  138. # If you want a specific Cura version to show up on the splash screen add the user configuration `user.cura:version=VERSION`
  139. # the global.conf, profile, package_info (of dependency) or via the cmd line `-c user.cura:version=VERSION`
  140. cura_version = Version(self.conf.get("user.cura:version", default = self.version, check_type = str))
  141. pre_tag = f"-{cura_version.pre}" if cura_version.pre else ""
  142. build_tag = f"+{cura_version.build}" if cura_version.build else ""
  143. internal_tag = f"+internal" if self.options.internal else ""
  144. cura_version = f"{cura_version.major}.{cura_version.minor}.{cura_version.patch}{pre_tag}{build_tag}{internal_tag}"
  145. with open(os.path.join(location, "CuraVersion.py"), "w") as f:
  146. f.write(cura_version_py.render(
  147. cura_app_name = self.name,
  148. cura_app_display_name = self._app_name,
  149. cura_version = cura_version,
  150. cura_build_type = "Enterprise" if self.options.enterprise else "",
  151. cura_debug_mode = self.options.cura_debug_mode,
  152. cura_cloud_api_root = self.conan_data["urls"][self._urls]["cloud_api_root"],
  153. cura_cloud_api_version = self.options.cloud_api_version,
  154. cura_cloud_account_api_root = self.conan_data["urls"][self._urls]["cloud_account_api_root"],
  155. cura_marketplace_root = self.conan_data["urls"][self._urls]["marketplace_root"],
  156. cura_digital_factory_url = self.conan_data["urls"][self._urls]["digital_factory_url"],
  157. cura_latest_url=self.conan_data["urls"][self._urls]["cura_latest_url"],
  158. conan_installs=self._conan_installs(),
  159. python_installs=self._python_installs(),
  160. ))
  161. def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
  162. pyinstaller_metadata = self.conan_data["pyinstaller"]
  163. datas = []
  164. for data in pyinstaller_metadata["datas"].values():
  165. if not self.options.internal and data.get("internal", False):
  166. continue
  167. if "package" in data: # get the paths from conan package
  168. if data["package"] == self.name:
  169. if self.in_local_cache:
  170. src_path = str(Path(self.package_folder, data["src"]))
  171. else:
  172. src_path = str(Path(self.source_folder, data["src"]))
  173. else:
  174. if data["package"] not in self.deps_cpp_info.deps:
  175. continue
  176. src_path = os.path.join(self.deps_cpp_info[data["package"]].rootpath, data["src"])
  177. elif "root" in data: # get the paths relative from the install folder
  178. src_path = os.path.join(self.install_folder, data["root"], data["src"])
  179. else:
  180. continue
  181. if Path(src_path).exists():
  182. datas.append((str(src_path), data["dst"]))
  183. binaries = []
  184. for binary in pyinstaller_metadata["binaries"].values():
  185. if "package" in binary: # get the paths from conan package
  186. src_path = os.path.join(self.deps_cpp_info[binary["package"]].rootpath, binary["src"])
  187. elif "root" in binary: # get the paths relative from the sourcefolder
  188. src_path = str(Path(self.source_folder, binary["root"], binary["src"]))
  189. if self.settings.os == "Windows":
  190. src_path = src_path.replace("\\", "\\\\")
  191. else:
  192. continue
  193. if not Path(src_path).exists():
  194. self.output.warning(f"Source path for binary {binary['binary']} does not exist")
  195. continue
  196. for bin in Path(src_path).glob(binary["binary"] + "*[.exe|.dll|.so|.dylib|.so.]*"):
  197. binaries.append((str(bin), binary["dst"]))
  198. for bin in Path(src_path).glob(binary["binary"]):
  199. binaries.append((str(bin), binary["dst"]))
  200. # Make sure all Conan dependencies which are shared are added to the binary list for pyinstaller
  201. for _, dependency in self.dependencies.host.items():
  202. for bin_paths in dependency.cpp_info.bindirs:
  203. binaries.extend([(f"{p}", ".") for p in Path(bin_paths).glob("**/*.dll")])
  204. for lib_paths in dependency.cpp_info.libdirs:
  205. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.so*")])
  206. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.dylib*")])
  207. # Copy dynamic libs from lib path
  208. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.dylib*")])
  209. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.so*")])
  210. # Collect all dll's from PyQt6 and place them in the root
  211. binaries.extend([(f"{p}", ".") for p in Path(self._site_packages, "PyQt6", "Qt6").glob("**/*.dll")])
  212. with open(os.path.join(self.recipe_folder, "UltiMaker-Cura.spec.jinja"), "r") as f:
  213. pyinstaller = Template(f.read())
  214. version = self.conf.get("user.cura:version", default = self.version, check_type = str)
  215. cura_version = Version(version)
  216. with open(os.path.join(location, "UltiMaker-Cura.spec"), "w") as f:
  217. f.write(pyinstaller.render(
  218. name = str(self.options.display_name).replace(" ", "-"),
  219. display_name = self._app_name,
  220. entrypoint = entrypoint_location,
  221. datas = datas,
  222. binaries = binaries,
  223. venv_script_path = str(self._script_dir),
  224. hiddenimports = pyinstaller_metadata["hiddenimports"],
  225. collect_all = pyinstaller_metadata["collect_all"],
  226. icon = icon_path,
  227. entitlements_file = entitlements_file,
  228. osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None",
  229. upx = str(self.settings.os == "Windows"),
  230. 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
  231. target_arch = self._pyinstaller_spec_arch,
  232. macos = self.settings.os == "Macos",
  233. version = f"'{version}'",
  234. short_version = f"'{cura_version.major}.{cura_version.minor}.{cura_version.patch}'",
  235. ))
  236. def export(self):
  237. update_conandata(self, {"version": self.version})
  238. def export_sources(self):
  239. copy(self, "*", os.path.join(self.recipe_folder, "plugins"), os.path.join(self.export_sources_folder, "plugins"))
  240. copy(self, "*", os.path.join(self.recipe_folder, "resources"), os.path.join(self.export_sources_folder, "resources"), excludes = "*.mo")
  241. copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests"))
  242. copy(self, "*", os.path.join(self.recipe_folder, "cura"), os.path.join(self.export_sources_folder, "cura"), excludes="CuraVersion.py")
  243. copy(self, "*", os.path.join(self.recipe_folder, "packaging"), os.path.join(self.export_sources_folder, "packaging"))
  244. copy(self, "*", os.path.join(self.recipe_folder, ".run_templates"), os.path.join(self.export_sources_folder, ".run_templates"))
  245. copy(self, "requirements.txt", self.recipe_folder, self.export_sources_folder)
  246. copy(self, "requirements-dev.txt", self.recipe_folder, self.export_sources_folder)
  247. copy(self, "requirements-ultimaker.txt", self.recipe_folder, self.export_sources_folder)
  248. copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
  249. def config_options(self):
  250. if self.settings.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", check_type=str):
  251. del self.options.enable_i18n
  252. def validate(self):
  253. version = self.conf.get("user.cura:version", default = self.version, check_type = str)
  254. if version and Version(version) <= Version("4"):
  255. raise ConanInvalidConfiguration("Only versions 5+ are support")
  256. def requirements(self):
  257. for req in self.conan_data["requirements"]:
  258. if self.options.internal and "fdm_materials" in req:
  259. continue
  260. self.requires(req)
  261. if self.options.internal:
  262. for req in self.conan_data["requirements_internal"]:
  263. self.requires(req)
  264. if self.options.enterprise:
  265. for req in self.conan_data["requirements_enterprise"]:
  266. self.requires(req)
  267. self.requires("cpython/3.12.2")
  268. def build_requirements(self):
  269. if self.options.get_safe("enable_i18n", False):
  270. self.test_requires("gettext/0.21")
  271. def layout(self):
  272. self.folders.source = "."
  273. self.folders.build = "venv"
  274. self.folders.generators = os.path.join(self.folders.build, "conan")
  275. self.cpp.package.libdirs = [os.path.join("site-packages", "cura")]
  276. self.cpp.package.bindirs = ["bin"]
  277. self.cpp.package.resdirs = ["resources", "plugins", "packaging"]
  278. def generate(self):
  279. copy(self, "cura_app.py", self.source_folder, str(self._script_dir))
  280. cura_run_envvars = self._cura_run_env.vars(self, scope = "run")
  281. ext = ".ps1" if self.settings.os == "Windows" else ".sh"
  282. cura_run_envvars.save_script(os.path.join(self.folders.generators, f"cura_run_environment{ext}"))
  283. vr = VirtualRunEnv(self)
  284. vr.generate()
  285. self._generate_cura_version(str(Path(self.source_folder, "cura")))
  286. # Copy CuraEngine.exe to bindirs of Virtual Python Environment
  287. curaengine = self.dependencies["curaengine"].cpp_info
  288. copy(self, "CuraEngine.exe", curaengine.bindirs[0], self.source_folder, keep_path = False)
  289. copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path = False)
  290. # Copy the external plugins that we want to bundle with Cura
  291. if self.options.enterprise:
  292. rmdir(self, str(Path(self.source_folder, "plugins", "NativeCADplugin")))
  293. native_cad_plugin = self.dependencies["native_cad_plugin"].cpp_info
  294. copy(self, "*", native_cad_plugin.resdirs[0], str(Path(self.source_folder, "plugins", "NativeCADplugin")), keep_path = True)
  295. copy(self, "bundled_*.json", native_cad_plugin.resdirs[1], str(Path(self.source_folder, "resources", "bundled_packages")), keep_path = False)
  296. # Copy resources of cura_binary_data
  297. cura_binary_data = self.dependencies["cura_binary_data"].cpp_info
  298. copy(self, "*", cura_binary_data.resdirs[0], str(self._share_dir.joinpath("cura")), keep_path = True)
  299. copy(self, "*", cura_binary_data.resdirs[1], str(self._share_dir.joinpath("uranium")), keep_path = True)
  300. if self.settings.os == "Windows":
  301. copy(self, "*", cura_binary_data.resdirs[2], str(self._share_dir.joinpath("windows")), keep_path = True)
  302. for dependency in self.dependencies.host.values():
  303. for bindir in dependency.cpp_info.bindirs:
  304. copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
  305. for libdir in dependency.cpp_info.libdirs:
  306. copy(self, "*.pyd", libdir, str(self._site_packages), keep_path = False)
  307. copy(self, "*.pyi", libdir, str(self._site_packages), keep_path = False)
  308. copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
  309. # Copy materials (flat)
  310. rmdir(self, str(Path(self.source_folder, "resources", "materials")))
  311. fdm_materials = self.dependencies["fdm_materials"].cpp_info
  312. copy(self, "*", fdm_materials.resdirs[0], self.source_folder)
  313. # Copy internal resources
  314. if self.options.internal:
  315. cura_private_data = self.dependencies["cura_private_data"].cpp_info
  316. copy(self, "*", cura_private_data.resdirs[0], str(self._share_dir.joinpath("cura")))
  317. if self.options.devtools:
  318. entitlements_file = "'{}'".format(str(Path(self.source_folder, "packaging", "MacOS", "cura.entitlements")))
  319. self._generate_pyinstaller_spec(
  320. location=self.generators_folder,
  321. entrypoint_location="'{}'".format(
  322. os.path.join(self.source_folder, self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace(
  323. "\\", "\\\\"),
  324. icon_path="'{}'".format(os.path.join(self.source_folder, "packaging",
  325. self.conan_data["pyinstaller"]["icon"][
  326. str(self.settings.os)])).replace("\\", "\\\\"),
  327. entitlements_file=entitlements_file if self.settings.os == "Macos" else "None"
  328. )
  329. if self.options.get_safe("enable_i18n", False) and self._i18n_options["extract"]:
  330. vb = VirtualBuildEnv(self)
  331. vb.generate()
  332. # # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  333. cpp_info = self.dependencies["gettext"].cpp_info
  334. pot = self.python_requires["translationextractor"].module.ExtractTranslations(self, cpp_info.bindirs[0])
  335. pot.generate()
  336. def build(self):
  337. if self.options.get_safe("enable_i18n", False) and self._i18n_options["build"]:
  338. for po_file in Path(self.source_folder, "resources", "i18n").glob("**/*.po"):
  339. mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_folder))
  340. mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)
  341. mkdir(self, str(unix_path(self, Path(mo_file).parent)))
  342. cpp_info = self.dependencies["gettext"].cpp_info
  343. self.run(f"{cpp_info.bindirs[0]}/msgfmt {po_file} -o {mo_file} -f", env="conanbuild", ignore_errors=True)
  344. def deploy(self):
  345. copy(self, "*", os.path.join(self.package_folder, self.cpp.package.resdirs[2]), os.path.join(self.install_folder, "packaging"), keep_path = True)
  346. # Copy resources of Cura (keep folder structure) needed by pyinstaller to determine the module structure
  347. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.bindirs[0]), str(self._base_dir), keep_path = False)
  348. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.libdirs[0]), str(self._site_packages.joinpath("cura")), keep_path = True)
  349. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[0]), str(self._share_dir.joinpath("cura", "resources")), keep_path = True)
  350. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[1]), str(self._share_dir.joinpath("cura", "plugins")), keep_path = True)
  351. # Copy the cura_resources resources from the package
  352. rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  353. cura_resources = self.dependencies["cura_resources"].cpp_info
  354. for res_dir in cura_resources.resdirs:
  355. copy(self, "*", res_dir, str(self._share_dir.joinpath("cura", "resources", Path(res_dir).name)), keep_path = True)
  356. # Copy resources of Uranium (keep folder structure)
  357. uranium = self.dependencies["uranium"].cpp_info
  358. copy(self, "*", uranium.resdirs[0], str(self._share_dir.joinpath("uranium", "resources")), keep_path = True)
  359. copy(self, "*", uranium.resdirs[1], str(self._share_dir.joinpath("uranium", "plugins")), keep_path = True)
  360. copy(self, "*", uranium.libdirs[0], str(self._site_packages.joinpath("UM")), keep_path = True)
  361. # Generate the GitHub Action version info Environment
  362. version = self.conf.get("user.cura:version", default = self.version, check_type = str)
  363. cura_version = Version(version)
  364. env_prefix = "Env:" if self.settings.os == "Windows" else ""
  365. activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
  366. echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
  367. echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
  368. echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
  369. echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
  370. echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
  371. """).render(cura_version_major = cura_version.major,
  372. cura_version_minor = cura_version.minor,
  373. cura_version_patch = cura_version.patch,
  374. cura_version_build = cura_version.build if cura_version.build != "" else "0",
  375. cura_version_full = self.version,
  376. cura_app_name = self._app_name,
  377. env_prefix = env_prefix)
  378. ext = ".sh" if self.settings.os != "Windows" else ".ps1"
  379. save(self, os.path.join(self._script_dir, f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)
  380. self._generate_cura_version(os.path.join(self._site_packages, "cura"))
  381. entitlements_file = "'{}'".format(Path(self.cpp_info.res_paths[2], "MacOS", "cura.entitlements"))
  382. self._generate_pyinstaller_spec(location = self._base_dir,
  383. entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  384. icon_path = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.resdirs[2], self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  385. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  386. def package(self):
  387. copy(self, "cura_app.py", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.bindirs[0]))
  388. copy(self, "*", src = os.path.join(self.source_folder, "cura"), dst = os.path.join(self.package_folder, self.cpp.package.libdirs[0]))
  389. copy(self, "*", src = os.path.join(self.source_folder, "resources"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  390. copy(self, "*.mo", os.path.join(self.build_folder, "resources"), os.path.join(self.package_folder, "resources"))
  391. copy(self, "*", src = os.path.join(self.source_folder, "plugins"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[1]))
  392. copy(self, "requirement*.txt", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.resdirs[-1]))
  393. copy(self, "*", src = os.path.join(self.source_folder, "packaging"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[2]))
  394. # Remove the fdm_materials from the package
  395. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials"))
  396. # Remove the cura_resources resources from the package
  397. rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  398. cura_resources = self.dependencies["cura_resources"].cpp_info
  399. for res_dir in cura_resources.resdirs:
  400. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], Path(res_dir).name))
  401. def package_info(self):
  402. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "site-packages"))
  403. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "plugins"))
  404. def package_id(self):
  405. # The following options shouldn't be used to determine the hash, since these are only used to set the CuraVersion.py
  406. # which will als be generated by the deploy method during the `conan install cura/5.1.0@_/_`
  407. del self.info.options.enterprise
  408. del self.info.options.staging
  409. del self.info.options.devtools
  410. del self.info.options.cloud_api_version
  411. del self.info.options.display_name
  412. del self.info.options.cura_debug_mode
  413. self.info.options.rm_safe("enable_i18n")