Use only pip in conan requirements

No longer download and mess with sources from
other repo's.

Created Conan packages for cura-binary-data,
fdm_materials and uranium.

Charon is installed with pip. I had to create
a separate requirement file for that since
you can't mix and match git and hashes.

Contributes to CURA-9365
This commit is contained in:
j.spijker@ultimaker.com 2022-06-16 19:55:56 +02:00 committed by Jelle Spijker
parent b8a4243e26
commit 6cbc9aaa38
4 changed files with 227 additions and 243 deletions

View file

@ -15,7 +15,7 @@ block_cipher = None
a = Analysis( a = Analysis(
['{{ entrypoint }}'], ['{{ entrypoint }}'],
pathex={{ pathex }}, pathex=[],
binaries=binaries, binaries=binaries,
datas=datas, datas=datas,
hiddenimports=hiddenimports, hiddenimports=hiddenimports,

View file

@ -1,144 +1,138 @@
"dev": requirements:
conan: "5.1.0-beta":
curaengine: "curaengine/latest@ultimaker/cura-9365" - "arcus/5.1.0-beta@ultimaker/stable"
arcus: "arcus/latest@ultimaker/cura-9365" - "curaengine/5.1.0-beta@ultimaker/stable"
savitar: "savitar/latest@ultimaker/cura-9365" - "savitar/5.1.0-beta@ultimaker/stable"
pynest2d: "pynest2d/latest@ultimaker/cura-9365" - "pynest2d/5.1.0-beta@ultimaker/stable"
sources: - "uranium/5.1.0-beta@ultimaker/stable"
fdm_materials: - "fdm_materials/5.1.0-beta@ultimaker/stable"
root: "../fdm_materials" - "cura_binary_data/5.1.0-beta@ultimaker/stable"
src: "." "5.1.0-cura_9365":
dst: "resources/materials/fdm_materials" - "arcus/5.1.0-cura_9365@ultimaker/testing"
filter: [ "**/*.fdm_material", "**/*.sig" ] - "curaengine/5.1.0-cura_9365@ultimaker/testing"
pyinstaller: - "savitar/5.1.0-cura_9365@ultimaker/testing"
datas: - "pynest2d/5.1.0-cura_9365@ultimaker/testing"
cura_plugins: - "uranium/5.1.0-cura_9365@ultimaker/testing"
root: "." - "fdm_materials/5.1.0-cura_9365@ultimaker/testing"
src: "plugins" - "cura_binary_data/5.1.0-cura_9365@ultimaker/testing"
dst: "share/cura/plugins" pyinstaller:
cura_resources: "5.1.0-beta":
root: "." datas:
src: "resources" cura_plugins:
dst: "share/cura/resources" package: "cura"
uranium_plugins: src: "site-packages/plugins"
root: "../uranium" dst: "share/cura/plugins"
src: "plugins" cura_resources:
dst: "share/uranium/plugins" root: "package"
uranium_resources: src: "res/resources"
root: "../uranium" dst: "share/cura/resources"
src: "resources" uranium_plugins:
dst: "share/uranium/resources" package: "uranium"
uranium_um_qt_qml_um: src: "site-packages/plugins"
root: "../uranium" dst: "share/uranium/plugins"
src: "UM/Qt/qml/UM" uranium_resources:
dst: "PyQt6/qt6/qml/UM" package: "uranium"
cura_binary_data: src: "res/resources"
root: "../cura-binary-data" dst: "share/uranium/resources"
src: "cura/resources" uranium_um_qt_qml_um:
dst: "share/cura/resources" package: "uranium"
uranium_binary_data: src: "site-packages/UM/Qt/qml/UM"
root: "../cura-binary-data" dst: "PyQt6/qt6/qml/UM"
src: "uranium/resources" cura_binary_data:
dst: "share/uranium/resources" package: "cura_binary_data"
binaries: src: "res/cura/resources"
curaengine: dst: "share/cura/resources"
package: "curaengine" uranium_binary_data:
src: "bin" package: "cura_binary_data"
dst: "." src: "res/uranium/resources"
binary: "CuraEngine" dst: "share/uranium/resources"
hiddenimports: fdm_materials:
- "pySavitar" package: "fdm_materials"
- "pyArcus" src: "res/materials"
- "pynest2d" dst: "share/cura/resources/materials"
- "PyQt6.QtNetwork" binaries:
- "logging.handlers" curaengine:
- "zeroconf" package: "curaengine"
- "fcntl" src: "bin"
collect_all: dst: "."
- "cura" binary: "CuraEngine"
- "UM" hiddenimports:
- "serial" - "pySavitar"
- "Charon" - "pyArcus"
- "sqlite3" - "pynest2d"
- "trimesh" - "PyQt6.QtNetwork"
- "win32ctypes" - "logging.handlers"
pathex: - "zeroconf"
- "." - "fcntl"
- "../uranium" collect_all:
- "../libcharon" - "cura"
icon: - "UM"
Windows: "./icons/Cura.ico" - "serial"
Macos: "./icons/cura.icns" - "Charon"
Linux: ".icons/cura-128.png" - "sqlite3"
"5.1.0-CURA-9365": - "trimesh"
conan: - "win32ctypes"
curaengine: "curaengine/latest@ultimaker/cura-9365" icon:
arcus: "arcus/latest@ultimaker/cura-9365" Windows: "./icons/Cura.ico"
savitar: "savitar/latest@ultimaker/cura-9365" Macos: "./icons/cura.icns"
pynest2d: "pynest2d/latest@ultimaker/cura-9365" Linux: ".icons/cura-128.png"
sources: "5.1.0-cura_9365":
fdm_materials: datas:
root: "../fdm_materials" cura_plugins:
src: "." package: "cura"
dst: "resources/materials/fdm_materials" src: "site-packages/plugins"
filter: [ "**/*.fdm_material", "**/*.sig" ] dst: "share/cura/plugins"
pyinstaller: cura_resources:
datas: root: "package"
cura_plugins: src: "res/resources"
root: "." dst: "share/cura/resources"
src: "plugins" uranium_plugins:
dst: "share/cura/plugins" package: "uranium"
cura_resources: src: "site-packages/plugins"
root: "." dst: "share/uranium/plugins"
src: "resources" uranium_resources:
dst: "share/cura/resources" package: "uranium"
uranium_plugins: src: "res/resources"
root: "../uranium" dst: "share/uranium/resources"
src: "plugins" uranium_um_qt_qml_um:
dst: "share/uranium/plugins" package: "uranium"
uranium_resources: src: "site-packages/UM/Qt/qml/UM"
root: "../uranium" dst: "PyQt6/qt6/qml/UM"
src: "resources" cura_binary_data:
dst: "share/uranium/resources" package: "cura_binary_data"
uranium_um_qt_qml_um: src: "res/cura/resources"
root: "../uranium" dst: "share/cura/resources"
src: "UM/Qt/qml/UM" uranium_binary_data:
dst: "PyQt6/qt6/qml/UM" package: "cura_binary_data"
cura_binary_data: src: "res/uranium/resources"
root: "../cura-binary-data" dst: "share/uranium/resources"
src: "cura/resources" fdm_materials:
dst: "share/cura/resources" package: "fdm_materials"
uranium_binary_data: src: "res/materials"
root: "../cura-binary-data" dst: "share/cura/resources/materials"
src: "uranium/resources" binaries:
dst: "share/uranium/resources" curaengine:
binaries: package: "curaengine"
curaengine: src: "bin"
package: "curaengine" dst: "."
src: "bin" binary: "CuraEngine"
dst: "." hiddenimports:
binary: "CuraEngine" - "pySavitar"
hiddenimports: - "pyArcus"
- "pySavitar" - "pynest2d"
- "pyArcus" - "PyQt6.QtNetwork"
- "pynest2d" - "logging.handlers"
- "PyQt6.QtNetwork" - "zeroconf"
- "logging.handlers" - "fcntl"
- "zeroconf" collect_all:
- "fcntl" - "cura"
collect_all: - "UM"
- "cura" - "serial"
- "UM" - "Charon"
- "serial" - "sqlite3"
- "Charon" - "trimesh"
- "sqlite3" - "win32ctypes"
- "trimesh" icon:
- "win32ctypes" Windows: "./icons/Cura.ico"
pathex: Macos: "./icons/cura.icns"
- "." Linux: ".icons/cura-128.png"
- "../uranium"
- "../libcharon"
icon:
Windows: "./icons/Cura.ico"
Macos: "./icons/cura.icns"
Linux: ".icons/cura-128.png"

View file

@ -1,5 +1,4 @@
import os import os
import shutil
from pathlib import Path from pathlib import Path
from platform import python_version from platform import python_version
@ -23,13 +22,15 @@ class CuraConan(ConanFile):
build_policy = "missing" build_policy = "missing"
exports = "LICENSE*" exports = "LICENSE*"
settings = "os", "compiler", "build_type", "arch" settings = "os", "compiler", "build_type", "arch"
no_copy_source = True
options = { options = {
"python_version": "ANY", "python_version": "ANY",
"enterprise": ["True", "False", "true", "false"], "enterprise": ["True", "False", "true", "false"],
"staging": ["True", "False", "true", "false"], "staging": ["True", "False", "true", "false"],
"devtools": [True, False], "devtools": [True, False],
"cloud_api_version": "ANY", "cloud_api_version": "ANY",
"display_name": "ANY" "display_name": "ANY",
"cura_debug_mode": [True, False]
} }
default_options = { default_options = {
"python_version": "system", "python_version": "system",
@ -37,7 +38,8 @@ class CuraConan(ConanFile):
"staging": "False", "staging": "False",
"devtools": False, "devtools": False,
"cloud_api_version": "1", "cloud_api_version": "1",
"display_name": "Ultimaker Cura" "display_name": "Ultimaker Cura",
"cura_debug_mode": False
} }
scm = { scm = {
"type": "git", "type": "git",
@ -47,21 +49,9 @@ class CuraConan(ConanFile):
} }
@property @property
def conandata_version(self): def _conan_data_version(self):
if not self.version or self.version == "dev":
return "dev"
version = tools.Version(self.version) version = tools.Version(self.version)
version = f"{version.major}.{version.minor}.{version.patch}-{version.prerelease}" return f"{version.major}.{version.minor}.{version.patch}-{version.prerelease}"
if version in self.conan_data:
return version
return "dev"
def set_version(self):
if not self.version:
if "CURA_VERSION" in os.environ:
self.version = os.environ["CURA_VERSION"]
else:
self.version = "dev"
@property @property
def _staging(self): def _staging(self):
@ -90,8 +80,8 @@ class CuraConan(ConanFile):
@property @property
def requirements_txts(self): def requirements_txts(self):
if self.options.devtools: if self.options.devtools:
return ["requirements.txt", "requirements-dev.txt"] return ["requirements.txt", "requirements-ultimaker.txt", "requirements-dev.txt"]
return "requirements.txt" return ["requirements.txt", "requirements-ultimaker.txt"]
def config_options(self): def config_options(self):
if self.options.python_version == "system": if self.options.python_version == "system":
@ -99,35 +89,25 @@ class CuraConan(ConanFile):
def configure(self): def configure(self):
self.options["*"].shared = True self.options["*"].shared = True
self.options["*"].python_version = self.options.python_version
def validate(self): def validate(self):
if self.version: if tools.Version(self.version) <= tools.Version("4"):
if self.version != "dev" and tools.Version(self.version) <= tools.Version("4"): raise ConanInvalidConfiguration("Only versions 5+ are support")
raise ConanInvalidConfiguration("Only versions 5+ are support")
def requirements(self): def requirements(self):
for req in self.conan_data[self.conandata_version]["conan"].values(): for req in self.conan_data["requirements"][self._conan_data_version]:
self.requires(req) self.requires(req)
def layout(self):
self.folders.source = "."
self.folders.build = "venv"
self.folders.generators = os.path.join(self.folders.build, "conan")
self.cpp.package.libdirs = ["site-packages"]
def generate(self): def generate(self):
for source in self.conan_data[self.conandata_version]["sources"].values(): # TODO: handle materials when running from source and using the fdm_materials
src_path = Path(self.source_folder, source["root"], source["src"])
if not src_path.exists():
continue
dst_root_path = Path(self.source_folder, source["dst"])
if dst_root_path.exists():
shutil.rmtree(dst_root_path, ignore_errors = True)
dst_root_path.mkdir(parents = True)
if "filter" in source:
for pattern in source["filter"]:
for file in src_path.glob(pattern):
rel_file = file.relative_to(src_path)
dst_file = dst_root_path.joinpath(rel_file)
if not dst_file.parent.exists():
dst_file.parent.mkdir(parents = True)
shutil.copy(file, dst_file)
else:
shutil.copytree(src_path, dst_root_path)
with open(Path(self.source_folder, "cura", "CuraVersion.py.jinja"), "r") as f: with open(Path(self.source_folder, "cura", "CuraVersion.py.jinja"), "r") as f:
cura_version_py = Template(f.read()) cura_version_py = Template(f.read())
@ -136,75 +116,84 @@ class CuraConan(ConanFile):
f.write(cura_version_py.render( f.write(cura_version_py.render(
cura_app_name = self.name, cura_app_name = self.name,
cura_app_display_name = self.options.display_name, cura_app_display_name = self.options.display_name,
cura_version = self.version if self.version else "dev", cura_version = self.version,
cura_build_type = "Enterprise" if self._enterprise else "", cura_build_type = "Enterprise" if self._enterprise else "",
cura_debug_mode = self.settings.build_type != "Release", cura_debug_mode = self.options.cura_debug_mode,
cura_cloud_api_root = self._cloud_api_root, cura_cloud_api_root = self._cloud_api_root,
cura_cloud_api_version = self.options.cloud_api_version, cura_cloud_api_version = self.options.cloud_api_version,
cura_cloud_account_api_root = self._cloud_account_api_root, cura_cloud_account_api_root = self._cloud_account_api_root,
cura_marketplace_root = self._marketplace_root, cura_marketplace_root = self._marketplace_root,
cura_digital_factory_url = self._digital_factory_url)) cura_digital_factory_url = self._digital_factory_url))
if self.options.devtools: # Create the Ultimaker-Cura.spec
# Create the Ultimaker-Cura.spec based on the data in the conandata.yml # TODO: Create a generator for this
with open(Path(self.source_folder, "Ultimaker-Cura.spec.jinja"), "r") as f: # TODO: Create exception for not in_local_cache
pyinstaller = Template(f.read()) # 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.conan_data[self.conandata_version]["pyinstaller"] pyinstaller_metadata = self.conan_data["pyinstaller"][self._conan_data_version]
datas = [] datas = []
for data in pyinstaller_metadata["datas"].values(): for data in pyinstaller_metadata["datas"].values():
if "package" in data: # get the paths from conan package if "package" in data: # get the paths from conan package
if data["package"] == self.name:
src_path = Path(self.package_folder, data["src"])
else:
src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"]) src_path = Path(self.deps_cpp_info[data["package"]].rootpath, data["src"])
elif "root" in data: # get the paths relative from the sourcefolder elif "root" in data: # get the paths relative from the sourcefolder
src_path = Path(self.source_folder, data["root"], data["src"]) src_path = Path(self.source_folder, data["root"], data["src"])
else: else:
continue continue
if src_path.exists(): if src_path.exists():
datas.append((str(src_path), data["dst"])) 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"]))
pathex = [str(Path(self.source_folder, p)) for p in pyinstaller_metadata["pathex"]] with open(Path(self.generators_folder, "Ultimaker-Cura.spec"), "w") as f:
f.write(pyinstaller.render(
with open(Path(self.source_folder, "Ultimaker-Cura.spec"), "w") as f: name = str(self.options.display_name).replace(" ", "-"),
f.write(pyinstaller.render( entrypoint = "cura_app.py",
name = str(self.options.display_name).replace(" ", "-"), datas = datas,
entrypoint = "cura_app.py", binaries = binaries,
datas = datas, hiddenimports = pyinstaller_metadata["hiddenimports"],
binaries = binaries, collect_all = pyinstaller_metadata["collect_all"],
hiddenimports = pyinstaller_metadata["hiddenimports"], icon = pyinstaller_metadata["icon"][str(self.settings.os)]
collect_all = pyinstaller_metadata["collect_all"], ))
pathex = pathex,
icon = pyinstaller_metadata["icon"][str(self.settings.os)]
))
def layout(self):
self.folders.source = "."
self.folders.build = "venv"
self.folders.generators = os.path.join(self.folders.build, "conan")
# FIXME: Once libCharon en Uranium are also Packages
self.runenv_info.append_path("PYTHONPATH", str(Path(__file__).parent))
self.runenv_info.append_path("PYTHONPATH", str(Path(__file__).parent.parent.joinpath("uranium")))
self.runenv_info.append_path("PYTHONPATH", str(Path(__file__).parent.parent.joinpath("libcharon")))
def imports(self): def imports(self):
self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = self.source_folder, keep_path = False) self.copy("CuraEngine.exe", root_package = "curaengine", src = "@bindirs", dst = self.source_folder, keep_path = False)
self.copy("CuraEngine", root_package = "curaengine", src = "@bindirs", dst = self.source_folder, keep_path = False) self.copy("CuraEngine", root_package = "curaengine", src = "@bindirs", dst = self.source_folder, keep_path = False)
self.copy("*.dll", src = "@bindirs", dst = os.path.join(self.folders.build, "Lib", "site-packages")) self.copy("*.dll", src = "@bindirs", dst = os.path.join(self.build_folder, "Lib", "site-packages"))
self.copy("*.pyd", src = "@libdirs", dst = os.path.join(self.folders.build, "Lib", "site-packages")) self.copy("*.pyd", src = "@libdirs", dst = os.path.join(self.build_folder, "Lib", "site-packages"))
self.copy("*.pyi", src = "@libdirs", dst = os.path.join(self.folders.build, "Lib", "site-packages")) self.copy("*.pyi", src = "@libdirs", dst = os.path.join(self.build_folder, "Lib", "site-packages"))
self.copy("*.dylib", src = "@libdirs", dst = os.path.join(self.folders.build, "bin")) self.copy("*.dylib", src = "@libdirs", dst = os.path.join(self.build_folder, "bin"))
def package(self):
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 = "resources", dst = os.path.join(self.cpp.package.resdirs[0], "resources"))
def package_info(self):
if self.in_local_cache:
self.runenv_info.append_path("PYTHONPATH", self.cpp_info.libdirs[0])
else:
self.runenv_info.append_path("PYTHONPATH", self.source_folder)
def package_id(self):
del self.info.settings.os
del self.info.settings.compiler
del self.info.settings.build_type
del self.info.settings.arch

View file

@ -0,0 +1 @@
git+https://github.com/ultimaker/libcharon@master#egg=charon