Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Np 186 seperate cura resources #19039

Merged
merged 13 commits into from
May 10, 2024
Merged
41 changes: 41 additions & 0 deletions .github/workflows/conan-package-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: conan-package-resources

on:
push:
paths:
- '.github/workflows/conan-package-resources.yml'
- 'resources/definitions/**'
- 'resources/extruders/**'
- 'resources/images/**'
- 'resources/intent/**'
- 'resources/meshes/**'
- 'resources/quality/**'
- 'resources/variants/**'
- 'resources/conanfile.py'
branches:
- 'main'
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9].[0-9]*'
- '[0-9].[0-9][0-9]*'

env:
CONAN_LOGIN_USERNAME_CURA: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD_CURA: ${{ secrets.CONAN_PASS }}

jobs:
conan-recipe-version:
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@main
with:
project_name: cura_resources

# FIXME: Point to main, once merged
conan-package-export:
needs: [ conan-recipe-version ]
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@NP-186_seperate_cura_resources
with:
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }}
conan_recipe_root: "./resources/"
secrets: inherit
16 changes: 13 additions & 3 deletions .github/workflows/conan-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ on:
push:
paths:
- 'plugins/**'
- 'resources/**'
- 'cura/**'
- 'resources/bundled_packages/**'
- 'resources/i18n/**'
- 'resources/qml/**'
- 'resources/setting_visibility/**'
- 'resources/shaders/**'
- 'resources/texts/**'
- 'resources/themes/**'
- 'resources/public_key.pem'
- 'resources/README_resources.txt'
- 'icons/**'
- 'tests/**'
- 'packaging/**'
- '.github/workflows/conan-*.yml'
- '.github/workflows/conan-package.yml'
- '.github/workflows/notify.yml'
- '.github/workflows/requirements-runner.txt'
- 'requirements*.txt'
Expand All @@ -20,6 +28,7 @@ on:
- 'main'
- 'CURA-*'
- 'PP-*'
- 'NP-*'
- '[0-9].[0-9]*'
- '[0-9].[0-9][0-9]*'

Expand All @@ -33,9 +42,10 @@ jobs:
with:
project_name: cura

# FIXME: point to main once merged
conan-package-export:
needs: [ conan-recipe-version ]
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@main
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@NP-186_seperate_cura_resources
with:
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }}
Expand Down
29 changes: 25 additions & 4 deletions conandata.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "5.8.0-alpha.0"
requirements:
- "cura_resources/(latest)@ultimaker/np_186"
- "uranium/(latest)@ultimaker/testing"
- "curaengine/(latest)@ultimaker/testing"
- "cura_binary_data/(latest)@ultimaker/testing"
Expand Down Expand Up @@ -50,10 +51,30 @@ pyinstaller:
package: "native_cad_plugin"
src: "res/bundled_packages"
dst: "share/cura/resources/bundled_packages"
cura_resources:
package: "cura"
src: "resources"
dst: "share/cura/resources"
cura_resources_definitions:
package: "cura_resources"
src: "res/definitions"
dst: "share/cura/resources/definitions"
cura_resources_extruders:
package: "cura_resources"
src: "res/extruders"
dst: "share/cura/resources/extruders"
cura_resources_intent:
package: "cura_resources"
src: "res/intent"
dst: "share/cura/resources/intent"
cura_resources_meshes:
package: "cura_resources"
src: "res/meshes"
dst: "share/cura/resources/meshes"
cura_resources_quality:
package: "cura_resources"
src: "res/quality"
dst: "share/cura/resources/quality"
cura_resources_variants:
package: "cura_resources"
src: "res/variants"
dst: "share/cura/resources/variants"
wawanbreton marked this conversation as resolved.
Show resolved Hide resolved
cura_private_data:
package: "cura_private_data"
src: "res"
Expand Down
12 changes: 12 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ def deploy(self):
copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[0]), str(self._share_dir.joinpath("cura", "resources")), keep_path = True)
copy(self, "*", os.path.join(self.package_folder, self.cpp_info.resdirs[1]), str(self._share_dir.joinpath("cura", "plugins")), keep_path = True)

# Copy the cura_resources resources from the package
rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
cura_resources = self.dependencies["cura_resources"].cpp_info
for res_dir in cura_resources.resdirs:
copy(self, "*", res_dir, str(self._share_dir.joinpath("cura", "resources", Path(res_dir).name)), keep_path = True)

# Copy resources of Uranium (keep folder structure)
uranium = self.dependencies["uranium"].cpp_info
copy(self, "*", uranium.resdirs[0], str(self._share_dir.joinpath("uranium", "resources")), keep_path = True)
Expand Down Expand Up @@ -519,6 +525,12 @@ def package(self):
# Remove the fdm_materials from the package
rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], "materials"))

# Remove the cura_resources resources from the package
rm(self, "conanfile.py", os.path.join(self.package_folder, self.cpp.package.resdirs[0]))
cura_resources = self.dependencies["cura_resources"].cpp_info
for res_dir in cura_resources.resdirs:
rmdir(self, os.path.join(self.package_folder, self.cpp.package.resdirs[0], Path(res_dir).name))

def package_info(self):
self.user_info.pip_requirements = "requirements.txt"
self.user_info.pip_requirements_git = "requirements-ultimaker.txt"
Expand Down
69 changes: 69 additions & 0 deletions resources/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import os

from conan import ConanFile
from conan.tools.files import copy, update_conandata
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration

required_conan_version = ">=1.58.0 <2.0.0"


class CuraResource(ConanFile):
name = "cura_resources"
license = ""
author = "UltiMaker"
url = "https://github.com/Ultimaker/cura-private-data"
jellespijker marked this conversation as resolved.
Show resolved Hide resolved
description = "Cura Resources"
topics = ("conan", "cura")
exports = "LICENSE*"
jellespijker marked this conversation as resolved.
Show resolved Hide resolved
settings = "os", "compiler", "build_type", "arch"
no_copy_source = True

def set_version(self):
if not self.version:
self.version = self.conan_data["version"]

def export(self):
copy(self, pattern="conandata.yml", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
keep_path=False)
update_conandata(self, {"version": self.version})

def export_sources(self):
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "definitions"),
dst=os.path.join(self.export_sources_folder, "definitions"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "extruders"),
dst=os.path.join(self.export_sources_folder, "extruders"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "images"),
dst=os.path.join(self.export_sources_folder, "images"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "intent"),
dst=os.path.join(self.export_sources_folder, "intent"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "meshes"),
dst=os.path.join(self.export_sources_folder, "meshes"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "quality"),
dst=os.path.join(self.export_sources_folder, "quality"))
copy(self, pattern="*", src=os.path.join(self.recipe_folder, "variants"),
dst=os.path.join(self.export_sources_folder, "variants"))
jellespijker marked this conversation as resolved.
Show resolved Hide resolved

def validate(self):
if Version(self.version) <= Version("4"):
raise ConanInvalidConfiguration("Only versions 5+ are support")

def layout(self):
self.cpp.source.resdirs = ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"]
self.cpp.package.resdirs = ["res/definitions", "res/extruders", "res/images", "res/intent", "res/meshes", "res/quality", "res/variants"]
jellespijker marked this conversation as resolved.
Show resolved Hide resolved

def package(self):
copy(self, "*", os.path.join(self.export_sources_folder),
os.path.join(self.package_folder, "res"))

def package_info(self):
self.cpp_info.includedirs = []
self.runenv_info.append_path("CURA_RESOURCES", os.path.join(self.package_folder, "res"))
self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "definitions"))
self.runenv_info.append_path("CURA_ENGINE_SEARCH_PATH", os.path.join(self.package_folder, "res", "extruders"))
self.env_info.CURA_RESOURCES.append(os.path.join(self.package_folder, "res"))
self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))
self.env_info.CURA_ENGINE_SEARCH_PATH.append(os.path.join(self.package_folder, "res", "definitions"))

def package_id(self):
self.info.clear()
Loading