conanfile.py 27 KB

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