conanfile.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. import os
  2. from pathlib import Path
  3. from jinja2 import Template
  4. from conan import ConanFile
  5. from conan.tools.files import copy, rmdir, save, mkdir
  6. from conan.tools.microsoft import unix_path
  7. from conan.tools.env import VirtualRunEnv, Environment
  8. from conan.tools.scm import Version
  9. from conan.errors import ConanInvalidConfiguration, ConanException
  10. required_conan_version = ">=1.52.0"
  11. class CuraConan(ConanFile):
  12. name = "cura"
  13. license = "LGPL-3.0"
  14. author = "UltiMaker"
  15. url = "https://github.com/Ultimaker/cura"
  16. description = "3D printer / slicing GUI built on top of the Uranium framework"
  17. topics = ("conan", "python", "pyqt5", "qt", "qml", "3d-printing", "slicer")
  18. build_policy = "missing"
  19. exports = "LICENSE*", "UltiMaker-Cura.spec.jinja", "CuraVersion.py.jinja"
  20. settings = "os", "compiler", "build_type", "arch"
  21. no_copy_source = True # We won't build so no need to copy sources to the build folder
  22. # FIXME: Remove specific branch once merged to main
  23. # Extending the conanfile with the UMBaseConanfile https://github.com/Ultimaker/conan-ultimaker-index/tree/CURA-9177_Fix_CI_CD/recipes/umbase
  24. python_requires = "umbase/[>=0.1.7]@ultimaker/stable"
  25. python_requires_extend = "umbase.UMBaseConanfile"
  26. options = {
  27. "enterprise": ["True", "False", "true", "false"], # Workaround for GH Action passing boolean as lowercase string
  28. "staging": ["True", "False", "true", "false"], # Workaround for GH Action passing boolean as lowercase string
  29. "devtools": [True, False], # FIXME: Split this up in testing and (development / build (pyinstaller) / system installer) tools
  30. "cloud_api_version": "ANY",
  31. "display_name": "ANY", # TODO: should this be an option??
  32. "cura_debug_mode": [True, False], # FIXME: Use profiles
  33. "internal": [True, False]
  34. }
  35. default_options = {
  36. "enterprise": "False",
  37. "staging": "False",
  38. "devtools": False,
  39. "cloud_api_version": "1",
  40. "display_name": "UltiMaker Cura",
  41. "cura_debug_mode": False, # Not yet implemented
  42. "internal": False,
  43. }
  44. scm = {
  45. "type": "git",
  46. "subfolder": ".",
  47. "url": "auto",
  48. "revision": "auto"
  49. }
  50. @property
  51. def _pycharm_targets(self):
  52. return self.conan_data["pycharm_targets"]
  53. # FIXME: These env vars should be defined in the runenv.
  54. _cura_env = None
  55. @property
  56. def _cura_run_env(self):
  57. if self._cura_env:
  58. return self._cura_env
  59. self._cura_env = Environment()
  60. self._cura_env.define("QML2_IMPORT_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "qml")))
  61. self._cura_env.define("QT_PLUGIN_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "plugins")))
  62. if self.settings.os == "Linux":
  63. self._cura_env.define("QT_QPA_FONTDIR", "/usr/share/fonts")
  64. self._cura_env.define("QT_QPA_PLATFORMTHEME", "xdgdesktopportal")
  65. self._cura_env.define("QT_XKB_CONFIG_ROOT", "/usr/share/X11/xkb")
  66. return self._cura_env
  67. @property
  68. def _staging(self):
  69. return self.options.staging in ["True", 'true']
  70. @property
  71. def _enterprise(self):
  72. return self.options.enterprise in ["True", 'true']
  73. @property
  74. def _cloud_api_root(self):
  75. return "https://api-staging.ultimaker.com" if self._staging else "https://api.ultimaker.com"
  76. @property
  77. def _cloud_account_api_root(self):
  78. return "https://account-staging.ultimaker.com" if self._staging else "https://account.ultimaker.com"
  79. @property
  80. def _marketplace_root(self):
  81. return "https://marketplace-staging.ultimaker.com" if self._staging else "https://marketplace.ultimaker.com"
  82. @property
  83. def _digital_factory_url(self):
  84. return "https://digitalfactory-staging.ultimaker.com" if self._staging else "https://digitalfactory.ultimaker.com"
  85. @property
  86. def _cura_latest_url(self):
  87. return "https://software.ultimaker.com/latest.json"
  88. @property
  89. def requirements_txts(self):
  90. if self.options.devtools:
  91. return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"]
  92. return ["requirements.txt", "requirements-ultimaker.txt"]
  93. @property
  94. def _base_dir(self):
  95. if self.install_folder is None:
  96. if self.build_folder is not None:
  97. return Path(self.build_folder)
  98. return Path(os.getcwd(), "venv")
  99. if self.in_local_cache:
  100. return Path(self.install_folder)
  101. else:
  102. return Path(self.source_folder, "venv")
  103. @property
  104. def _share_dir(self):
  105. return self._base_dir.joinpath("share")
  106. @property
  107. def _script_dir(self):
  108. if self.settings.os == "Windows":
  109. return self._base_dir.joinpath("Scripts")
  110. return self._base_dir.joinpath("bin")
  111. @property
  112. def _site_packages(self):
  113. if self.settings.os == "Windows":
  114. return self._base_dir.joinpath("Lib", "site-packages")
  115. py_version = Version(self.deps_cpp_info["cpython"].version)
  116. return self._base_dir.joinpath("lib", f"python{py_version.major}.{py_version.minor}", "site-packages")
  117. @property
  118. def _py_interp(self):
  119. py_interp = self._script_dir.joinpath(Path(self.deps_user_info["cpython"].python).name)
  120. if self.settings.os == "Windows":
  121. py_interp = Path(*[f'"{p}"' if " " in p else p for p in py_interp.parts])
  122. return py_interp
  123. def _generate_cura_version(self, location):
  124. with open(Path(__file__).parent.joinpath("CuraVersion.py.jinja"), "r") as f:
  125. cura_version_py = Template(f.read())
  126. # If you want a specific Cura version to show up on the splash screen add the user configuration `user.cura:version=VERSION`
  127. # the global.conf, profile, package_info (of dependency) or via the cmd line `-c user.cura:version=VERSION`
  128. cura_version = Version(self.conf.get("user.cura:version", default = self.version, check_type = str))
  129. pre_tag = f"-{cura_version.pre}" if cura_version.pre else ""
  130. build_tag = f"+{cura_version.build}" if cura_version.build else ""
  131. internal_tag = f"+internal" if self.options.internal else ""
  132. cura_version = f"{cura_version.major}.{cura_version.minor}.{cura_version.patch}{pre_tag}{build_tag}{internal_tag}"
  133. with open(Path(location, "CuraVersion.py"), "w") as f:
  134. f.write(cura_version_py.render(
  135. cura_app_name = self.name,
  136. cura_app_display_name = self.options.display_name,
  137. cura_version = cura_version,
  138. cura_build_type = "Enterprise" if self._enterprise else "",
  139. cura_debug_mode = self.options.cura_debug_mode,
  140. cura_cloud_api_root = self._cloud_api_root,
  141. cura_cloud_api_version = self.options.cloud_api_version,
  142. cura_cloud_account_api_root = self._cloud_account_api_root,
  143. cura_marketplace_root = self._marketplace_root,
  144. cura_digital_factory_url = self._digital_factory_url,
  145. cura_latest_url = self._cura_latest_url))
  146. def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
  147. pyinstaller_metadata = self._um_data()["pyinstaller"]
  148. datas = [(str(self._base_dir.joinpath("conan_install_info.json")), ".")]
  149. for data in pyinstaller_metadata["datas"].values():
  150. if not self.options.internal and data.get("internal", False):
  151. continue
  152. if "package" in data: # get the paths from conan package
  153. if data["package"] == self.name:
  154. if self.in_local_cache:
  155. src_path = Path(self.package_folder, data["src"])
  156. else:
  157. src_path = Path(self.source_folder, data["src"])
  158. else:
  159. src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"])
  160. elif "root" in data: # get the paths relative from the sourcefolder
  161. src_path = Path(self.source_folder, data["root"], data["src"])
  162. else:
  163. continue
  164. if src_path.exists():
  165. datas.append((str(src_path), data["dst"]))
  166. binaries = []
  167. for binary in pyinstaller_metadata["binaries"].values():
  168. if "package" in binary: # get the paths from conan package
  169. src_path = Path(self.deps_cpp_info[binary["package"]].rootpath, binary["src"])
  170. elif "root" in binary: # get the paths relative from the sourcefolder
  171. src_path = Path(self.source_folder, binary["root"], binary["src"])
  172. else:
  173. continue
  174. if not src_path.exists():
  175. self.output.warning(f"Source path for binary {binary['binary']} does not exist")
  176. continue
  177. for bin in src_path.glob(binary["binary"] + "*[.exe|.dll|.so|.dylib|.so.]*"):
  178. binaries.append((str(bin), binary["dst"]))
  179. for bin in src_path.glob(binary["binary"]):
  180. binaries.append((str(bin), binary["dst"]))
  181. # Make sure all Conan dependencies which are shared are added to the binary list for pyinstaller
  182. for _, dependency in self.dependencies.host.items():
  183. for bin_paths in dependency.cpp_info.bindirs:
  184. binaries.extend([(f"{p}", ".") for p in Path(bin_paths).glob("**/*.dll")])
  185. for lib_paths in dependency.cpp_info.libdirs:
  186. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.so*")])
  187. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.dylib*")])
  188. # Copy dynamic libs from lib path
  189. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.dylib*")])
  190. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.so*")])
  191. # Collect all dll's from PyQt6 and place them in the root
  192. binaries.extend([(f"{p}", ".") for p in Path(self._site_packages, "PyQt6", "Qt6").glob("**/*.dll")])
  193. with open(Path(__file__).parent.joinpath("UltiMaker-Cura.spec.jinja"), "r") as f:
  194. pyinstaller = Template(f.read())
  195. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  196. cura_version = Version(version)
  197. with open(Path(location, "UltiMaker-Cura.spec"), "w") as f:
  198. f.write(pyinstaller.render(
  199. name = str(self.options.display_name).replace(" ", "-"),
  200. display_name = self.options.display_name,
  201. entrypoint = entrypoint_location,
  202. datas = datas,
  203. binaries = binaries,
  204. venv_script_path = str(self._script_dir),
  205. hiddenimports = pyinstaller_metadata["hiddenimports"],
  206. collect_all = pyinstaller_metadata["collect_all"],
  207. icon = icon_path,
  208. entitlements_file = entitlements_file,
  209. osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None",
  210. upx = str(self.settings.os == "Windows"),
  211. 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
  212. target_arch = "'x86_64'" if self.settings.os == "Macos" else "None", # FIXME: Make this dependent on the settings.arch_target
  213. macos = self.settings.os == "Macos",
  214. version = f"'{version}'",
  215. short_version = f"'{cura_version.major}.{cura_version.minor}.{cura_version.patch}'",
  216. ))
  217. def set_version(self):
  218. if self.version is None:
  219. self.version = self._umdefault_version()
  220. def configure(self):
  221. self.options["pyarcus"].shared = True
  222. self.options["pysavitar"].shared = True
  223. self.options["pynest2d"].shared = True
  224. self.options["cpython"].shared = True
  225. def validate(self):
  226. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  227. if version and Version(version) <= Version("4"):
  228. raise ConanInvalidConfiguration("Only versions 5+ are support")
  229. def requirements(self):
  230. for req in self._um_data()["requirements"]:
  231. self.requires(req)
  232. if self.options.internal:
  233. for req in self._um_data()["internal_requirements"]:
  234. self.requires(req)
  235. def build_requirements(self):
  236. if self.options.devtools:
  237. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  238. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  239. self.tool_requires("gettext/0.21", force_host_context=True)
  240. def layout(self):
  241. self.folders.source = "."
  242. self.folders.build = "venv"
  243. self.folders.generators = Path(self.folders.build, "conan")
  244. self.cpp.package.libdirs = [os.path.join("site-packages", "cura")]
  245. self.cpp.package.bindirs = ["bin"]
  246. self.cpp.package.resdirs = ["resources", "plugins", "packaging", "pip_requirements"] # pip_requirements should be the last item in the list
  247. def build(self):
  248. if self.options.devtools:
  249. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  250. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  251. cpp_info = self.dependencies["gettext"].cpp_info
  252. for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
  253. mo_file = self.build_path.joinpath(po_file.with_suffix('.mo').relative_to(self.source_path))
  254. mkdir(self, str(unix_path(self, mo_file.parent)))
  255. self.run(f"{cpp_info.bindirs[0]}/msgfmt {po_file} -o {mo_file} -f", env="conanbuild", ignore_errors=True)
  256. def generate(self):
  257. cura_run_envvars = self._cura_run_env.vars(self, scope = "run")
  258. ext = ".ps1" if self.settings.os == "Windows" else ".sh"
  259. cura_run_envvars.save_script(self.folders.generators.joinpath(f"cura_run_environment{ext}"))
  260. vr = VirtualRunEnv(self)
  261. vr.generate()
  262. self._generate_cura_version(Path(self.source_folder, "cura"))
  263. if self.options.devtools:
  264. entitlements_file = "'{}'".format(Path(self.source_folder, "packaging", "dmg", "cura.entitlements"))
  265. self._generate_pyinstaller_spec(location = self.generators_folder,
  266. entrypoint_location = "'{}'".format(Path(self.source_folder, self._um_data()["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  267. icon_path = "'{}'".format(Path(self.source_folder, "packaging", self._um_data()["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  268. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  269. # Update the po files
  270. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  271. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  272. cpp_info = self.dependencies["gettext"].cpp_info
  273. for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
  274. pot_file = self.source_path.joinpath("resources", "i18n", po_file.with_suffix('.pot').name)
  275. mkdir(self, str(unix_path(self, pot_file.parent)))
  276. self.run(f"{cpp_info.bindirs[0]}/msgmerge --no-wrap --no-fuzzy-matching -width=140 -o {po_file} {po_file} {pot_file}",
  277. env = "conanbuild", ignore_errors = True)
  278. def imports(self):
  279. self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
  280. self.copy("CuraEngine", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
  281. rmdir(self, os.path.join(self.source_folder, "resources", "materials"))
  282. self.copy("*.fdm_material", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
  283. self.copy("*.sig", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
  284. if self.options.internal:
  285. self.copy("*.fdm_material", root_package = "fdm_materials_private", src = "@resdirs", dst = "resources/materials", keep_path = False)
  286. self.copy("*.sig", root_package = "fdm_materials_private", src = "@resdirs", dst = "resources/materials", keep_path = False)
  287. self.copy("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[0],
  288. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  289. # Copy resources of cura_binary_data
  290. self.copy("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[0],
  291. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  292. self.copy("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[1],
  293. dst =self._share_dir.joinpath("uranium", "resources"), keep_path = True)
  294. self.copy("*.dll", src = "@bindirs", dst = self._site_packages)
  295. self.copy("*.pyd", src = "@libdirs", dst = self._site_packages)
  296. self.copy("*.pyi", src = "@libdirs", dst = self._site_packages)
  297. self.copy("*.dylib", src = "@libdirs", dst = self._script_dir)
  298. def deploy(self):
  299. # Copy CuraEngine.exe to bindirs of Virtual Python Environment
  300. # TODO: Fix source such that it will get the curaengine relative from the executable (Python bindir in this case)
  301. self.copy_deps("CuraEngine.exe", root_package = "curaengine", src = self.deps_cpp_info["curaengine"].bindirs[0],
  302. dst = self._base_dir,
  303. keep_path = False)
  304. self.copy_deps("CuraEngine", root_package = "curaengine", src = self.deps_cpp_info["curaengine"].bindirs[0], dst = self._base_dir,
  305. keep_path = False)
  306. # Copy resources of Cura (keep folder structure)
  307. self.copy("*", src = self.cpp_info.bindirs[0], dst = self._base_dir, keep_path = False)
  308. self.copy("*", src = self.cpp_info.libdirs[0], dst = self._site_packages.joinpath("cura"), keep_path = True)
  309. self.copy("*", src = self.cpp_info.resdirs[0], dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  310. self.copy("*", src = self.cpp_info.resdirs[1], dst = self._share_dir.joinpath("cura", "plugins"), keep_path = True)
  311. # Copy materials (flat)
  312. self.copy_deps("*.fdm_material", root_package = "fdm_materials", src = self.deps_cpp_info["fdm_materials"].resdirs[0],
  313. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  314. self.copy_deps("*.sig", root_package = "fdm_materials", src = self.deps_cpp_info["fdm_materials"].resdirs[0],
  315. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  316. # Copy internal resources
  317. if self.options.internal:
  318. self.copy_deps("*.fdm_material", root_package = "fdm_materials_private", src = self.deps_cpp_info["fdm_materials_private"].resdirs[0],
  319. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  320. self.copy_deps("*.sig", root_package = "fdm_materials_private", src = self.deps_cpp_info["fdm_materials_private"].resdirs[0],
  321. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  322. self.copy_deps("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[0],
  323. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  324. self.copy_deps("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[1],
  325. dst = self._share_dir.joinpath("cura", "plugins"), keep_path = True)
  326. # Copy resources of Uranium (keep folder structure)
  327. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].resdirs[0],
  328. dst = self._share_dir.joinpath("uranium", "resources"), keep_path = True)
  329. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].resdirs[1],
  330. dst = self._share_dir.joinpath("uranium", "plugins"), keep_path = True)
  331. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].libdirs[0],
  332. dst = self._site_packages.joinpath("UM"),
  333. keep_path = True)
  334. self.copy_deps("*", root_package = "uranium", src = str(Path(self.deps_cpp_info["uranium"].libdirs[0], "Qt", "qml", "UM")),
  335. dst = self._site_packages.joinpath("PyQt6", "Qt6", "qml", "UM"),
  336. keep_path = True)
  337. # Copy resources of cura_binary_data
  338. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[0],
  339. dst = self._share_dir.joinpath("cura"), keep_path = True)
  340. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[1],
  341. dst = self._share_dir.joinpath("uranium"), keep_path = True)
  342. if self.settings.os == "Windows":
  343. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[2],
  344. dst = self._share_dir.joinpath("windows"), keep_path = True)
  345. self.copy_deps("*.dll", src = "@bindirs", dst = self._site_packages)
  346. self.copy_deps("*.pyd", src = "@libdirs", dst = self._site_packages)
  347. self.copy_deps("*.pyi", src = "@libdirs", dst = self._site_packages)
  348. self.copy_deps("*.dylib", src = "@libdirs", dst = self._base_dir.joinpath("lib"))
  349. # Copy packaging scripts
  350. self.copy("*", src = self.cpp_info.resdirs[2], dst = self._base_dir.joinpath("packaging"))
  351. # Copy requirements.txt's
  352. self.copy("*.txt", src = self.cpp_info.resdirs[-1], dst = self._base_dir.joinpath("pip_requirements"))
  353. # Generate the GitHub Action version info Environment
  354. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  355. cura_version = Version(version)
  356. env_prefix = "Env:" if self.settings.os == "Windows" else ""
  357. activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
  358. echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
  359. echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
  360. echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
  361. echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
  362. """).render(cura_version_major = cura_version.major,
  363. cura_version_minor = cura_version.minor,
  364. cura_version_patch = cura_version.patch,
  365. cura_version_build = cura_version.build if cura_version.build != "" else "0",
  366. cura_version_full = self.version,
  367. env_prefix = env_prefix)
  368. ext = ".sh" if self.settings.os != "Windows" else ".ps1"
  369. save(self, self._script_dir.joinpath(f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)
  370. self._generate_cura_version(Path(self._site_packages, "cura"))
  371. entitlements_file = "'{}'".format(Path(self.cpp_info.res_paths[2], "dmg", "cura.entitlements"))
  372. self._generate_pyinstaller_spec(location = self._base_dir,
  373. entrypoint_location = "'{}'".format(Path(self.cpp_info.bin_paths[0], self._um_data()["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  374. icon_path = "'{}'".format(Path(self.cpp_info.res_paths[2], self._um_data()["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  375. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  376. def package(self):
  377. copy(self, "cura_app.py", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.bindirs[0]))
  378. copy(self, "*", src = self.source_path.joinpath("cura"), dst = self.package_path.joinpath(self.cpp.package.libdirs[0]))
  379. copy(self, "*", src = self.source_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]), excludes="*.po")
  380. copy(self, "*", src = self.build_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]))
  381. copy(self, "*", src = self.source_path.joinpath("plugins"), dst = self.package_path.joinpath(self.cpp.package.resdirs[1]))
  382. copy(self, "requirement*.txt", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.resdirs[-1]))
  383. copy(self, "*", src = self.source_path.joinpath("packaging"), dst = self.package_path.joinpath(self.cpp.package.resdirs[2]))
  384. def package_info(self):
  385. self.user_info.pip_requirements = "requirements.txt"
  386. self.user_info.pip_requirements_git = "requirements-ultimaker.txt"
  387. self.user_info.pip_requirements_build = "requirements-dev.txt"
  388. if self.in_local_cache:
  389. self.runenv_info.append_path("PYTHONPATH", str(Path(self.cpp_info.lib_paths[0]).parent))
  390. self.runenv_info.append_path("PYTHONPATH", self.cpp_info.res_paths[1]) # Add plugins to PYTHONPATH
  391. else:
  392. self.runenv_info.append_path("PYTHONPATH", self.source_folder)
  393. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.source_folder, "plugins"))
  394. def package_id(self):
  395. del self.info.settings.os
  396. del self.info.settings.compiler
  397. del self.info.settings.build_type
  398. del self.info.settings.arch
  399. # The following options shouldn't be used to determine the hash, since these are only used to set the CuraVersion.py
  400. # which will als be generated by the deploy method during the `conan install cura/5.1.0@_/_`
  401. del self.info.options.enterprise
  402. del self.info.options.staging
  403. del self.info.options.devtools
  404. del self.info.options.cloud_api_version
  405. del self.info.options.display_name
  406. del self.info.options.cura_debug_mode
  407. # TODO: Use the hash of requirements.txt and requirements-ultimaker.txt, Because changing these will actually result in a different
  408. # Cura. This is needed because the requirements.txt aren't managed by Conan and therefor not resolved in the package_id. This isn't
  409. # ideal but an acceptable solution for now.