conanfile.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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", "target_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", "translationextractor/[>=1.0.0]@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 _app_name(self):
  75. app_name = str(self.options.display_name)
  76. if self._enterprise:
  77. app_name += " Enterprise"
  78. if self.settings.target_arch:
  79. app_name += f"_{self.settings.target_arch}"
  80. else:
  81. app_name += f"_{self.settings.arch}"
  82. return app_name
  83. @property
  84. def _cloud_api_root(self):
  85. return "https://api-staging.ultimaker.com" if self._staging else "https://api.ultimaker.com"
  86. @property
  87. def _cloud_account_api_root(self):
  88. return "https://account-staging.ultimaker.com" if self._staging else "https://account.ultimaker.com"
  89. @property
  90. def _marketplace_root(self):
  91. return "https://marketplace-staging.ultimaker.com" if self._staging else "https://marketplace.ultimaker.com"
  92. @property
  93. def _digital_factory_url(self):
  94. return "https://digitalfactory-staging.ultimaker.com" if self._staging else "https://digitalfactory.ultimaker.com"
  95. @property
  96. def _cura_latest_url(self):
  97. return "https://software.ultimaker.com/latest.json"
  98. @property
  99. def requirements_txts(self):
  100. if self.options.devtools:
  101. return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"]
  102. return ["requirements.txt", "requirements-ultimaker.txt"]
  103. @property
  104. def _base_dir(self):
  105. if self.install_folder is None:
  106. if self.build_folder is not None:
  107. return Path(self.build_folder)
  108. return Path(os.getcwd(), "venv")
  109. if self.in_local_cache:
  110. return Path(self.install_folder)
  111. else:
  112. return Path(self.source_folder, "venv")
  113. @property
  114. def _share_dir(self):
  115. return self._base_dir.joinpath("share")
  116. @property
  117. def _script_dir(self):
  118. if self.settings.os == "Windows":
  119. return self._base_dir.joinpath("Scripts")
  120. return self._base_dir.joinpath("bin")
  121. @property
  122. def _site_packages(self):
  123. if self.settings.os == "Windows":
  124. return self._base_dir.joinpath("Lib", "site-packages")
  125. py_version = Version(self.deps_cpp_info["cpython"].version)
  126. return self._base_dir.joinpath("lib", f"python{py_version.major}.{py_version.minor}", "site-packages")
  127. @property
  128. def _py_interp(self):
  129. py_interp = self._script_dir.joinpath(Path(self.deps_user_info["cpython"].python).name)
  130. if self.settings.os == "Windows":
  131. py_interp = Path(*[f'"{p}"' if " " in p else p for p in py_interp.parts])
  132. return py_interp
  133. @property
  134. def _pyinstaller_spec_arch(self):
  135. if self.settings.os == "Macos":
  136. if self.settings.target_arch == "armv8":
  137. return "'arm64'"
  138. return "'x86_64'"
  139. return "None"
  140. def _generate_cura_version(self, location):
  141. with open(Path(__file__).parent.joinpath("CuraVersion.py.jinja"), "r") as f:
  142. cura_version_py = Template(f.read())
  143. # If you want a specific Cura version to show up on the splash screen add the user configuration `user.cura:version=VERSION`
  144. # the global.conf, profile, package_info (of dependency) or via the cmd line `-c user.cura:version=VERSION`
  145. cura_version = Version(self.conf.get("user.cura:version", default = self.version, check_type = str))
  146. pre_tag = f"-{cura_version.pre}" if cura_version.pre else ""
  147. build_tag = f"+{cura_version.build}" if cura_version.build else ""
  148. internal_tag = f"+internal" if self.options.internal else ""
  149. cura_version = f"{cura_version.major}.{cura_version.minor}.{cura_version.patch}{pre_tag}{build_tag}{internal_tag}"
  150. with open(Path(location, "CuraVersion.py"), "w") as f:
  151. f.write(cura_version_py.render(
  152. cura_app_name = self.name,
  153. cura_app_display_name = self._app_name,
  154. cura_version = cura_version,
  155. cura_build_type = "Enterprise" if self._enterprise else "",
  156. cura_debug_mode = self.options.cura_debug_mode,
  157. cura_cloud_api_root = self._cloud_api_root,
  158. cura_cloud_api_version = self.options.cloud_api_version,
  159. cura_cloud_account_api_root = self._cloud_account_api_root,
  160. cura_marketplace_root = self._marketplace_root,
  161. cura_digital_factory_url = self._digital_factory_url,
  162. cura_latest_url = self._cura_latest_url))
  163. def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
  164. pyinstaller_metadata = self._um_data()["pyinstaller"]
  165. datas = [(str(self._base_dir.joinpath("conan_install_info.json")), ".")]
  166. for data in pyinstaller_metadata["datas"].values():
  167. if not self.options.internal and data.get("internal", False):
  168. continue
  169. if "package" in data: # get the paths from conan package
  170. if data["package"] == self.name:
  171. if self.in_local_cache:
  172. src_path = Path(self.package_folder, data["src"])
  173. else:
  174. src_path = Path(self.source_folder, data["src"])
  175. else:
  176. src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"])
  177. elif "root" in data: # get the paths relative from the sourcefolder
  178. src_path = Path(self.source_folder, data["root"], data["src"])
  179. else:
  180. continue
  181. if 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 = Path(self.deps_cpp_info[binary["package"]].rootpath, binary["src"])
  187. elif "root" in binary: # get the paths relative from the sourcefolder
  188. src_path = Path(self.source_folder, binary["root"], binary["src"])
  189. else:
  190. continue
  191. if not src_path.exists():
  192. self.output.warning(f"Source path for binary {binary['binary']} does not exist")
  193. continue
  194. for bin in src_path.glob(binary["binary"] + "*[.exe|.dll|.so|.dylib|.so.]*"):
  195. binaries.append((str(bin), binary["dst"]))
  196. for bin in src_path.glob(binary["binary"]):
  197. binaries.append((str(bin), binary["dst"]))
  198. # Make sure all Conan dependencies which are shared are added to the binary list for pyinstaller
  199. for _, dependency in self.dependencies.host.items():
  200. for bin_paths in dependency.cpp_info.bindirs:
  201. binaries.extend([(f"{p}", ".") for p in Path(bin_paths).glob("**/*.dll")])
  202. for lib_paths in dependency.cpp_info.libdirs:
  203. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.so*")])
  204. binaries.extend([(f"{p}", ".") for p in Path(lib_paths).glob("**/*.dylib*")])
  205. # Copy dynamic libs from lib path
  206. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.dylib*")])
  207. binaries.extend([(f"{p}", ".") for p in Path(self._base_dir.joinpath("lib")).glob("**/*.so*")])
  208. # Collect all dll's from PyQt6 and place them in the root
  209. binaries.extend([(f"{p}", ".") for p in Path(self._site_packages, "PyQt6", "Qt6").glob("**/*.dll")])
  210. with open(Path(__file__).parent.joinpath("UltiMaker-Cura.spec.jinja"), "r") as f:
  211. pyinstaller = Template(f.read())
  212. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  213. cura_version = Version(version)
  214. with open(Path(location, "UltiMaker-Cura.spec"), "w") as f:
  215. f.write(pyinstaller.render(
  216. name = str(self.options.display_name).replace(" ", "-"),
  217. display_name = self._app_name,
  218. entrypoint = entrypoint_location,
  219. datas = datas,
  220. binaries = binaries,
  221. venv_script_path = str(self._script_dir),
  222. hiddenimports = pyinstaller_metadata["hiddenimports"],
  223. collect_all = pyinstaller_metadata["collect_all"],
  224. icon = icon_path,
  225. entitlements_file = entitlements_file,
  226. osx_bundle_identifier = "'nl.ultimaker.cura'" if self.settings.os == "Macos" else "None",
  227. upx = str(self.settings.os == "Windows"),
  228. 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
  229. target_arch = self._pyinstaller_spec_arch,
  230. macos = self.settings.os == "Macos",
  231. version = f"'{version}'",
  232. short_version = f"'{cura_version.major}.{cura_version.minor}.{cura_version.patch}'",
  233. ))
  234. def set_version(self):
  235. if self.version is None:
  236. self.version = self._umdefault_version()
  237. def configure(self):
  238. self.options["pyarcus"].shared = True
  239. self.options["pysavitar"].shared = True
  240. self.options["pynest2d"].shared = True
  241. self.options["cpython"].shared = True
  242. def validate(self):
  243. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  244. if version and Version(version) <= Version("4"):
  245. raise ConanInvalidConfiguration("Only versions 5+ are support")
  246. def requirements(self):
  247. for req in self._um_data()["requirements"]:
  248. self.requires(req)
  249. if self.options.internal:
  250. for req in self._um_data()["internal_requirements"]:
  251. self.requires(req)
  252. def build_requirements(self):
  253. if self.options.devtools:
  254. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  255. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  256. self.tool_requires("gettext/0.21", force_host_context=True)
  257. def layout(self):
  258. self.folders.source = "."
  259. self.folders.build = "venv"
  260. self.folders.generators = Path(self.folders.build, "conan")
  261. self.cpp.package.libdirs = [os.path.join("site-packages", "cura")]
  262. self.cpp.package.bindirs = ["bin"]
  263. self.cpp.package.resdirs = ["resources", "plugins", "packaging", "pip_requirements"] # pip_requirements should be the last item in the list
  264. def build(self):
  265. if self.options.devtools:
  266. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  267. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  268. cpp_info = self.dependencies["gettext"].cpp_info
  269. for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
  270. mo_file = self.build_path.joinpath(po_file.with_suffix('.mo').relative_to(self.source_path))
  271. mkdir(self, str(unix_path(self, mo_file.parent)))
  272. self.run(f"{cpp_info.bindirs[0]}/msgfmt {po_file} -o {mo_file} -f", env="conanbuild", ignore_errors=True)
  273. def generate(self):
  274. cura_run_envvars = self._cura_run_env.vars(self, scope = "run")
  275. ext = ".ps1" if self.settings.os == "Windows" else ".sh"
  276. cura_run_envvars.save_script(self.folders.generators.joinpath(f"cura_run_environment{ext}"))
  277. vr = VirtualRunEnv(self)
  278. vr.generate()
  279. self._generate_cura_version(Path(self.source_folder, "cura"))
  280. if self.options.devtools:
  281. entitlements_file = "'{}'".format(Path(self.source_folder, "packaging", "MacOS", "cura.entitlements"))
  282. self._generate_pyinstaller_spec(location = self.generators_folder,
  283. entrypoint_location = "'{}'".format(Path(self.source_folder, self._um_data()["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  284. icon_path = "'{}'".format(Path(self.source_folder, "packaging", self._um_data()["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  285. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  286. # Update the po files
  287. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  288. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  289. # Extract all the new strings and update the existing po files
  290. extractTool = self.python_requires["translationextractor"].module.ExtractTranslations(self, self.source_path.joinpath("resources", "i18n"), "cura.pot")
  291. extractTool.generate()
  292. def imports(self):
  293. self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
  294. self.copy("CuraEngine", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
  295. rmdir(self, os.path.join(self.source_folder, "resources", "materials"))
  296. self.copy("*.fdm_material", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
  297. self.copy("*.sig", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
  298. if self.options.internal:
  299. self.copy("*.fdm_material", root_package = "fdm_materials_private", src = "@resdirs", dst = "resources/materials", keep_path = False)
  300. self.copy("*.sig", root_package = "fdm_materials_private", src = "@resdirs", dst = "resources/materials", keep_path = False)
  301. self.copy("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[0],
  302. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  303. # Copy resources of cura_binary_data
  304. self.copy("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[0],
  305. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  306. self.copy("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[1],
  307. dst =self._share_dir.joinpath("uranium", "resources"), keep_path = True)
  308. self.copy("*.dll", src = "@bindirs", dst = self._site_packages)
  309. self.copy("*.pyd", src = "@libdirs", dst = self._site_packages)
  310. self.copy("*.pyi", src = "@libdirs", dst = self._site_packages)
  311. self.copy("*.dylib", src = "@libdirs", dst = self._script_dir)
  312. def deploy(self):
  313. # Copy CuraEngine.exe to bindirs of Virtual Python Environment
  314. # TODO: Fix source such that it will get the curaengine relative from the executable (Python bindir in this case)
  315. self.copy_deps("CuraEngine.exe", root_package = "curaengine", src = self.deps_cpp_info["curaengine"].bindirs[0],
  316. dst = self._base_dir,
  317. keep_path = False)
  318. self.copy_deps("CuraEngine", root_package = "curaengine", src = self.deps_cpp_info["curaengine"].bindirs[0], dst = self._base_dir,
  319. keep_path = False)
  320. # Copy resources of Cura (keep folder structure)
  321. self.copy("*", src = self.cpp_info.bindirs[0], dst = self._base_dir, keep_path = False)
  322. self.copy("*", src = self.cpp_info.libdirs[0], dst = self._site_packages.joinpath("cura"), keep_path = True)
  323. self.copy("*", src = self.cpp_info.resdirs[0], dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  324. self.copy("*", src = self.cpp_info.resdirs[1], dst = self._share_dir.joinpath("cura", "plugins"), keep_path = True)
  325. # Copy materials (flat)
  326. self.copy_deps("*.fdm_material", root_package = "fdm_materials", src = self.deps_cpp_info["fdm_materials"].resdirs[0],
  327. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  328. self.copy_deps("*.sig", root_package = "fdm_materials", src = self.deps_cpp_info["fdm_materials"].resdirs[0],
  329. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  330. # Copy internal resources
  331. if self.options.internal:
  332. self.copy_deps("*.fdm_material", root_package = "fdm_materials_private", src = self.deps_cpp_info["fdm_materials_private"].resdirs[0],
  333. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  334. self.copy_deps("*.sig", root_package = "fdm_materials_private", src = self.deps_cpp_info["fdm_materials_private"].resdirs[0],
  335. dst = self._share_dir.joinpath("cura", "resources", "materials"), keep_path = False)
  336. self.copy_deps("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[0],
  337. dst = self._share_dir.joinpath("cura", "resources"), keep_path = True)
  338. self.copy_deps("*", root_package = "cura_private_data", src = self.deps_cpp_info["cura_private_data"].resdirs[1],
  339. dst = self._share_dir.joinpath("cura", "plugins"), keep_path = True)
  340. # Copy resources of Uranium (keep folder structure)
  341. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].resdirs[0],
  342. dst = self._share_dir.joinpath("uranium", "resources"), keep_path = True)
  343. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].resdirs[1],
  344. dst = self._share_dir.joinpath("uranium", "plugins"), keep_path = True)
  345. self.copy_deps("*", root_package = "uranium", src = self.deps_cpp_info["uranium"].libdirs[0],
  346. dst = self._site_packages.joinpath("UM"),
  347. keep_path = True)
  348. self.copy_deps("*", root_package = "uranium", src = str(Path(self.deps_cpp_info["uranium"].libdirs[0], "Qt", "qml", "UM")),
  349. dst = self._site_packages.joinpath("PyQt6", "Qt6", "qml", "UM"),
  350. keep_path = True)
  351. # Copy resources of cura_binary_data
  352. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[0],
  353. dst = self._share_dir.joinpath("cura"), keep_path = True)
  354. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[1],
  355. dst = self._share_dir.joinpath("uranium"), keep_path = True)
  356. if self.settings.os == "Windows":
  357. self.copy_deps("*", root_package = "cura_binary_data", src = self.deps_cpp_info["cura_binary_data"].resdirs[2],
  358. dst = self._share_dir.joinpath("windows"), keep_path = True)
  359. self.copy_deps("*.dll", src = "@bindirs", dst = self._site_packages)
  360. self.copy_deps("*.pyd", src = "@libdirs", dst = self._site_packages)
  361. self.copy_deps("*.pyi", src = "@libdirs", dst = self._site_packages)
  362. self.copy_deps("*.dylib", src = "@libdirs", dst = self._base_dir.joinpath("lib"))
  363. # Copy packaging scripts
  364. self.copy("*", src = self.cpp_info.resdirs[2], dst = self._base_dir.joinpath("packaging"))
  365. # Copy requirements.txt's
  366. self.copy("*.txt", src = self.cpp_info.resdirs[-1], dst = self._base_dir.joinpath("pip_requirements"))
  367. # Generate the GitHub Action version info Environment
  368. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  369. cura_version = Version(version)
  370. env_prefix = "Env:" if self.settings.os == "Windows" else ""
  371. activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
  372. echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
  373. echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
  374. echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
  375. echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
  376. echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
  377. """).render(cura_version_major = cura_version.major,
  378. cura_version_minor = cura_version.minor,
  379. cura_version_patch = cura_version.patch,
  380. cura_version_build = cura_version.build if cura_version.build != "" else "0",
  381. cura_version_full = self.version,
  382. cura_app_name = self._app_name,
  383. env_prefix = env_prefix)
  384. ext = ".sh" if self.settings.os != "Windows" else ".ps1"
  385. save(self, self._script_dir.joinpath(f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)
  386. self._generate_cura_version(Path(self._site_packages, "cura"))
  387. entitlements_file = "'{}'".format(Path(self.cpp_info.res_paths[2], "MacOS", "cura.entitlements"))
  388. self._generate_pyinstaller_spec(location = self._base_dir,
  389. entrypoint_location = "'{}'".format(Path(self.cpp_info.bin_paths[0], self._um_data()["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  390. icon_path = "'{}'".format(Path(self.cpp_info.res_paths[2], self._um_data()["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  391. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  392. def package(self):
  393. copy(self, "cura_app.py", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.bindirs[0]))
  394. copy(self, "*", src = self.source_path.joinpath("cura"), dst = self.package_path.joinpath(self.cpp.package.libdirs[0]))
  395. copy(self, "*", src = self.source_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]), excludes="*.po")
  396. copy(self, "*", src = self.build_path.joinpath("resources"), dst = self.package_path.joinpath(self.cpp.package.resdirs[0]))
  397. copy(self, "*", src = self.source_path.joinpath("plugins"), dst = self.package_path.joinpath(self.cpp.package.resdirs[1]))
  398. copy(self, "requirement*.txt", src = self.source_path, dst = self.package_path.joinpath(self.cpp.package.resdirs[-1]))
  399. copy(self, "*", src = self.source_path.joinpath("packaging"), dst = self.package_path.joinpath(self.cpp.package.resdirs[2]))
  400. def package_info(self):
  401. self.user_info.pip_requirements = "requirements.txt"
  402. self.user_info.pip_requirements_git = "requirements-ultimaker.txt"
  403. self.user_info.pip_requirements_build = "requirements-dev.txt"
  404. if self.in_local_cache:
  405. self.runenv_info.append_path("PYTHONPATH", str(Path(self.cpp_info.lib_paths[0]).parent))
  406. self.runenv_info.append_path("PYTHONPATH", self.cpp_info.res_paths[1]) # Add plugins to PYTHONPATH
  407. else:
  408. self.runenv_info.append_path("PYTHONPATH", self.source_folder)
  409. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.source_folder, "plugins"))
  410. def package_id(self):
  411. del self.info.settings.os
  412. del self.info.settings.compiler
  413. del self.info.settings.build_type
  414. del self.info.settings.arch
  415. # The following options shouldn't be used to determine the hash, since these are only used to set the CuraVersion.py
  416. # which will als be generated by the deploy method during the `conan install cura/5.1.0@_/_`
  417. del self.info.options.enterprise
  418. del self.info.options.staging
  419. del self.info.options.devtools
  420. del self.info.options.cloud_api_version
  421. del self.info.options.display_name
  422. del self.info.options.cura_debug_mode
  423. # TODO: Use the hash of requirements.txt and requirements-ultimaker.txt, Because changing these will actually result in a different
  424. # Cura. This is needed because the requirements.txt aren't managed by Conan and therefor not resolved in the package_id. This isn't
  425. # ideal but an acceptable solution for now.