From b1b2474b2d698ccc1cad0aacebe9c88c9b55e8a5 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 12 Feb 2024 11:42:36 +0100 Subject: [PATCH 01/15] Use Conan v2 Contributes to CURA-11622 --- .github/workflows/conan-package.yml | 224 ++++++------------ .../workflows/requirements-conan-package.txt | 2 - .github/workflows/requirements-runner.txt | 0 conandata.yml | 3 + conanfile.py | 79 +++--- test_package/conanfile.py | 13 +- 6 files changed, 119 insertions(+), 202 deletions(-) delete mode 100644 .github/workflows/requirements-conan-package.txt create mode 100644 .github/workflows/requirements-runner.txt create mode 100644 conandata.yml diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index e6c38a7..d03c284 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -1,157 +1,77 @@ ---- name: conan-package -# Exports the recipe, sources and binaries for Mac, Windows and Linux and upload these to the server such that these can -# be used downstream. -# -# It should run on pushes against main or CURA-* branches, but it will only create the binaries for main and release branches - on: - workflow_dispatch: - inputs: - # FIXME: Not yet implemented - conan_id: - required: false - type: string - description: 'The full conan package ID, e.g. "libnest2d/1.2.3@ultimaker/stable"' - create_latest_alias: - required: true - default: false - type: boolean - description: 'Create latest alias' - create_binaries_windows: - required: true - default: false - type: boolean - description: 'create binaries Windows' - create_binaries_linux: - required: true - default: false - type: boolean - description: 'create binaries Linux' - create_binaries_macos: - required: true - default: false - type: boolean - description: 'create binaries Macos' - - push: - paths: - - 'python/**' - - 'test_package/**' - - 'cmake/**' - - 'conanfile.py' - - 'conandata.yml' - - 'CMakeLists.txt' - - '.github/workflows/conan-package.yml' - - '.github/workflows/requirements*' - branches: - - main - - 'CURA-*' - - '[0-9]+.[0-9]+' - tags: - - '[0-9]+.[0-9]+.[0-9]*' + push: + paths: + - 'python/**' + - 'test_package/**' + - 'conanfile.py' + - 'conandata.yml' + - 'CMakeLists.txt' + - '.github/workflows/conan-package.yml' + - '.github/workflows/requirements*' + branches: + - main + - 'CURA-*' + - 'PP-*' + - 'NP-*' + - '[0-9].[0-9]*' + - '[0-9].[0-9][0-9]*' jobs: - conan-recipe-version: - uses: ultimaker/cura/.github/workflows/conan-recipe-version.yml@main - with: - project_name: pynest2d - - conan-package-export: - needs: [ conan-recipe-version ] - uses: ultimaker/cura/.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 }} - runs_on: 'ubuntu-20.04' - python_version: '3.11.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-windows: - if: ${{ (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_windows) }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main - with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 4 - build_info: false - runs_on: 'windows-2022' - python_version: '3.11.x' - conan_config_branch: '' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-macos: - if: ${{ (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_macos) }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main - with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 3 - build_info: false - runs_on: 'macos-11' - python_version: '3.11.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-linux-modern: - if: ${{ (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) }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main - with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 2 - build_info: false - runs_on: 'ubuntu-22.04' - python_version: '3.11.x' - conan_logging_level: 'info' - secrets: inherit - - conan-package-create-linux: - if: ${{ (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) }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/conan-package-create.yml@main - with: - project_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - build_id: 1 - build_info: false - runs_on: 'ubuntu-20.04' - python_version: '3.11.x' - conan_logging_level: 'info' - secrets: inherit - - notify-export: - if: ${{ always() }} - needs: [ conan-recipe-version, conan-package-export ] - - uses: ultimaker/cura/.github/workflows/notify.yml@main - with: - success: ${{ contains(join(needs.*.result, ','), 'success') }} - success_title: "New Conan recipe exported in ${{ github.repository }}" - success_body: "Exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - failure_title: "Failed to export Conan Export in ${{ github.repository }}" - failure_body: "Failed to exported ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - secrets: inherit - - notify-create: - 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)) }} - needs: [ conan-recipe-version, conan-package-create-macos, conan-package-create-windows, conan-package-create-linux, conan-package-create-linux-modern ] - - uses: ultimaker/cura/.github/workflows/notify.yml@main - with: - success: ${{ contains(join(needs.*.result, ','), 'success') }} - success_title: "New binaries created in ${{ github.repository }}" - success_body: "Created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - failure_title: "Failed to create binaries in ${{ github.repository }}" - failure_body: "Failed to created binaries for ${{ needs.conan-recipe-version.outputs.recipe_id_full }}" - secrets: inherit +# FIXME: Use main once merged + conan-recipe-version: + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@CURA-11622_conan_v2 + with: + project_name: pynest2d + +# FIXME: Use main once merged + conan-package-export: + needs: [ conan-recipe-version ] + uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@CURA-11622_conan_v2 + with: + recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} + recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} + recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} + recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} + recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} + secrets: inherit + +# FIXME: Use main once merged + conan-package-create-macos: + needs: [ conan-recipe-version, conan-package-export ] + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-macos.yml@CURA-11622_conan_v2 + with: + recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} + recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} + recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} + recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} + recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} + secrets: inherit + +# FIXME: Use main once merged + conan-package-create-windows: + needs: [ conan-recipe-version, conan-package-export ] + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-windows.yml@CURA-11622_conan_v2 + with: + recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} + recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} + recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} + recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} + recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} + secrets: inherit + +# FIXME: Use main once merged + conan-package-create-linux: + needs: [ conan-recipe-version, conan-package-export ] + if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} + uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-linux.yml@CURA-11622_conan_v2 + with: + recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} + recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} + recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} + recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} + recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/requirements-conan-package.txt b/.github/workflows/requirements-conan-package.txt deleted file mode 100644 index 790edfb..0000000 --- a/.github/workflows/requirements-conan-package.txt +++ /dev/null @@ -1,2 +0,0 @@ -conan -sip diff --git a/.github/workflows/requirements-runner.txt b/.github/workflows/requirements-runner.txt new file mode 100644 index 0000000..e69de29 diff --git a/conandata.yml b/conandata.yml new file mode 100644 index 0000000..f8e8c3e --- /dev/null +++ b/conandata.yml @@ -0,0 +1,3 @@ +version: "5.4.0-alpha.0" +requirements: + - "nest2d/[>=5.4.0]@ultimaker/cura_11622" diff --git a/conanfile.py b/conanfile.py index c276b42..cea4724 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,14 +6,12 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, mkdir +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.tools.files import copy, mkdir, update_conandata from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime -from conan.tools.scm import Version +from conan.tools.scm import Version, Git - -required_conan_version = ">=1.56.0" +required_conan_version = ">=1.58.0" class PyNest2DConan(ConanFile): @@ -24,11 +22,10 @@ class PyNest2DConan(ConanFile): description = "Python bindings for libnest2d" topics = ("conan", "cura", "prusaslicer", "nesting", "c++", "bin packaging", "python", "sip") settings = "os", "compiler", "build_type", "arch" - revision_mode = "scm" exports = "LICENSE*" - generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + package_type = "library" - python_requires = "pyprojecttoolchain/[>=0.1.7]@ultimaker/stable", "sipbuildtool/[>=0.2.4]@ultimaker/stable" + python_requires = "pyprojecttoolchain/[>=0.2.0]@ultimaker/cura_11622", "sipbuildtool/[>=0.3.0]@ultimaker/cura_11622" # FIXME: use stable after merge options = { "shared": [True, False], @@ -45,7 +42,11 @@ class PyNest2DConan(ConanFile): def set_version(self): if not self.version: - self.version = "5.4.0-alpha" + self.version = self.conan_data["version"] + + def export(self): + git = Git(self) + update_conandata(self, {"version": self.version, "commit": git.get_commit()}) @property def _min_cppstd(self): @@ -66,8 +67,8 @@ def export_sources(self): copy(self, "*", path.join(self.recipe_folder, "python"), path.join(self.export_sources_folder, "python")) def requirements(self): - self.requires("nest2d/5.3.0") - self.requires("cpython/3.10.4") + for req in self.conan_data["requirements"]: + self.requires(req) def validate(self): if self.settings.compiler.cppstd: @@ -81,8 +82,9 @@ def validate(self): ) def build_requirements(self): - self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") - self.test_requires("sipbuildtool/[>=0.2.4]@ultimaker/stable") + self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/cura_11622") # FIXME: use stable after merge + self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/cura_11622") # FIXME: use stable after merge + self.test_requires("cpython/3.12.2@ultimaker/cura_11622") # FIXME: use stable after merge def config_options(self): if self.settings.os == "Windows": @@ -94,18 +96,23 @@ def configure(self): self.options["cpython"].shared = True def generate(self): - pp = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) - pp.blocks["tool_sip_project"].values["sip_files_dir"] = str(Path("python").as_posix()) - pp.blocks.remove("extra_sources") - pp.generate() + tc = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) + tc.blocks["tool_sip_project"].values["sip_files_dir"] = str(Path("python").as_posix()) + tc.blocks.remove("extra_sources") + tc.generate() + + tc = CMakeDeps(self) + tc.generate() tc = CMakeToolchain(self) if is_msvc(self): tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) - tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" - tc.variables["Python_EXECUTABLE"] = self.deps_user_info["cpython"].python.replace("\\", "/") - tc.variables["Python_USE_STATIC_LIBS"] = not self.options["cpython"].shared - tc.variables["Python_ROOT_DIR"] = self.deps_cpp_info["cpython"].rootpath.replace("\\", "/") + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0148"] = "OLD" + cpython_conf = self.dependencies["cpython"].conf_info + tc.variables["Python_EXECUTABLE"] = cpython_conf.get("user.cpython:python").replace("\\", "/") + tc.variables["Python_ROOT_DIR"] = cpython_conf.get("user.cpython:python_root").replace("\\", "/") + cpython_options = self.dependencies["cpython"].options + tc.variables["Python_USE_STATIC_LIBS"] = not cpython_options.shared tc.variables["Python_FIND_FRAMEWORK"] = "NEVER" tc.variables["Python_FIND_REGISTRY"] = "NEVER" tc.variables["Python_FIND_IMPLEMENTATIONS"] = "CPython" @@ -113,13 +120,10 @@ def generate(self): tc.variables["Python_SITEARCH"] = "site-packages" tc.generate() - vb = VirtualBuildEnv(self) - vb.generate(scope="build") - # Generate the Source code from SIP - sip = self.python_requires["sipbuildtool"].module.SipBuildTool(self) - sip.configure() - sip.build() + tc = self.python_requires["sipbuildtool"].module.SipBuildTool(self) + tc.configure() + tc.build() def layout(self): cmake_layout(self) @@ -127,6 +131,12 @@ def layout(self): if self.settings.os in ["Linux", "FreeBSD", "Macos"]: self.cpp.package.system_libs = ["pthread"] + self.cpp.package.lib = ["pySavitar"] + self.cpp.package.libdirs = ["lib"] + + self.layouts.build.runenv_info.prepend_path("PYTHONPATH", ".") + self.layouts.package.runenv_info.prepend_path("PYTHONPATH", "lib") + def build(self): cmake = CMake(self) cmake.configure() @@ -134,15 +144,8 @@ def build(self): def package(self): copy(self, pattern="LICENSE*", dst="licenses", src=self.source_folder) - for ext in ("*.pyi", "*.so", "*.lib", "*.a", "*.pyd"): - copy(self, ext, src = self.build_folder, dst = path.join(self.package_folder, "lib"), keep_path = False) - - for ext in ("*.dll", "*.so", "*.dylib"): - copy(self, ext, src = self.build_folder, dst = path.join(self.package_folder, "bin"), keep_path = False) + for ext in ("*.pyi", "*.so", "*.lib", "*.a", "*.pyd", "*.dll", "*.dylib"): + copy(self, ext, src=self.build_folder, dst=path.join(self.package_folder, "lib"), keep_path=False) def package_info(self): - self.cpp_info.libdirs = [ os.path.join(self.package_folder, "lib")] - if self.in_local_cache: - self.runenv_info.append_path("PYTHONPATH", os.path.join(self.package_folder, "lib")) - else: - self.runenv_info.append_path("PYTHONPATH", self.build_folder) + self.conf_info.define("user.pysavitar:pythonpath", os.path.join(self.package_folder, "lib")) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 23992bd..5ec34b4 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,6 +1,4 @@ -import shutil from io import StringIO -from pathlib import Path from conan import ConanFile from conan.tools.env import VirtualRunEnv @@ -11,7 +9,6 @@ class PyNest2DTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "VirtualRunEnv" test_type = "explicit" def requirements(self): @@ -22,19 +19,15 @@ def generate(self): venv.generate() cpp_info = self.dependencies[self.tested_reference_str].cpp_info - copy(self, "*.pyd", src = cpp_info.libdirs[0], dst =self.build_folder) + copy(self, "*.pyd", src=cpp_info.libdirs[0], dst=self.build_folder) for dep in self.dependencies.values(): for bin_dir in dep.cpp_info.bindirs: - copy(self, "*.dll", src = bin_dir, dst = self.build_folder) - - def build(self): - if can_run(self): - shutil.copy(Path(self.source_folder).joinpath("test.py"), Path(self.build_folder).joinpath("test.py")) + copy(self, "*.dll", src=bin_dir, dst=self.build_folder) def test(self): if can_run(self): test_buf = StringIO() - self.run(f"python test.py", env = "conanrun", output = test_buf) + self.run(f"python test.py", env="conanrun", stdout=test_buf, scope="run") if "True" not in test_buf.getvalue(): raise ConanException("pynest2d wasn't build correctly!") From 3cd2724a86c620e3153bc552ac5b783397cc5779 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Mon, 16 Sep 2024 13:25:15 +0200 Subject: [PATCH 02/15] Use mainstream Python --- CMakeLists.txt | 4 ++-- conanfile.py | 15 ++------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69d03b7..3f1a88e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ +cmake_minimum_required(VERSION 3.20) cmake_policy(SET CMP0091 NEW) project(pynest2d) -cmake_minimum_required(VERSION 3.20) find_package(nest2d REQUIRED) -find_package(cpython REQUIRED) +find_package(Python REQUIRED) find_package(standardprojectsettings REQUIRED) find_package(sipbuildtool REQUIRED) diff --git a/conanfile.py b/conanfile.py index cea4724..9b824af 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,7 +11,7 @@ from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime from conan.tools.scm import Version, Git -required_conan_version = ">=1.58.0" +required_conan_version = ">=2.7.0" class PyNest2DConan(ConanFile): @@ -84,7 +84,7 @@ def validate(self): def build_requirements(self): self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/cura_11622") # FIXME: use stable after merge self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/cura_11622") # FIXME: use stable after merge - self.test_requires("cpython/3.12.2@ultimaker/cura_11622") # FIXME: use stable after merge + self.test_requires("cpython/3.12.2") def config_options(self): if self.settings.os == "Windows": @@ -107,17 +107,6 @@ def generate(self): tc = CMakeToolchain(self) if is_msvc(self): tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) - tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0148"] = "OLD" - cpython_conf = self.dependencies["cpython"].conf_info - tc.variables["Python_EXECUTABLE"] = cpython_conf.get("user.cpython:python").replace("\\", "/") - tc.variables["Python_ROOT_DIR"] = cpython_conf.get("user.cpython:python_root").replace("\\", "/") - cpython_options = self.dependencies["cpython"].options - tc.variables["Python_USE_STATIC_LIBS"] = not cpython_options.shared - tc.variables["Python_FIND_FRAMEWORK"] = "NEVER" - tc.variables["Python_FIND_REGISTRY"] = "NEVER" - tc.variables["Python_FIND_IMPLEMENTATIONS"] = "CPython" - tc.variables["Python_FIND_STRATEGY"] = "LOCATION" - tc.variables["Python_SITEARCH"] = "site-packages" tc.generate() # Generate the Source code from SIP From 778b27f4dcb1e6b96f75417c7213a70828a735c0 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 09:13:35 +0200 Subject: [PATCH 03/15] Use mainstream Python and update recipe --- CMakeLists.txt | 10 ++++++++-- conanfile.py | 22 ++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f1a88e..4a1585e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 3.20) -cmake_policy(SET CMP0091 NEW) project(pynest2d) +cmake_policy(SET CMP0091 NEW) -find_package(nest2d REQUIRED) find_package(Python REQUIRED) +find_package(nest2d REQUIRED) find_package(standardprojectsettings REQUIRED) find_package(sipbuildtool REQUIRED) @@ -15,3 +15,9 @@ target_link_libraries(pynest2d INTERFACE nest2d::nest2d cpython::cpython) add_sip_module(pynest2d) install_sip_module(pynest2d) +# Ensure the linking to libnest2d will not be discarded by GCC +target_link_libraries(sip_pynest2d PUBLIC + $<$:-Wl,--no-as-needed> + -lnest2d + $<$:-Wl,--as-needed> +) diff --git a/conanfile.py b/conanfile.py index 9b824af..923ce4a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -7,6 +7,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import copy, mkdir, update_conandata from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime from conan.tools.scm import Version, Git @@ -69,6 +70,7 @@ def export_sources(self): def requirements(self): for req in self.conan_data["requirements"]: self.requires(req) + self.requires("cpython/3.12.2") def validate(self): if self.settings.compiler.cppstd: @@ -84,7 +86,6 @@ def validate(self): def build_requirements(self): self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/cura_11622") # FIXME: use stable after merge self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/cura_11622") # FIXME: use stable after merge - self.test_requires("cpython/3.12.2") def config_options(self): if self.settings.os == "Windows": @@ -96,10 +97,13 @@ def configure(self): self.options["cpython"].shared = True def generate(self): - tc = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) - tc.blocks["tool_sip_project"].values["sip_files_dir"] = str(Path("python").as_posix()) - tc.blocks.remove("extra_sources") - tc.generate() + pp = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) + pp.blocks["tool_sip_project"].values["sip_files_dir"] = str(Path("python").as_posix()) + pp.blocks["tool_sip_bindings"].values["name"] = "pynest2d" + pp.blocks["tool_sip_metadata"].values["name"] = "pynest2d" + print(pp.blocks["tool_sip_bindings"].context()) + pp.blocks.remove("extra_sources") + pp.generate() tc = CMakeDeps(self) tc.generate() @@ -109,6 +113,12 @@ def generate(self): tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) tc.generate() + vb = VirtualBuildEnv(self) + vb.generate() + + vr = VirtualRunEnv(self) + vr.generate(scope="build") + # Generate the Source code from SIP tc = self.python_requires["sipbuildtool"].module.SipBuildTool(self) tc.configure() @@ -120,7 +130,7 @@ def layout(self): if self.settings.os in ["Linux", "FreeBSD", "Macos"]: self.cpp.package.system_libs = ["pthread"] - self.cpp.package.lib = ["pySavitar"] + self.cpp.package.lib = ["pynest2d"] self.cpp.package.libdirs = ["lib"] self.layouts.build.runenv_info.prepend_path("PYTHONPATH", ".") From fd8e229753cae5380a2650528273df9e491f6fc8 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 09:15:44 +0200 Subject: [PATCH 04/15] Use common workflow --- .github/workflows/conan-package.yml | 54 +---------------------- .github/workflows/requirements-runner.txt | 0 2 files changed, 2 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/requirements-runner.txt diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index d03c284..3672ae8 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -20,58 +20,8 @@ on: jobs: # FIXME: Use main once merged - conan-recipe-version: - uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-version.yml@CURA-11622_conan_v2 + conan-package: + uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@CURA-11622_conan_v2 with: project_name: pynest2d - -# FIXME: Use main once merged - conan-package-export: - needs: [ conan-recipe-version ] - uses: ultimaker/cura-workflows/.github/workflows/conan-recipe-export.yml@CURA-11622_conan_v2 - with: - recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} - recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} - recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - secrets: inherit - -# FIXME: Use main once merged - conan-package-create-macos: - needs: [ conan-recipe-version, conan-package-export ] - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} - uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-macos.yml@CURA-11622_conan_v2 - with: - recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} - recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} - recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} secrets: inherit - -# FIXME: Use main once merged - conan-package-create-windows: - needs: [ conan-recipe-version, conan-package-export ] - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} - uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-windows.yml@CURA-11622_conan_v2 - with: - recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} - recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} - recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - secrets: inherit - -# FIXME: Use main once merged - conan-package-create-linux: - needs: [ conan-recipe-version, conan-package-export ] - if: ${{ (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master' || needs.conan-recipe-version.outputs.is_release_branch == 'true')) }} - uses: ultimaker/cura-workflows/.github/workflows/conan-package-create-linux.yml@CURA-11622_conan_v2 - with: - recipe_id_name: ${{ needs.conan-recipe-version.outputs.project_name }} - recipe_id_version: ${{ needs.conan-recipe-version.outputs.recipe_semver_full }} - recipe_id_user: ${{ needs.conan-recipe-version.outputs.user }} - recipe_id_channel: ${{ needs.conan-recipe-version.outputs.channel }} - recipe_id_full: ${{ needs.conan-recipe-version.outputs.recipe_id_full }} - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/requirements-runner.txt b/.github/workflows/requirements-runner.txt deleted file mode 100644 index e69de29..0000000 From 475b4126954c3dfde1705fe9c49b23c17a471726 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 09:59:32 +0200 Subject: [PATCH 05/15] Use old linking method for non-gcc build --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1585e..9f4e01d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,6 @@ add_sip_module(pynest2d) install_sip_module(pynest2d) # Ensure the linking to libnest2d will not be discarded by GCC -target_link_libraries(sip_pynest2d PUBLIC - $<$:-Wl,--no-as-needed> - -lnest2d - $<$:-Wl,--as-needed> -) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_libraries(sip_pynest2d PUBLIC -Wl,--no-as-needed -lnest2d -Wl,--as-needed) +endif() From 93f75a9af27b53fc7f649c4fa970771d0aff75ce Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 10:14:46 +0200 Subject: [PATCH 06/15] Add global dependency to clipper and nlopt This should not be required, but it is for some reason. It seems that linking against libnest2d is somehow omitted, and pynest2d then misses required level 2 dependencies --- CMakeLists.txt | 5 ----- conanfile.py | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f4e01d..8324acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,3 @@ use_threads(pynest2d) target_link_libraries(pynest2d INTERFACE nest2d::nest2d cpython::cpython) add_sip_module(pynest2d) install_sip_module(pynest2d) - -# Ensure the linking to libnest2d will not be discarded by GCC -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(sip_pynest2d PUBLIC -Wl,--no-as-needed -lnest2d -Wl,--as-needed) -endif() diff --git a/conanfile.py b/conanfile.py index 923ce4a..5b704ea 100644 --- a/conanfile.py +++ b/conanfile.py @@ -71,6 +71,8 @@ def requirements(self): for req in self.conan_data["requirements"]: self.requires(req) self.requires("cpython/3.12.2") + self.requires("clipper/6.4.2") + self.requires("nlopt/2.7.1") def validate(self): if self.settings.compiler.cppstd: From d3a6927e5f6ee7e4f7b3efaa1477ccc8b79b4792 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 10:28:21 +0200 Subject: [PATCH 07/15] Useless change to trigger build --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 5b704ea..9975e13 100644 --- a/conanfile.py +++ b/conanfile.py @@ -71,8 +71,8 @@ def requirements(self): for req in self.conan_data["requirements"]: self.requires(req) self.requires("cpython/3.12.2") - self.requires("clipper/6.4.2") self.requires("nlopt/2.7.1") + self.requires("clipper/6.4.2") def validate(self): if self.settings.compiler.cppstd: From 5f2ad9cb7ac1f98ea1beebfcb5814bf40033c341 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Sep 2024 16:10:40 +0200 Subject: [PATCH 08/15] Use custom clipper recipe --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 9975e13..bb12639 100644 --- a/conanfile.py +++ b/conanfile.py @@ -72,7 +72,7 @@ def requirements(self): self.requires(req) self.requires("cpython/3.12.2") self.requires("nlopt/2.7.1") - self.requires("clipper/6.4.2") + self.requires("clipper/6.4.2@ultimaker/cura_11622") # FIXME: use main after merge def validate(self): if self.settings.compiler.cppstd: From 852b4a83afebf76fd595a4f1fa3a6da848a2987c Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 24 Sep 2024 11:38:07 +0200 Subject: [PATCH 09/15] Remove indirect dependencies --- conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index bb12639..a20ace8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -72,7 +72,6 @@ def requirements(self): self.requires(req) self.requires("cpython/3.12.2") self.requires("nlopt/2.7.1") - self.requires("clipper/6.4.2@ultimaker/cura_11622") # FIXME: use main after merge def validate(self): if self.settings.compiler.cppstd: @@ -96,7 +95,6 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - self.options["cpython"].shared = True def generate(self): pp = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) From 84735d1a6347e17201ef2e044b6837b2beb89b09 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 24 Sep 2024 12:37:52 +0200 Subject: [PATCH 10/15] Restore required clipper depdendancy --- conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conanfile.py b/conanfile.py index a20ace8..a681869 100644 --- a/conanfile.py +++ b/conanfile.py @@ -73,6 +73,9 @@ def requirements(self): self.requires("cpython/3.12.2") self.requires("nlopt/2.7.1") + # Although not a direct dependency, clipper is for some reason required at link-time + self.requires("clipper/6.4.2@ultimaker/cura_11622") # FIXME: use main after merge + def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) From 69f049196006de00101f89481ace6a6b2688ad0c Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 25 Sep 2024 15:28:28 +0200 Subject: [PATCH 11/15] Update variable name --- .github/workflows/conan-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index 3672ae8..f80da08 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -23,5 +23,5 @@ jobs: conan-package: uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@CURA-11622_conan_v2 with: - project_name: pynest2d + package_name: pynest2d secrets: inherit From 0fddd80f21f79d11934a8faee4400cae482b5a80 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 26 Nov 2024 11:47:22 +0100 Subject: [PATCH 12/15] Use simplified package creation workflow --- .github/workflows/conan-package.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index f80da08..729a1a7 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -22,6 +22,4 @@ jobs: # FIXME: Use main once merged conan-package: uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@CURA-11622_conan_v2 - with: - package_name: pynest2d secrets: inherit From 8c3785b4c63e686f09073f2544cc02a097a2a1c8 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Fri, 29 Nov 2024 09:04:02 +0100 Subject: [PATCH 13/15] Update python version --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index a681869..7f9d513 100644 --- a/conanfile.py +++ b/conanfile.py @@ -70,7 +70,7 @@ def export_sources(self): def requirements(self): for req in self.conan_data["requirements"]: self.requires(req) - self.requires("cpython/3.12.2") + self.requires("cpython/3.12.7") self.requires("nlopt/2.7.1") # Although not a direct dependency, clipper is for some reason required at link-time From c74b9bc962f3017c6ce2f336298c371d99bf34bc Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Mon, 2 Dec 2024 10:33:14 +0100 Subject: [PATCH 14/15] Revert CPython to 3.12.2 Unfortunately, 3.12.7 doesn't build on Windows yet --- conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 7f9d513..a681869 100644 --- a/conanfile.py +++ b/conanfile.py @@ -70,7 +70,7 @@ def export_sources(self): def requirements(self): for req in self.conan_data["requirements"]: self.requires(req) - self.requires("cpython/3.12.7") + self.requires("cpython/3.12.2") self.requires("nlopt/2.7.1") # Although not a direct dependency, clipper is for some reason required at link-time From b1a3a770f103c5d8c5d6efba58ad2abcf61d96f6 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 4 Dec 2024 11:47:39 +0100 Subject: [PATCH 15/15] Prepare for merge CURA-11622 --- .github/workflows/conan-package.yml | 3 +-- conandata.yml | 2 +- conanfile.py | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/conan-package.yml b/.github/workflows/conan-package.yml index 729a1a7..50ab5a5 100644 --- a/.github/workflows/conan-package.yml +++ b/.github/workflows/conan-package.yml @@ -19,7 +19,6 @@ on: - '[0-9].[0-9][0-9]*' jobs: -# FIXME: Use main once merged conan-package: - uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@CURA-11622_conan_v2 + uses: ultimaker/cura-workflows/.github/workflows/conan-package.yml@main secrets: inherit diff --git a/conandata.yml b/conandata.yml index f8e8c3e..f0170ec 100644 --- a/conandata.yml +++ b/conandata.yml @@ -1,3 +1,3 @@ version: "5.4.0-alpha.0" requirements: - - "nest2d/[>=5.4.0]@ultimaker/cura_11622" + - "nest2d/[>=5.4.0]@ultimaker/stable" diff --git a/conanfile.py b/conanfile.py index a681869..e247948 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,7 +26,7 @@ class PyNest2DConan(ConanFile): exports = "LICENSE*" package_type = "library" - python_requires = "pyprojecttoolchain/[>=0.2.0]@ultimaker/cura_11622", "sipbuildtool/[>=0.3.0]@ultimaker/cura_11622" # FIXME: use stable after merge + python_requires = "pyprojecttoolchain/[>=0.2.0]@ultimaker/stable", "sipbuildtool/[>=0.3.0]@ultimaker/stable" options = { "shared": [True, False], @@ -74,7 +74,7 @@ def requirements(self): self.requires("nlopt/2.7.1") # Although not a direct dependency, clipper is for some reason required at link-time - self.requires("clipper/6.4.2@ultimaker/cura_11622") # FIXME: use main after merge + self.requires("clipper/6.4.2@ultimaker/stable") def validate(self): if self.settings.compiler.cppstd: @@ -88,8 +88,8 @@ def validate(self): ) def build_requirements(self): - self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/cura_11622") # FIXME: use stable after merge - self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/cura_11622") # FIXME: use stable after merge + self.test_requires("standardprojectsettings/[>=0.2.0]@ultimaker/stable") + self.test_requires("sipbuildtool/[>=0.3.0]@ultimaker/stable") def config_options(self): if self.settings.os == "Windows":