Initial set-up of deploy functionality

Contributes to CURA-9365
This commit is contained in:
j.spijker@ultimaker.com 2022-06-27 13:51:50 +02:00 committed by Jelle Spijker
parent fab8598a05
commit 62aacc5946
3 changed files with 77 additions and 75 deletions

View File

@ -21,7 +21,8 @@ class CuraConan(ConanFile):
description = "3D printer / slicing GUI built on top of the Uranium framework" description = "3D printer / slicing GUI built on top of the Uranium framework"
topics = ("conan", "python", "pyqt5", "qt", "qml", "3d-printing", "slicer") topics = ("conan", "python", "pyqt5", "qt", "qml", "3d-printing", "slicer")
build_policy = "missing" build_policy = "missing"
exports = "LICENSE*" exports = "LICENSE*", "Ultimaker-Cura.spec.jinja"
exports_sources = "CuraVersion.py.jinja"
settings = "os", "compiler", "build_type", "arch" settings = "os", "compiler", "build_type", "arch"
no_copy_source = True # We won't build so no need to copy sources to the build folder no_copy_source = True # We won't build so no need to copy sources to the build folder
@ -83,6 +84,23 @@ class CuraConan(ConanFile):
return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"] return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"]
return ["requirements.txt", "requirements-ultimaker.txt"] return ["requirements.txt", "requirements-ultimaker.txt"]
def source(self):
with open(Path(self.source_folder, "CuraVersion.py.jinja"), "r") as f:
cura_version_py = Template(f.read())
with open(Path(self.source_folder, "cura", "CuraVersion.py"), "w") as f:
f.write(cura_version_py.render(
cura_app_name = self.name,
cura_app_display_name = self.options.display_name,
cura_version = self.version,
cura_build_type = "Enterprise" if self._enterprise else "",
cura_debug_mode = self.options.cura_debug_mode,
cura_cloud_api_root = self._cloud_api_root,
cura_cloud_api_version = self.options.cloud_api_version,
cura_cloud_account_api_root = self._cloud_account_api_root,
cura_marketplace_root = self._marketplace_root,
cura_digital_factory_url = self._digital_factory_url))
def configure(self): def configure(self):
self.options["arcus"].shared = True self.options["arcus"].shared = True
self.options["savitar"].shared = True self.options["savitar"].shared = True
@ -103,73 +121,53 @@ class CuraConan(ConanFile):
self.folders.generators = os.path.join(self.folders.build, "conan") self.folders.generators = os.path.join(self.folders.build, "conan")
self.cpp.package.libdirs = ["site-packages"] self.cpp.package.libdirs = ["site-packages"]
self.cpp.package.resdirs = ["res"]
def generate(self): def generate(self):
# TODO: handle materials when running from source and using the fdm_materials if self.options.devtools:
with open(Path(self.source_folder, "Ultimaker-Cura.spec.jinja"), "r") as f:
pyinstaller = Template(f.read())
with open(Path(self.source_folder, "cura", "CuraVersion.py.jinja"), "r") as f: pyinstaller_metadata = self._um_data(self.version)["pyinstaller"]
cura_version_py = Template(f.read()) datas = []
for data in pyinstaller_metadata["datas"].values():
with open(Path(self.source_folder, "cura", "CuraVersion.py"), "w") as f: if "package" in data: # get the paths from conan package
f.write(cura_version_py.render( if data["package"] == self.name:
cura_app_name = self.name, src_path = Path(self.package_folder, data["src"])
cura_app_display_name = self.options.display_name, else:
cura_version = self.version, src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"])
cura_build_type = "Enterprise" if self._enterprise else "", elif "root" in data: # get the paths relative from the sourcefolder
cura_debug_mode = self.options.cura_debug_mode, src_path = Path(self.source_folder, data["root"], data["src"])
cura_cloud_api_root = self._cloud_api_root,
cura_cloud_api_version = self.options.cloud_api_version,
cura_cloud_account_api_root = self._cloud_account_api_root,
cura_marketplace_root = self._marketplace_root,
cura_digital_factory_url = self._digital_factory_url))
# Create the Ultimaker-Cura.spec
# TODO: Create a generator for this
# TODO: Create exception for not in_local_cache
# TODO: Allow for paths to be determine when installing from local cache without root_folder
with open(Path(self.source_folder, "Ultimaker-Cura.spec.jinja"), "r") as f:
pyinstaller = Template(f.read())
pyinstaller_metadata = self._um_data(self.version)["pyinstaller"]
datas = []
for data in pyinstaller_metadata["datas"].values():
if "package" in data: # get the paths from conan package
if data["package"] == self.name:
src_path = Path(self.package_folder, data["src"])
else: else:
src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"]) continue
elif "root" in data: # get the paths relative from the sourcefolder if src_path.exists():
src_path = Path(self.source_folder, data["root"], data["src"]) datas.append((str(src_path), data["dst"]))
else:
continue
if src_path.exists():
datas.append((str(src_path), data["dst"]))
binaries = [] binaries = []
for binary in pyinstaller_metadata["binaries"].values(): for binary in pyinstaller_metadata["binaries"].values():
if "package" in binary: # get the paths from conan package if "package" in binary: # get the paths from conan package
src_path = Path(self.deps_cpp_info[binary["package"]].rootpath, binary["src"]) src_path = Path(self.deps_cpp_info[binary["package"]].rootpath, binary["src"])
elif "root" in binary: # get the paths relative from the sourcefolder elif "root" in binary: # get the paths relative from the sourcefolder
src_path = Path(self.source_folder, binary["root"], binary["src"]) src_path = Path(self.source_folder, binary["root"], binary["src"])
else: else:
continue continue
if not src_path.exists(): if not src_path.exists():
continue continue
for bin in src_path.glob(binary["binary"] + ".*[exe|dll|so|dylib]"): for bin in src_path.glob(binary["binary"] + ".*[exe|dll|so|dylib]"):
binaries.append((str(bin), binary["dst"])) binaries.append((str(bin), binary["dst"]))
for bin in src_path.glob(binary["binary"]): for bin in src_path.glob(binary["binary"]):
binaries.append((str(bin), binary["dst"])) binaries.append((str(bin), binary["dst"]))
with open(Path(self.generators_folder, "Ultimaker-Cura.spec"), "w") as f: with open(Path(self.generators_folder, "Ultimaker-Cura.spec"), "w") as f:
f.write(pyinstaller.render( f.write(pyinstaller.render(
name = str(self.options.display_name).replace(" ", "-"), name = str(self.options.display_name).replace(" ", "-"),
entrypoint = os.path.join("..", "..", self._um_data(self.version)["runinfo"]["entrypoint"]), entrypoint = os.path.join("..", "..", self._um_data(self.version)["runinfo"]["entrypoint"]),
datas = datas, datas = datas,
binaries = binaries, binaries = binaries,
hiddenimports = pyinstaller_metadata["hiddenimports"], hiddenimports = pyinstaller_metadata["hiddenimports"],
collect_all = pyinstaller_metadata["collect_all"], collect_all = pyinstaller_metadata["collect_all"],
icon = os.path.join("..", "..", pyinstaller_metadata["icon"][str(self.settings.os)]) icon = os.path.join("..", "..", pyinstaller_metadata["icon"][str(self.settings.os)])
)) ))
def imports(self): def imports(self):
self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False) self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
@ -184,6 +182,23 @@ class CuraConan(ConanFile):
self.copy("*.pyi", src = "@libdirs", dst = "venv/Lib/site-packages") self.copy("*.pyi", src = "@libdirs", dst = "venv/Lib/site-packages")
self.copy("*.dylib", src = "@libdirs", dst = "venv/bin") self.copy("*.dylib", src = "@libdirs", dst = "venv/bin")
def deploy(self):
self.copy_deps("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
self.copy_deps("CuraEngine", root_package = "curaengine", src = "@bindirs", dst = "", keep_path = False)
self.copy_deps("*.fdm_material", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
self.copy_deps("*.sig", root_package = "fdm_materials", src = "@resdirs", dst = "resources/materials", keep_path = False)
self.copy_deps("*.dll", src = "@bindirs", dst = "venv/Lib/site-packages")
self.copy_deps("*.pyd", src = "@libdirs", dst = "venv/Lib/site-packages")
self.copy_deps("*.pyi", src = "@libdirs", dst = "venv/Lib/site-packages")
self.copy_deps("*.dylib", src = "@libdirs", dst = "venv/bin")
with open(Path("CuraVersion.py.jinja"), "r") as f:
cura_version_py = Template(f.read())
# TODO: Extend
def package(self): def package(self):
self.copy("*", src = "cura", dst = os.path.join(self.cpp.package.libdirs[0], "cura")) self.copy("*", src = "cura", dst = os.path.join(self.cpp.package.libdirs[0], "cura"))
self.copy("*", src = "plugins", dst = os.path.join(self.cpp.package.libdirs[0], "plugins")) self.copy("*", src = "plugins", dst = os.path.join(self.cpp.package.libdirs[0], "plugins"))

View File

@ -1,13 +0,0 @@
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
CuraAppName = "@CURA_APP_NAME@"
CuraAppDisplayName = "@CURA_APP_DISPLAY_NAME@"
CuraVersion = "@CURA_VERSION@"
CuraBuildType = "@CURA_BUILDTYPE@"
CuraDebugMode = True if "@_cura_debugmode@" == "ON" else False
CuraCloudAPIRoot = "@CURA_CLOUD_API_ROOT@"
CuraCloudAPIVersion = "@CURA_CLOUD_API_VERSION@"
CuraCloudAccountAPIRoot = "@CURA_CLOUD_ACCOUNT_API_ROOT@"
CuraMarketplaceRoot = "@CURA_MARKETPLACE_ROOT@"
CuraDigitalFactoryURL = "@CURA_DIGITAL_FACTORY_URL@"