Skip to content

Commit 52dc83a

Browse files
authored
Merge pull request #4 from Ultimaker/CURA-11622_conan_v2
Cura 11622 conan v2
2 parents 38e64bb + 97dc0cc commit 52dc83a

File tree

7 files changed

+78
-208
lines changed

7 files changed

+78
-208
lines changed
Lines changed: 19 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,24 @@
1-
---
21
name: conan-package
32

4-
# Exports the recipe, sources and binaries for Mac, Windows and Linux and upload these to the server such that these can
5-
# be used downstream.
6-
#
7-
# It should run on pushes against main or CURA-* branches, but it will only create the binaries for main and release branches
8-
93
on:
10-
workflow_dispatch:
11-
inputs:
12-
# FIXME: Not yet implemented
13-
conan_id:
14-
required: false
15-
type: string
16-
description: 'The full conan package ID, e.g. "libnest2d/1.2.3@ultimaker/stable"'
17-
create_latest_alias:
18-
required: true
19-
default: false
20-
type: boolean
21-
description: 'Create latest alias'
22-
create_binaries_windows:
23-
required: true
24-
default: false
25-
type: boolean
26-
description: 'create binaries Windows'
27-
create_binaries_linux:
28-
required: true
29-
default: false
30-
type: boolean
31-
description: 'create binaries Linux'
32-
create_binaries_macos:
33-
required: true
34-
default: false
35-
type: boolean
36-
description: 'create binaries Macos'
37-
38-
push:
39-
paths:
40-
- 'python/**'
41-
- 'test_package/**'
42-
- 'cmake/**'
43-
- 'conanfile.py'
44-
- 'conandata.yml'
45-
- 'CMakeLists.txt'
46-
- '.github/workflows/conan-package.yml'
47-
- '.github/workflows/requirements*'
48-
branches:
49-
- main
50-
- 'CURA-*'
51-
- '[0-9]+.[0-9]+'
52-
tags:
53-
- '[0-9]+.[0-9]+.[0-9]*'
4+
push:
5+
paths:
6+
- 'python/**'
7+
- 'test_package/**'
8+
- 'cmake/**'
9+
- 'conanfile.py'
10+
- 'conandata.yml'
11+
- 'CMakeLists.txt'
12+
- '.github/workflows/conan-package.yml'
13+
branches:
14+
- main
15+
- 'CURA-*'
16+
- 'PP-*'
17+
- 'NP-*'
18+
- '[0-9].[0-9]*'
19+
- '[0-9].[0-9][0-9]*'
5420

5521
jobs:
56-
conan-recipe-version:
57-
uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main
58-
with:
59-
project_name: pysavitar
60-
61-
conan-package-export:
62-
needs: [ conan-recipe-version ]
63-
uses: ultimaker/cura/.github/workflows/conan-recipe-export.yml@main
64-
with:
65-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
66-
recipe_id_latest: ${{ needs.conan-recipe-version.outputs.recipe_id_latest }}
67-
runs_on: 'ubuntu-20.04'
68-
python_version: '3.10.x'
69-
conan_logging_level: 'info'
70-
secrets: inherit
71-
72-
conan-package-create-windows:
73-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true' )) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_windows) }}
74-
needs: [ conan-recipe-version, conan-package-export ]
75-
76-
uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main
77-
with:
78-
project_name: ${{ needs.conan-recipe-version.outputs.project_name }}
79-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
80-
build_id: 4
81-
build_info: false
82-
runs_on: 'windows-2022'
83-
python_version: '3.10.x'
84-
conan_config_branch: ''
85-
conan_logging_level: 'info'
86-
secrets: inherit
87-
88-
conan-package-create-macos:
89-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_macos) }}
90-
needs: [ conan-recipe-version, conan-package-export ]
91-
92-
uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main
93-
with:
94-
project_name: ${{ needs.conan-recipe-version.outputs.project_name }}
95-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
96-
build_id: 3
97-
build_info: false
98-
runs_on: 'macos-11'
99-
python_version: '3.10.x'
100-
conan_logging_level: 'info'
101-
secrets: inherit
102-
103-
conan-package-create-linux-modern:
104-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux) }}
105-
needs: [ conan-recipe-version, conan-package-export ]
106-
107-
uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main
108-
with:
109-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
110-
project_name: ${{ needs.conan-recipe-version.outputs.project_name }}
111-
build_id: 2
112-
build_info: false
113-
runs_on: 'ubuntu-22.04'
114-
python_version: '3.10.x'
115-
conan_logging_level: 'info'
116-
secrets: inherit
117-
118-
conan-package-create-linux:
119-
if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux) }}
120-
needs: [ conan-recipe-version, conan-package-export ]
121-
122-
uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main
123-
with:
124-
recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }}
125-
project_name: ${{ needs.conan-recipe-version.outputs.project_name }}
126-
build_id: 1
127-
build_info: false
128-
runs_on: 'ubuntu-20.04'
129-
python_version: '3.10.x'
130-
conan_logging_level: 'info'
131-
secrets: inherit
132-
133-
notify-export:
134-
if: ${{ always() }}
135-
needs: [ conan-recipe-version, conan-package-export ]
136-
137-
uses: ultimaker/cura/.github/workflows/notify.yml@main
138-
with:
139-
success: ${{ contains(join(needs.*.result, ','), 'success') }}
140-
success_title: "New Conan recipe exported in ${{ github.repository }}"
141-
success_body: "Exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}"
142-
failure_title: "Failed to export Conan Export in ${{ github.repository }}"
143-
failure_body: "Failed to exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}"
144-
secrets: inherit
145-
146-
notify-create:
147-
if: ${{ always() && ((github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch)) || (github.event_name == 'workflow_dispatch' && inputs.create_binaries_linux)) }}
148-
needs: [ conan-recipe-version, conan-package-create-macos, conan-package-create-windows, conan-package-create-linux, conan-package-create-linux-modern ]
149-
150-
uses: ultimaker/cura/.github/workflows/notify.yml@main
151-
with:
152-
success: ${{ contains(join(needs.*.result, ','), 'success') }}
153-
success_title: "New binaries created in ${{ github.repository }}"
154-
success_body: "Created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}"
155-
failure_title: "Failed to create binaries in ${{ github.repository }}"
156-
failure_body: "Failed to created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}"
157-
secrets: inherit
22+
conan-package:
23+
uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main
24+
secrets: inherit

.github/workflows/requirements-conan-package.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ test_package/build/
4545

4646
pyproject.toml
4747
build-*/
48+
/test_package/metadata/
49+
/test_package/conanbuild.sh
50+
/test_package/conanbuildenv-release-x86_64.sh
51+
/test_package/conanrun.sh
52+
/test_package/conanrunenv-release-x86_64.sh
53+
/test_package/deactivate_conanbuild.sh
54+
/test_package/deactivate_conanrun.sh
55+
/test_package/deactivate_conanrunenv-release-x86_64.sh

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
cmake_policy(SET CMP0091 NEW)
2-
project(pysavitar)
31
cmake_minimum_required(VERSION 3.20)
2+
project(pysavitar)
3+
cmake_policy(SET CMP0091 NEW)
44

5-
find_package(cpython REQUIRED)
5+
find_package(Python REQUIRED)
66
find_package(savitar REQUIRED)
77

88
find_package(standardprojectsettings REQUIRED)

conandata.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: "5.4.0-alpha.0"
2+
requirements:
3+
- "savitar/[>=5.4.0]@ultimaker/stable"

conanfile.py

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import os
22

33
from pathlib import Path
4-
from os import path
54

65
from conan import ConanFile
76
from conan.errors import ConanInvalidConfiguration
87
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
9-
from conan.tools.env import VirtualBuildEnv
10-
from conan.tools.files import copy, mkdir
8+
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
9+
from conan.tools.files import copy, mkdir, update_conandata
1110
from conan.tools.build import check_min_cppstd
1211
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime
13-
from conan.tools.scm import Version
12+
from conan.tools.scm import Version, Git
1413

15-
16-
required_conan_version = ">=1.56.0"
14+
required_conan_version = ">=2.7.0"
1715

1816

1917
class PySavitarConan(ConanFile):
@@ -24,11 +22,10 @@ class PySavitarConan(ConanFile):
2422
description = "pySavitar is a c++ implementation of 3mf loading with SIP python bindings"
2523
topics = ("conan", "cura", "3mf", "c++")
2624
settings = "os", "compiler", "build_type", "arch"
27-
revision_mode = "scm"
2825
exports = "LICENSE*"
29-
generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv"
26+
generators = "CMakeDeps"
3027

31-
python_requires = "pyprojecttoolchain/[>=0.1.7]@ultimaker/stable", "sipbuildtool/[>=0.2.4]@ultimaker/stable"
28+
python_requires = "pyprojecttoolchain/[>=0.2.0]@ultimaker/stable", "sipbuildtool/[>=0.3.0]@ultimaker/stable"
3229

3330
options = {
3431
"shared": [True, False],
@@ -45,7 +42,11 @@ class PySavitarConan(ConanFile):
4542

4643
def set_version(self):
4744
if not self.version:
48-
self.version = "5.4.0-alpha"
45+
self.version = self.conan_data["version"]
46+
47+
def export(self):
48+
git = Git(self)
49+
update_conandata(self, {"version": self.version, "commit": git.get_commit()})
4950

5051
@property
5152
def _min_cppstd(self):
@@ -54,20 +55,21 @@ def _min_cppstd(self):
5455
@property
5556
def _compilers_minimum_version(self):
5657
return {
57-
"gcc": "9",
58-
"clang": "9",
59-
"apple-clang": "9",
58+
"gcc": "11",
59+
"clang": "14",
60+
"apple-clang": "13",
6061
"msvc": "192",
61-
"visual_studio": "14",
62+
"visual_studio": "17",
6263
}
6364

6465
def export_sources(self):
6566
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
66-
copy(self, "*", path.join(self.recipe_folder, "python"), path.join(self.export_sources_folder, "python"))
67+
copy(self, "*", os.path.join(self.recipe_folder, "python"), os.path.join(self.export_sources_folder, "python"))
6768

6869
def requirements(self):
69-
self.requires("savitar/(latest)@ultimaker/testing")
70-
self.requires("cpython/3.10.4")
70+
for req in self.conan_data["requirements"]:
71+
self.requires(req)
72+
self.requires("cpython/3.12.2")
7173

7274
def validate(self):
7375
if self.settings.compiler.cppstd:
@@ -81,8 +83,8 @@ def validate(self):
8183
)
8284

8385
def build_requirements(self):
84-
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
85-
self.test_requires("sipbuildtool/[>=0.2.4]@ultimaker/stable")
86+
self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable")
87+
self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/stable")
8688

8789
def config_options(self):
8890
if self.settings.os == "Windows":
@@ -104,19 +106,13 @@ def generate(self):
104106
tc = CMakeToolchain(self)
105107
if is_msvc(self):
106108
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
107-
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
108-
tc.variables["Python_EXECUTABLE"] = self.deps_user_info["cpython"].python.replace("\\", "/")
109-
tc.variables["Python_USE_STATIC_LIBS"] = not self.options["cpython"].shared
110-
tc.variables["Python_ROOT_DIR"] = self.deps_cpp_info["cpython"].rootpath.replace("\\", "/")
111-
tc.variables["Python_FIND_FRAMEWORK"] = "NEVER"
112-
tc.variables["Python_FIND_REGISTRY"] = "NEVER"
113-
tc.variables["Python_FIND_IMPLEMENTATIONS"] = "CPython"
114-
tc.variables["Python_FIND_STRATEGY"] = "LOCATION"
115-
tc.variables["Python_SITEARCH"] = "site-packages"
116109
tc.generate()
117110

118111
vb = VirtualBuildEnv(self)
119-
vb.generate(scope="build")
112+
vb.generate()
113+
114+
vr = VirtualRunEnv(self)
115+
vr.generate(scope="build")
120116

121117
# Generate the Source code from SIP
122118
sip = self.python_requires["sipbuildtool"].module.SipBuildTool(self)
@@ -129,22 +125,21 @@ def layout(self):
129125
if self.settings.os in ["Linux", "FreeBSD", "Macos"]:
130126
self.cpp.package.system_libs = ["pthread"]
131127

128+
self.cpp.package.lib = ["pySavitar"]
129+
self.cpp.package.libdirs = ["lib"]
130+
131+
self.layouts.build.runenv_info.prepend_path("PYTHONPATH", ".")
132+
self.layouts.package.runenv_info.prepend_path("PYTHONPATH", "lib")
133+
132134
def build(self):
133135
cmake = CMake(self)
134136
cmake.configure()
135137
cmake.build()
136138

137139
def package(self):
138140
copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder)
139-
for ext in ("*.pyi", "*.so", "*.lib", "*.a", "*.pyd"):
140-
copy(self, ext, src = self.build_folder, dst = path.join(self.package_folder, "lib"), keep_path = False)
141-
142-
for ext in ("*.dll", "*.so", "*.dylib"):
143-
copy(self, ext, src = self.build_folder, dst = path.join(self.package_folder, "bin"), keep_path = False)
141+
for ext in ("*.pyi", "*.so", "*.lib", "*.a", "*.pyd", "*.dll", "*.dylib"):
142+
copy(self, ext, src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
144143

145144
def package_info(self):
146-
self.cpp_info.libdirs = [ os.path.join(self.package_folder, "lib")]
147-
if self.in_local_cache:
148-
self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "lib"))
149-
else:
150-
self.runenv_info.append_path("PYTHONPATH", self.build_folder)
145+
self.conf_info.define("user.pysavitar:pythonpath", os.path.join(self.package_folder, "lib"))

0 commit comments

Comments
 (0)