Skip to content

Commit de46561

Browse files
authored
Replace conan 1 with conan 2 (#137) [skip ci]
* Replace conan 1 with conan 2 * Fix path issue on win builds * oops * Fix path on windows * Ooop. It's Monday morning
1 parent 6f6c943 commit de46561

File tree

5 files changed

+100
-56
lines changed

5 files changed

+100
-56
lines changed

conan_boost_mod/all/conandata.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
sources:
2+
"1.88.0":
3+
url:
4+
- "https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.bz2"
5+
- "https://sourceforge.net/projects/boost/files/boost/1.88.0/boost_1_88_0.tar.bz2"
6+
sha256: "46d9d2c06637b219270877c9e16155cbd015b6dc84349af064c088e9b5b12f7b"
7+
"1.87.0":
8+
url:
9+
- "https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.bz2"
10+
- "https://sourceforge.net/projects/boost/files/boost/1.87.0/boost_1_87_0.tar.bz2"
11+
sha256: "af57be25cb4c4f4b413ed692fe378affb4352ea50fbe294a11ef548f4d527d89"
12+
"1.86.0":
13+
url:
14+
- "https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2"
15+
- "https://sourceforge.net/projects/boost/files/boost/1.86.0/boost_1_86_0.tar.bz2"
16+
sha256: "1bed88e40401b2cb7a1f76d4bab499e352fa4d0c5f31c0dbae64e24d34d7513b"
217
"1.85.0":
318
url:
4-
- "https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.tar.bz2"
19+
- "https://archives.boost.io/release/1.85.0/source/boost_1_85_0.tar.bz2"
520
- "https://sourceforge.net/projects/boost/files/boost/1.85.0/boost_1_85_0.tar.bz2"
621
sha256: "7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617"
722
"1.84.0":

conan_boost_mod/all/conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import sys
2222
import yaml
2323

24-
required_conan_version = ">=1.53.0"
24+
required_conan_version = ">=2.0.0"
2525

2626
# When adding (or removing) an option, also add this option to the list in
2727
# `rebuild-dependencies.yml` and re-run that script.

conanfile.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import os
2+
import sys
3+
from conan import ConanFile
4+
from conan.tools.cmake import CMakeDeps, CMakeToolchain
5+
from conan.tools.env import VirtualRunEnv
6+
from conan.tools.files import copy
7+
from pathlib import Path
8+
9+
10+
11+
class RDKitConan(ConanFile):
12+
settings = "os", "compiler", "build_type", "arch"
13+
14+
def configure(self):
15+
# Configure boost options
16+
self.options["boost/*"].shared = True
17+
self.options["boost/*"].without_python = False
18+
19+
# We always need a posix path with forward slashes
20+
# Because the workflows run on Windows runners with the Git Bash shell,
21+
# as_posix returns "/" paths
22+
self.options["boost/*"].python_executable = Path(sys.executable).as_posix()
23+
24+
# Platform-specific configurations
25+
if self.settings.os == "Macos" and self.settings.arch == "armv8":
26+
# stacktrace does not work on macOS arm64 for some reason
27+
self.options["boost/*"].without_stacktrace = True
28+
else:
29+
self.options["boost/*"].without_stacktrace = False
30+
31+
# Configure Python library linking for wheel building
32+
if self.settings.os == "Windows":
33+
self.options["boost/*"].without_python_lib = False
34+
else:
35+
self.options["boost/*"].without_python_lib = True
36+
37+
def requirements(self):
38+
# Main boost requirement - use modified version
39+
self.requires("boost/1.85.0@chris/mod_boost")
40+
# self.requires("boost/1.85.0")
41+
42+
# Platform-specific requirements
43+
if self.settings.os == "Macos" and os.environ.get("CIBW_BUILD", "").startswith("cp"):
44+
# macOS libraries to meet development target
45+
self.requires("pixman/0.43.4")
46+
self.requires("cairo/1.18.0")
47+
self.requires("libpng/1.6.43")
48+
self.requires("fontconfig/2.15.0")
49+
self.requires("freetype/2.13.2")
50+
51+
def build_requirements(self):
52+
pass
53+
54+
def generate(self):
55+
# Generate CMake dependencies
56+
deps = CMakeDeps(self)
57+
deps.generate()
58+
59+
# Generate CMake toolchain
60+
tc = CMakeToolchain(self)
61+
tc.generate()
62+
63+
# Generate virtual run environment
64+
env = VirtualRunEnv(self)
65+
env.generate()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ requires = [
44
"wheel",
55
"cmake == 3.31.1",
66
"numpy",
7-
"conan == 1.66.0",
7+
"conan >= 2.0.0",
88
"ninja",
99
"pybind11-stubgen",
1010
"Pillow", # required for building the stubs

setup.py

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def get_ext_filename(self, ext_name):
3737
def conan_install(self, boost_version, conan_toolchain_path):
3838
"""Run the Conan"""
3939

40+
# Create default profile if it doesn't exist (Conan 2 requirement)
41+
check_call(["conan", "profile", "detect", "--force"])
42+
4043
# This modified conanfile.py for boost does not link libpython*.so
4144
# When building a platform wheel, we don't want to link libpython*.so.
4245
mod_conan_path = "conan_boost_mod"
@@ -47,72 +50,32 @@ def conan_install(self, boost_version, conan_toolchain_path):
4750
"conan",
4851
"export",
4952
f"{mod_conan_path}/all/",
50-
f"{boost_version}@chris/mod_boost",
53+
f"--name=boost",
54+
f"--version={boost_version}",
55+
f"--user=chris",
56+
f"--channel=mod_boost",
5157
]
5258
)
5359

54-
without_python_lib = "boost:without_python_lib=False"
55-
boost_version_string = f"boost/{boost_version}@chris/mod_boost"
56-
without_stacktrace = "False"
57-
58-
if sys.platform != "win32":
59-
# if no windows builds, compile boost without python lib.a/.so/.dylib
60-
without_python_lib = "boost:without_python_lib=True"
61-
62-
if "macosx_arm64" in os.environ["CIBW_BUILD"]:
63-
# does not work on macos arm64 for some reason
64-
without_stacktrace = "True"
65-
66-
macos_libs = ""
67-
if "macosx" in os.environ["CIBW_BUILD"]:
68-
## install these libraries to meet the development target
69-
macos_libs = """
70-
pixman/0.43.4
71-
cairo/1.18.0
72-
libpng/1.6.43
73-
fontconfig/2.15.0
74-
freetype/2.13.2
75-
"""
76-
77-
conanfile = f"""\
78-
[requires]
79-
{boost_version_string}
80-
{macos_libs}
81-
82-
[generators]
83-
deploy
84-
CMakeDeps
85-
CMakeToolchain
86-
VirtualRunEnv
87-
88-
[options]
89-
boost:shared=True
90-
boost:without_python=False
91-
{without_python_lib}
92-
boost:python_executable={sys.executable}
93-
boost:without_stacktrace={without_stacktrace}
94-
"""
95-
# boost:debug_level=1
96-
97-
Path("conanfile.txt").write_text(dedent(conanfile))
98-
99-
# run conan install
60+
# run conan install using conanfile.py
10061
cmd = [
10162
"conan",
10263
"install",
103-
"conanfile.txt",
64+
".", # Use current directory with conanfile.py
10465
# build all missing
10566
"--build=missing",
106-
"-if",
67+
"--output-folder",
10768
f"{conan_toolchain_path}",
69+
# copies files to output folder
70+
"--deployer=direct_deploy",
10871
]
10972

11073
if sys.platform == "win32":
111-
cmd += ["-pr:b", "default"]
74+
cmd += ["--profile:build", "default"]
11275

11376
# but force build b2 on linux
11477
if "linux" in sys.platform:
115-
cmd += ["--build=b2", "-pr:b", "default"]
78+
cmd += ["--build=b2/*", "--profile:build", "default"]
11679

11780
check_call(cmd)
11881

@@ -355,8 +318,8 @@ def to_win_path(pt: Path):
355318
# While repairing the wheels, the built libs need to be copied to the platform wheels
356319
# Also, the libs needs to be accessible for building the stubs
357320
rdkit_lib_path = rdkit_install_path / "lib"
358-
boost_lib_path = conan_toolchain_path / "boost" / "lib"
359-
boost_lib_path_bin_windows_only = conan_toolchain_path / "boost" / "bin"
321+
boost_lib_path = conan_toolchain_path / "direct_deploy" / "boost" / "lib"
322+
boost_lib_path_bin_windows_only = conan_toolchain_path / "direct_deploy" / "boost" / "bin"
360323

361324
cmds = []
362325
if "linux" in sys.platform:
@@ -407,6 +370,7 @@ def to_win_path(pt: Path):
407370
[copy_file(i, str(to_path)) for i in boost_lib_path.rglob("*dylib")]
408371

409372
# Build the RDKit stubs
373+
410374
cmds += [
411375
f"cmake --build build --config Release --target stubs -v",
412376
]

0 commit comments

Comments
 (0)