Skip to content

Commit

Permalink
Merge pull request #19039 from Ultimaker/NP-186_seperate_cura_resources
Browse files Browse the repository at this point in the history
Np 186 seperate cura resources
  • Loading branch information
jellespijker authored May 10, 2024
2 parents a9084f3 + e1603f3 commit 5e731b8
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 4 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/conan-package-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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

conan-package-export:
needs: [ conan-recipe-version ]
uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@main
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
13 changes: 11 additions & 2 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 Down
5 changes: 3 additions & 2 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/latest"
- "uranium/(latest)@ultimaker/testing"
- "curaengine/(latest)@ultimaker/testing"
- "cura_binary_data/(latest)@ultimaker/testing"
Expand Down Expand Up @@ -51,8 +52,8 @@ pyinstaller:
src: "res/bundled_packages"
dst: "share/cura/resources/bundled_packages"
cura_resources:
package: "cura"
src: "resources"
package: "cura_resources"
src: "res"
dst: "share/cura/resources"
cura_private_data:
package: "cura_private_data"
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
64 changes: 64 additions & 0 deletions resources/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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"
description = "Cura Resources"
topics = ("conan", "cura")
settings = "os", "compiler", "build_type", "arch"
no_copy_source = True


@property
def _shared_resources(self):
return ["definitions", "extruders", "images", "intent", "meshes", "quality", "variants"]

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)
copy(self, pattern="LICENSE*", src=os.path.join(self.recipe_folder, ".."), dst=self.export_folder,
keep_path=False)
update_conandata(self, {"version": self.version})

def export_sources(self):
for shared_resources in self._shared_resources:
copy(self, pattern="*", src=os.path.join(self.recipe_folder, shared_resources),
dst=os.path.join(self.export_sources_folder, shared_resources))

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

def layout(self):
self.cpp.source.resdirs = self._shared_resources
self.cpp.package.resdirs = [f"res/{res}" for res in self._shared_resources]

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()

0 comments on commit 5e731b8

Please sign in to comment.