conanfile.py 28 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, rm
  6. from conan.tools.microsoft import unix_path
  7. from conan.tools.env import VirtualRunEnv, Environment, VirtualBuildEnv
  8. from conan.tools.scm import Version
  9. from conan.errors import ConanInvalidConfiguration, ConanException
  10. required_conan_version = ">=1.58.0 <2.0.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", "pyqt6", "qt", "qml", "3d-printing", "slicer")
  18. build_policy = "missing"
  19. exports = "LICENSE*", "*.jinja"
  20. settings = "os", "compiler", "build_type", "arch"
  21. # FIXME: Remove specific branch once merged to main
  22. python_requires = "translationextractor/[>=2.1.1]@ultimaker/stable"
  23. options = {
  24. "enterprise": ["True", "False", "true", "false"], # Workaround for GH Action passing boolean as lowercase string
  25. "staging": ["True", "False", "true", "false"], # Workaround for GH Action passing boolean as lowercase string
  26. "devtools": [True, False], # FIXME: Split this up in testing and (development / build (pyinstaller) / system installer) tools
  27. "cloud_api_version": "ANY",
  28. "display_name": "ANY", # TODO: should this be an option??
  29. "cura_debug_mode": [True, False], # FIXME: Use profiles
  30. "internal": [True, False]
  31. }
  32. default_options = {
  33. "enterprise": "False",
  34. "staging": "False",
  35. "devtools": False,
  36. "cloud_api_version": "1",
  37. "display_name": "UltiMaker Cura",
  38. "cura_debug_mode": False, # Not yet implemented
  39. "internal": False,
  40. }
  41. def set_version(self):
  42. if not self.version:
  43. self.version = "5.5.0-beta.1"
  44. @property
  45. def _pycharm_targets(self):
  46. return self.conan_data["pycharm_targets"]
  47. # FIXME: These env vars should be defined in the runenv.
  48. _cura_env = None
  49. @property
  50. def _cura_run_env(self):
  51. if self._cura_env:
  52. return self._cura_env
  53. self._cura_env = Environment()
  54. self._cura_env.define("QML2_IMPORT_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "qml")))
  55. self._cura_env.define("QT_PLUGIN_PATH", str(self._site_packages.joinpath("PyQt6", "Qt6", "plugins")))
  56. if self.settings.os == "Linux":
  57. self._cura_env.define("QT_QPA_FONTDIR", "/usr/share/fonts")
  58. self._cura_env.define("QT_QPA_PLATFORMTHEME", "xdgdesktopportal")
  59. self._cura_env.define("QT_XKB_CONFIG_ROOT", "/usr/share/X11/xkb")
  60. return self._cura_env
  61. @property
  62. def _enterprise(self):
  63. return self.options.enterprise in ["True", 'true']
  64. @property
  65. def _app_name(self):
  66. if self._enterprise:
  67. return str(self.options.display_name) + " Enterprise"
  68. return str(self.options.display_name)
  69. @property
  70. def _urls(self):
  71. if self.options.staging in ["True", 'true']:
  72. return "staging"
  73. return "default"
  74. @property
  75. def requirements_txts(self):
  76. if self.options.devtools:
  77. return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"]
  78. return ["requirements.txt", "requirements-ultimaker.txt"]
  79. @property
  80. def _base_dir(self):
  81. if self.install_folder is None:
  82. if self.build_folder is not None:
  83. return Path(self.build_folder)
  84. return Path(os.getcwd(), "venv")
  85. if self.in_local_cache:
  86. return Path(self.install_folder)
  87. else:
  88. return Path(self.source_folder, "venv")
  89. @property
  90. def _share_dir(self):
  91. return self._base_dir.joinpath("share")
  92. @property
  93. def _script_dir(self):
  94. if self.settings.os == "Windows":
  95. return self._base_dir.joinpath("Scripts")
  96. return self._base_dir.joinpath("bin")
  97. @property
  98. def _site_packages(self):
  99. if self.settings.os == "Windows":
  100. return self._base_dir.joinpath("Lib", "site-packages")
  101. py_version = Version(self.deps_cpp_info["cpython"].version)
  102. return self._base_dir.joinpath("lib", f"python{py_version.major}.{py_version.minor}", "site-packages")
  103. @property
  104. def _py_interp(self):
  105. py_interp = self._script_dir.joinpath(Path(self.deps_user_info["cpython"].python).name)
  106. if self.settings.os == "Windows":
  107. py_interp = Path(*[f'"{p}"' if " " in p else p for p in py_interp.parts])
  108. return py_interp
  109. @property
  110. def _pyinstaller_spec_arch(self):
  111. if self.settings.os == "Macos":
  112. if self.settings.arch == "armv8":
  113. return "'arm64'"
  114. return "'x86_64'"
  115. return "None"
  116. def _generate_about_versions(self, location):
  117. with open(os.path.join(self.recipe_folder, "AboutDialogVersionsList.qml.jinja"), "r") as f:
  118. cura_version_py = Template(f.read())
  119. conan_installs = []
  120. python_installs = []
  121. # list of conan installs
  122. for _, dependency in self.dependencies.host.items():
  123. conan_installs.append([dependency.ref.name,dependency.ref.version])
  124. #list of python installs
  125. outer = '"' if self.settings.os == "Windows" else "'"
  126. inner = "'" if self.settings.os == "Windows" else '"'
  127. python_ins_cmd = f"python -c {outer}import pkg_resources; print({inner};{inner}.join([(s.key+{inner},{inner}+ s.version) for s in pkg_resources.working_set])){outer}"
  128. from six import StringIO
  129. buffer = StringIO()
  130. self.run(python_ins_cmd, run_environment= True, env = "conanrun", output=buffer)
  131. packages = str(buffer.getvalue()).split("-----------------\n")
  132. package = packages[1].strip('\r\n').split(";")
  133. for pack in package:
  134. python_installs.append(pack.split(","))
  135. with open(os.path.join(location, "AboutDialogVersionsList.qml"), "w") as f:
  136. f.write(cura_version_py.render(
  137. conan_installs = conan_installs,
  138. python_installs = python_installs
  139. ))
  140. def _generate_cura_version(self, location):
  141. with open(os.path.join(self.recipe_folder, "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(os.path.join(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.conan_data["urls"][self._urls]["cloud_api_root"],
  158. cura_cloud_api_version = self.options.cloud_api_version,
  159. cura_cloud_account_api_root = self.conan_data["urls"][self._urls]["cloud_account_api_root"],
  160. cura_marketplace_root = self.conan_data["urls"][self._urls]["marketplace_root"],
  161. cura_digital_factory_url = self.conan_data["urls"][self._urls]["digital_factory_url"],
  162. cura_latest_url = self.conan_data["urls"][self._urls]["cura_latest_url"]))
  163. def _generate_pyinstaller_spec(self, location, entrypoint_location, icon_path, entitlements_file):
  164. pyinstaller_metadata = self.conan_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 = os.path.join(self.package_folder, data["src"])
  173. else:
  174. src_path = os.path.join(self.source_folder, data["src"])
  175. else:
  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(self.source_path.joinpath(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_info.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_sources(self):
  237. copy(self, "*", os.path.join(self.recipe_folder, "plugins"), os.path.join(self.export_sources_folder, "plugins"))
  238. copy(self, "*", os.path.join(self.recipe_folder, "resources"), os.path.join(self.export_sources_folder, "resources"), excludes = "*.mo")
  239. copy(self, "*", os.path.join(self.recipe_folder, "tests"), os.path.join(self.export_sources_folder, "tests"))
  240. copy(self, "*", os.path.join(self.recipe_folder, "cura"), os.path.join(self.export_sources_folder, "cura"), excludes="CuraVersion.py")
  241. copy(self, "*", os.path.join(self.recipe_folder, "packaging"), os.path.join(self.export_sources_folder, "packaging"))
  242. copy(self, "*", os.path.join(self.recipe_folder, ".run_templates"), os.path.join(self.export_sources_folder, ".run_templates"))
  243. copy(self, "requirements.txt", self.recipe_folder, self.export_sources_folder)
  244. copy(self, "requirements-dev.txt", self.recipe_folder, self.export_sources_folder)
  245. copy(self, "requirements-ultimaker.txt", self.recipe_folder, self.export_sources_folder)
  246. copy(self, "cura_app.py", self.recipe_folder, self.export_sources_folder)
  247. def configure(self):
  248. self.options["pyarcus"].shared = True
  249. self.options["pysavitar"].shared = True
  250. self.options["pynest2d"].shared = True
  251. self.options["cpython"].shared = True
  252. self.options["boost"].header_only = True
  253. if self.settings.os == "Linux":
  254. self.options["curaengine_grpc_definitions"].shared = True
  255. def validate(self):
  256. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  257. if version and Version(version) <= Version("4"):
  258. raise ConanInvalidConfiguration("Only versions 5+ are support")
  259. def requirements(self):
  260. self.requires("boost/1.82.0")
  261. self.requires("curaengine_grpc_definitions/latest@ultimaker/testing")
  262. self.requires("zlib/1.2.13")
  263. self.requires("pyarcus/5.3.0")
  264. self.requires("curaengine/(latest)@ultimaker/stable")
  265. self.requires("pysavitar/5.3.0")
  266. self.requires("pynest2d/5.3.0")
  267. self.requires("curaengine_plugin_gradual_flow/(latest)@ultimaker/testing")
  268. self.requires("uranium/(latest)@ultimaker/stable")
  269. self.requires("cura_binary_data/(latest)@ultimaker/stable")
  270. self.requires("cpython/3.10.4")
  271. if self.options.internal:
  272. self.requires("cura_private_data/(latest)@ultimaker/testing")
  273. self.requires("fdm_materials/(latest)@internal/testing")
  274. else:
  275. self.requires("fdm_materials/(latest)@ultimaker/stable")
  276. def build_requirements(self):
  277. if self.options.devtools:
  278. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  279. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  280. self.tool_requires("gettext/0.21@ultimaker/testing", force_host_context = True)
  281. def layout(self):
  282. self.folders.source = "."
  283. self.folders.build = "venv"
  284. self.folders.generators = os.path.join(self.folders.build, "conan")
  285. self.cpp.package.libdirs = [os.path.join("site-packages", "cura")]
  286. self.cpp.package.bindirs = ["bin"]
  287. self.cpp.package.resdirs = ["resources", "plugins", "packaging", "pip_requirements"] # pip_requirements should be the last item in the list
  288. def generate(self):
  289. copy(self, "cura_app.py", self.source_folder, str(self._script_dir))
  290. cura_run_envvars = self._cura_run_env.vars(self, scope = "run")
  291. ext = ".ps1" if self.settings.os == "Windows" else ".sh"
  292. cura_run_envvars.save_script(os.path.join(self.folders.generators, f"cura_run_environment{ext}"))
  293. vr = VirtualRunEnv(self)
  294. vr.generate()
  295. self._generate_cura_version(os.path.join(self.source_folder, "cura"))
  296. self._generate_about_versions(os.path.join(self.source_folder, "resources","qml", "Dialogs"))
  297. if not self.in_local_cache:
  298. # Copy CuraEngine.exe to bindirs of Virtual Python Environment
  299. curaengine = self.dependencies["curaengine"].cpp_info
  300. copy(self, "CuraEngine.exe", curaengine.bindirs[0], self.source_folder, keep_path = False)
  301. copy(self, "CuraEngine", curaengine.bindirs[0], self.source_folder, keep_path = False)
  302. # Copy the external plugins that we want to bundle with Cura
  303. rmdir(self,str(self.source_path.joinpath("plugins", "CuraEngineGradualFlow")))
  304. curaengine_plugin_gradual_flow = self.dependencies["curaengine_plugin_gradual_flow"].cpp_info
  305. copy(self, "*", curaengine_plugin_gradual_flow.resdirs[0], str(self.source_path.joinpath("plugins", "CuraEngineGradualFlow")), keep_path = True)
  306. copy(self, "*", curaengine_plugin_gradual_flow.bindirs[0], self.source_folder, keep_path = False)
  307. copy(self, "bundled_*.json", curaengine_plugin_gradual_flow.resdirs[1], str(self.source_path.joinpath("resources", "bundled_packages")), keep_path = False)
  308. # Copy resources of cura_binary_data
  309. cura_binary_data = self.dependencies["cura_binary_data"].cpp_info
  310. copy(self, "*", cura_binary_data.resdirs[0], str(self._share_dir.joinpath("cura")), keep_path = True)
  311. copy(self, "*", cura_binary_data.resdirs[1], str(self._share_dir.joinpath("uranium")), keep_path = True)
  312. if self.settings.os == "Windows":
  313. copy(self, "*", cura_binary_data.resdirs[2], str(self._share_dir.joinpath("windows")), keep_path = True)
  314. for dependency in self.dependencies.host.values():
  315. for bindir in dependency.cpp_info.bindirs:
  316. copy(self, "*.dll", bindir, str(self._site_packages), keep_path = False)
  317. for libdir in dependency.cpp_info.libdirs:
  318. copy(self, "*.pyd", libdir, str(self._site_packages), keep_path = False)
  319. copy(self, "*.pyi", libdir, str(self._site_packages), keep_path = False)
  320. copy(self, "*.dylib", libdir, str(self._base_dir.joinpath("lib")), keep_path = False)
  321. # Copy materials (flat)
  322. rmdir(self, os.path.join(self.source_folder, "resources", "materials"))
  323. fdm_materials = self.dependencies["fdm_materials"].cpp_info
  324. copy(self, "*", fdm_materials.resdirs[0], self.source_folder)
  325. # Copy internal resources
  326. if self.options.internal:
  327. cura_private_data = self.dependencies["cura_private_data"].cpp_info
  328. copy(self, "*", cura_private_data.resdirs[0], str(self._share_dir.joinpath("cura")))
  329. if self.options.devtools:
  330. entitlements_file = "'{}'".format(os.path.join(self.source_folder, "packaging", "MacOS", "cura.entitlements"))
  331. self._generate_pyinstaller_spec(location = self.generators_folder,
  332. entrypoint_location = "'{}'".format(os.path.join(self.source_folder, self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  333. icon_path = "'{}'".format(os.path.join(self.source_folder, "packaging", self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  334. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  335. # Update the po and pot files
  336. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type=str):
  337. vb = VirtualBuildEnv(self)
  338. vb.generate()
  339. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  340. cpp_info = self.dependencies["gettext"].cpp_info
  341. pot = self.python_requires["translationextractor"].module.ExtractTranslations(self, cpp_info.bindirs[0])
  342. pot.generate()
  343. def build(self):
  344. if self.options.devtools:
  345. if self.settings.os != "Windows" or self.conf.get("tools.microsoft.bash:path", check_type = str):
  346. # FIXME: once m4, autoconf, automake are Conan V2 ready use self.win_bash and add gettext as base tool_requirement
  347. for po_file in self.source_path.joinpath("resources", "i18n").glob("**/*.po"):
  348. mo_file = Path(self.build_folder, po_file.with_suffix('.mo').relative_to(self.source_path))
  349. mo_file = mo_file.parent.joinpath("LC_MESSAGES", mo_file.name)
  350. mkdir(self, str(unix_path(self, Path(mo_file).parent)))
  351. cpp_info = self.dependencies["gettext"].cpp_info
  352. self.run(f"{cpp_info.bindirs[0]}/msgfmt {po_file} -o {mo_file} -f", env="conanbuild", ignore_errors=True)
  353. def deploy(self):
  354. copy(self, "*", os.path.join(self.package_folder, self.cpp.package.resdirs[2]), os.path.join(self.install_folder, "packaging"), keep_path = True)
  355. # Copy resources of Cura (keep folder structure) needed by pyinstaller to determine the module structure
  356. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.bindirs[0]), str(self._base_dir), keep_path = False)
  357. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.libdirs[0]), str(self._site_packages.joinpath("cura")), keep_path = True)
  358. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[0]), str(self._share_dir.joinpath("cura", "resources")), keep_path = True)
  359. copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[1]), str(self._share_dir.joinpath("cura", "plugins")), keep_path = True)
  360. # Copy resources of Uranium (keep folder structure)
  361. uranium = self.dependencies["uranium"].cpp_info
  362. copy(self, "*", uranium.resdirs[0], str(self._share_dir.joinpath("uranium", "resources")), keep_path = True)
  363. copy(self, "*", uranium.resdirs[1], str(self._share_dir.joinpath("uranium", "plugins")), keep_path = True)
  364. copy(self, "*", uranium.libdirs[0], str(self._site_packages.joinpath("UM")), keep_path = True)
  365. # Generate the GitHub Action version info Environment
  366. version = self.conf_info.get("user.cura:version", default = self.version, check_type = str)
  367. cura_version = Version(version)
  368. env_prefix = "Env:" if self.settings.os == "Windows" else ""
  369. activate_github_actions_version_env = Template(r"""echo "CURA_VERSION_MAJOR={{ cura_version_major }}" >> ${{ env_prefix }}GITHUB_ENV
  370. echo "CURA_VERSION_MINOR={{ cura_version_minor }}" >> ${{ env_prefix }}GITHUB_ENV
  371. echo "CURA_VERSION_PATCH={{ cura_version_patch }}" >> ${{ env_prefix }}GITHUB_ENV
  372. echo "CURA_VERSION_BUILD={{ cura_version_build }}" >> ${{ env_prefix }}GITHUB_ENV
  373. echo "CURA_VERSION_FULL={{ cura_version_full }}" >> ${{ env_prefix }}GITHUB_ENV
  374. echo "CURA_APP_NAME={{ cura_app_name }}" >> ${{ env_prefix }}GITHUB_ENV
  375. """).render(cura_version_major = cura_version.major,
  376. cura_version_minor = cura_version.minor,
  377. cura_version_patch = cura_version.patch,
  378. cura_version_build = cura_version.build if cura_version.build != "" else "0",
  379. cura_version_full = self.version,
  380. cura_app_name = self._app_name,
  381. env_prefix = env_prefix)
  382. ext = ".sh" if self.settings.os != "Windows" else ".ps1"
  383. save(self, os.path.join(self._script_dir, f"activate_github_actions_version_env{ext}"), activate_github_actions_version_env)
  384. self._generate_cura_version(os.path.join(self._site_packages, "cura"))
  385. self._generate_about_versions(str(self._share_dir.joinpath("cura", "resources", "qml", "Dialogs")))
  386. entitlements_file = "'{}'".format(Path(self.cpp_info.res_paths[2], "MacOS", "cura.entitlements"))
  387. self._generate_pyinstaller_spec(location = self._base_dir,
  388. entrypoint_location = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.bindirs[0], self.conan_data["pyinstaller"]["runinfo"]["entrypoint"])).replace("\\", "\\\\"),
  389. icon_path = "'{}'".format(os.path.join(self.package_folder, self.cpp_info.resdirs[2], self.conan_data["pyinstaller"]["icon"][str(self.settings.os)])).replace("\\", "\\\\"),
  390. entitlements_file = entitlements_file if self.settings.os == "Macos" else "None")
  391. def package(self):
  392. copy(self, "cura_app.py", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.bindirs[0]))
  393. copy(self, "*", src = os.path.join(self.source_folder, "cura"), dst = os.path.join(self.package_folder, self.cpp.package.libdirs[0]))
  394. copy(self, "*", src = os.path.join(self.source_folder, "resources"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
  395. copy(self, "*.mo", os.path.join(self.build_folder, "resources"), os.path.join(self.package_folder, "resources"))
  396. copy(self, "*", src = os.path.join(self.source_folder, "plugins"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[1]))
  397. copy(self, "requirement*.txt", src = self.source_folder, dst = os.path.join(self.package_folder, self.cpp.package.resdirs[-1]))
  398. copy(self, "*", src = os.path.join(self.source_folder, "packaging"), dst = os.path.join(self.package_folder, self.cpp.package.resdirs[2]))
  399. # Remove the CuraEngineGradualFlow plugin from the package
  400. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[1], "CuraEngineGradualFlow"))
  401. rm(self, "bundled_*.json", os.path.join(self.package_folder, self.cpp.package.resdirs[0], "bundled_packages"), recursive = False)
  402. # Remove the fdm_materials from the package
  403. rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials"))
  404. def package_info(self):
  405. self.user_info.pip_requirements = "requirements.txt"
  406. self.user_info.pip_requirements_git = "requirements-ultimaker.txt"
  407. self.user_info.pip_requirements_build = "requirements-dev.txt"
  408. if self.in_local_cache:
  409. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "site-packages"))
  410. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "plugins"))
  411. else:
  412. self.runenv_info.append_path("PYTHONPATH", self.source_folder)
  413. self.runenv_info.append_path("PYTHONPATH", os.path.join(self.source_folder, "plugins"))
  414. def package_id(self):
  415. self.info.clear()
  416. # The following options shouldn't be used to determine the hash, since these are only used to set the CuraVersion.py
  417. # which will als be generated by the deploy method during the `conan install cura/5.1.0@_/_`
  418. del self.info.options.enterprise
  419. del self.info.options.staging
  420. del self.info.options.devtools
  421. del self.info.options.cloud_api_version
  422. del self.info.options.display_name
  423. del self.info.options.cura_debug_mode
  424. # TODO: Use the hash of requirements.txt and requirements-ultimaker.txt, Because changing these will actually result in a different
  425. # Cura. This is needed because the requirements.txt aren't managed by Conan and therefor not resolved in the package_id. This isn't
  426. # ideal but an acceptable solution for now.