Skip to content
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

Bump to 2024_03_4 #105

Merged
merged 15 commits into from
Aug 6, 2024
Merged
24 changes: 23 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ jobs:

# Linux 64 bit ARM: aarch64 (on Circle CI)

# MacOS 64 bit Intel: x86_64
- os: macos-14
bitness: 64
python: 38
platform_id: macosx_arm64
- os: macos-14
bitness: 64
python: 39
platform_id: macosx_arm64
- os: macos-14
bitness: 64
python: 310
platform_id: macosx_arm64
- os: macos-14
bitness: 64
python: 311
platform_id: macosx_arm64
- os: macos-14
bitness: 64
python: 312
platform_id: macosx_arm64

# MacOS 64 bit Intel: x86_64
- os: macos-12
bitness: 64
Expand Down Expand Up @@ -109,7 +131,7 @@ jobs:

- name: Export GitHub Actions cache environment variables for vcpkg
if: ${{ runner.os == 'Windows' }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ environment-pass = ["CIBW_BUILD"]
before-all = ["brew install gnu-sed eigen cairo freetype"]

repair-wheel-command = [
"export DYLD_LIBRARY_PATH='/usr/local/lib:/usr/lib:/Users/admin/lib'",
"export DYLD_LIBRARY_PATH='/usr/local/lib:/usr/lib:/Users/admin/lib:/Users/runner/work/lib'",
"source conan/conanrun.sh",
"delocate-listdeps {wheel}",
"delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}",
Expand Down
64 changes: 46 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from setuptools.command.build_ext import build_ext as build_ext_orig

# RDKit version to build (tag from github repository)
rdkit_tag = "Release_2024_03_3"
rdkit_tag = "Release_2024_03_4"

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -103,6 +103,10 @@ def conan_install(self, boost_version, conan_toolchain_path):
if "linux" in sys.platform:
cmd += ["--build=b2", "-pr:b", "default"]

if "cp38-macosx_arm64" in os.environ["CIBW_BUILD"]:
# only in this case, conan detects x68_64 instead of armv8
cmd += ["-s", "arch=armv8", "-s", "arch_build=armv8"]

check_call(cmd)

def build_rdkit(self, ext):
Expand Down Expand Up @@ -145,6 +149,24 @@ def build_rdkit(self, ext):
# Start build process
os.chdir(str("rdkit"))

# Fix a bug in conan or rdkit: target name for numpy is boost::numpy{pyversion} with small 'b'
# and not Boost::numpy{pyversion}
# Line 345 in 2024_03_04 in CMakeLists.txt
# target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "Boost::numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
import fileinput

def replace_all(file, search_exp, replace_exp):
with fileinput.input(file, inplace=True) as f:
for line in f:
if search_exp in line:
line = line.replace(search_exp, replace_exp)
print(line, end='')

replace_all(
"CMakeLists.txt",
'target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "Boost::numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")',
'target_link_libraries(rdkit_py_base INTERFACE Boost::${Boost_Python_Lib} "boost::numpy${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")'
)

# Define CMake options
options = [
Expand Down Expand Up @@ -217,8 +239,11 @@ def to_win_path(pt: Path):
if "macosx_arm64" in os.environ["CIBW_BUILD"]:
options += [
"-DRDK_OPTIMIZE_POPCNT=OFF",
# Otherwise, cmake tries to link the system freetype
"-DFREETYPE_LIBRARY=/opt/homebrew/lib/libfreetype.dylib",
"-DFREETYPE_INCLUDE_DIRS=/opt/homebrew/include",
]

if "linux" in sys.platform:
# Use ninja for linux builds
cmds = [
Expand Down Expand Up @@ -283,23 +308,25 @@ def to_win_path(pt: Path):
[copy_file(i, str(to_path)) for i in boost_lib_path.rglob("*.lib")]
[copy_file(i, str(to_path)) for i in boost_lib_path_bin_windows_only.rglob("*.dll")]


variables["PATH"] = os.environ["PATH"] + os.pathsep + str(to_path)

# VCPKG libs
variables["PATH"] = os.environ["PATH"] + os.pathsep + str(vcpkg_lib)



elif "darwin" in sys.platform:
# on Github Actions
to_path = Path('/usr/local/lib')
if "macosx_arm64" in os.environ["CIBW_BUILD"]:
elif "darwin" in sys.platform:
# Github actions
to_path = Path("/Users/runner/work/lib")
if 'CIRRUS_CI' in os.environ:
# on cirrus CI
to_path = Path('/Users/admin/lib')
to_path.mkdir(parents=True, exist_ok=True)
variables["DYLD_LIBRARY_PATH"] = str(to_path)
to_path = Path("/Users/admin/lib")

# Make sure path exists?
to_path.mkdir(parents=True, exist_ok=True)

# Add path to DYLD_LIBRARY_PATH for generating stubs
variables["DYLD_LIBRARY_PATH"] = str(to_path)

# copy all boost and rdkit libs to one path
[copy_file(i, str(to_path)) for i in rdkit_lib_path.rglob("*dylib")]
[copy_file(i, str(to_path)) for i in boost_lib_path.rglob("*dylib")]

Expand Down Expand Up @@ -329,8 +356,11 @@ def to_win_path(pt: Path):
]

# Print the stubs error file to rdkit-stubs/gen_rdkit_stubs.err
stubs_error_file = build_path / 'rdkit' / "build" /"rdkit-stubs" / "gen_rdkit_stubs.err"
with open(stubs_error_file, 'r') as fin: print(fin.read(), file=sys.stderr)
stubs_error_file = (
build_path / "rdkit" / "build" / "rdkit-stubs" / "gen_rdkit_stubs.err"
)
with open(stubs_error_file, "r") as fin:
print(fin.read(), file=sys.stderr)

os.chdir(str(cwd))

Expand Down Expand Up @@ -359,13 +389,11 @@ def to_win_path(pt: Path):
wheel_path = Path(self.get_ext_fullpath(ext.name)).absolute().parent
wheel_path.mkdir(exist_ok=True)



# Copy RDMKit files to .../rdkit directory
def _logpath(path, names):
ignore_patterns
print(f"In directory {path} copy files: {names}", file=sys.stderr)
return ignore_patterns('*.pyc')(path, names)
return ignore_patterns("*.pyc")(path, names)

# Copy the RDKit stubs files to the rdkit-stubs wheels path
copytree(dir_rdkit_stubs, wheel_path / "rdkit-stubs", ignore=_logpath)
Expand Down Expand Up @@ -408,7 +436,7 @@ def _logpath(path, names):
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=[
"numpy < 2.0",
"numpy",
"Pillow",
],
ext_modules=[
Expand Down
Loading