-
Notifications
You must be signed in to change notification settings - Fork 15
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
CURA-10951_gh_build_curapackage #29
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1e16d86
Update build and test environment in conanfile.py
jellespijker 96fb8a4
no longer a use for conandata
jellespijker e8ea70d
bump up minimum versions
jellespijker 64b2dd7
removed duplicate validate method
jellespijker 51227eb
removed redundant scm atrribute
jellespijker 87ab45a
make min_cppstd a property
jellespijker 44e0191
Use libnest2d from CURA-10951
jellespijker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import os | ||
|
||
from pathlib import Path | ||
from os import path | ||
|
||
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.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime | ||
from conan.tools.scm import Version | ||
|
||
required_conan_version = ">=1.50.0" | ||
|
||
required_conan_version = ">=1.56.0" | ||
|
||
|
||
class PyNest2DConan(ConanFile): | ||
|
@@ -22,8 +28,7 @@ class PyNest2DConan(ConanFile): | |
exports = "LICENSE*" | ||
generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" | ||
|
||
python_requires = "umbase/[>=0.1.7]@ultimaker/stable", "pyprojecttoolchain/[>=0.1.6]@ultimaker/stable", "sipbuildtool/[>=0.2.3]@ultimaker/stable" | ||
python_requires_extend = "umbase.UMBaseConanfile" | ||
python_requires = "pyprojecttoolchain/[>=0.1.7]@ultimaker/stable", "sipbuildtool/[>=0.2.4]@ultimaker/stable" | ||
|
||
options = { | ||
"shared": [True, False], | ||
|
@@ -37,43 +42,68 @@ class PyNest2DConan(ConanFile): | |
"py_build_requires": '"sip >=6, <7", "setuptools>=40.8.0", "wheel"', | ||
"py_build_backend": "sipbuild.api", | ||
} | ||
scm = { | ||
"type": "git", | ||
"subfolder": ".", | ||
"url": "auto", | ||
"revision": "auto" | ||
} | ||
|
||
def set_version(self): | ||
if self.version is None: | ||
self.version = self._umdefault_version() | ||
if not self.version: | ||
self.version = "5.3.0-alpha" | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "9", | ||
"clang": "9", | ||
"apple-clang": "9", | ||
"msvc": "192", | ||
"visual_studio": "14", | ||
} | ||
|
||
def export_sources(self): | ||
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) | ||
copy(self, "*", path.join(self.recipe_folder, "python"), path.join(self.export_sources_folder, "python")) | ||
|
||
def requirements(self): | ||
self.requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") # required for the CMake build modules | ||
self.requires("sipbuildtool/[>=0.2.3]@ultimaker/stable") # required for the CMake build modules | ||
for req in self._um_data()["requirements"]: | ||
self.requires(req) | ||
self.requires("nest2d/(latest)@ultimaker/cura_10951") | ||
self.requires("cpython/3.10.4") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
check_min_vs(self, 192) # TODO: remove in Conan 2.0 | ||
if not is_msvc(self): | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def build_requirements(self): | ||
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable") | ||
self.test_requires("sipbuildtool/[>=0.2.4]@ultimaker/stable") | ||
|
||
def config_options(self): | ||
if self.options.shared and self.settings.compiler == "Visual Studio": | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
self.options["nest2d"].shared = self.options.shared | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
self.options["cpython"].shared = True | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, 17) | ||
|
||
def generate(self): | ||
pp = self.python_requires["pyprojecttoolchain"].module.PyProjectToolchain(self) | ||
pp.blocks["tool_sip_project"].values["sip_files_dir"] = Path("python").as_posix() | ||
mkdir(self, self.build_path) # FIXME: bad, this should not be necessary | ||
pp.blocks["tool_sip_project"].values["sip_files_dir"] = str(Path("python").as_posix()) | ||
# mkdir(self, self.build_path) # FIXME: bad, this should not be necessary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then remove it? ;-) |
||
pp.blocks.remove("extra_sources") | ||
pp.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("\\", "/") | ||
|
@@ -84,6 +114,9 @@ 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() | ||
|
@@ -101,11 +134,12 @@ def build(self): | |
cmake.build() | ||
|
||
def package(self): | ||
for ext in (".pyi", ".so", ".lib", ".a", ".pyd"): | ||
copy(self, f"pynest2d{ext}", self.build_folder, self.package_path.joinpath("lib"), keep_path = False) | ||
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, f"pynest2d{ext}", self.build_folder, self.package_path.joinpath("bin"), 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) | ||
|
||
def package_info(self): | ||
self.cpp_info.libdirs = [ os.path.join(self.package_folder, "lib")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per your own writeup, which mentions 1.57 and smaller as divergent in behaviour from what we've done for the repo's now, shouldn't this be
>=1.58.0
instead?You wrote:
(Or maybe you're building this one still in the 'old' way, so we don't have to do that -- I'll look further.)