Skip to content

Bump iqtree2 from f04b6f2 to 18fa5a3 #113

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

Merged
merged 9 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
python-version: ${{ matrix.python-version }}
cache-key: libiqtree-${{ matrix.os }}-${{ needs.build-iqtree.outputs.iqtree2-sha }}

- name: Update Homebrew
if: matrix.os != 'ubuntu-latest'
run: |
brew update
brew install llvm

- name: Run Nox Testing
run: |
pip install nox
Expand Down
6 changes: 5 additions & 1 deletion build_tools/before_all_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ if [ "$GITHUB_ACTIONS" = "true" ]; then
brew update
fi

brew install eigen boost
brew install llvm eigen boost libomp make

export LDFLAGS="-L$(brew --prefix libomp)/lib"
export CPPFLAGS="-I$(brew --prefix libomp)/include"
export CXXFLAGS="-I$(brew --prefix libomp)/include"

bash build_tools/build_iqtree.sh
16 changes: 14 additions & 2 deletions build_tools/build_iqtree.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
cd iqtree2
rm -rf build
mkdir build && cd build
cmake -DIQTREE_FLAGS="single" -DBUILD_LIB=ON ..
make -j

if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Building for macOS."
echo $LDFLAGS
echo $CPPFLAGS
echo $CXXFLAGS
cmake -DBUILD_LIB=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
gmake -j
else
echo "Building for linux."
cmake -DBUILD_LIB=ON ..
make -j
fi

cd ../..
mv iqtree2/build/libiqtree2.a src/piqtree2/_libiqtree/
2 changes: 1 addition & 1 deletion iqtree2
Submodule iqtree2 updated 1 files
+3 −1 CMakeLists.txt
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ target-version = "py310"
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["ALL"]
ignore = ["EXE002", "FA100", "E501", "PLR0913", "PLR2004", "D"]
ignore = ["EXE002", "FA100", "E501", "PLR0913", "PLR2004", "S603", "S607", "D"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
Expand Down
46 changes: 44 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
"""setup for piqtree2."""

import os
import platform
import subprocess
from pathlib import Path

from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup

LIBRARY_DIR = "src/piqtree2/_libiqtree"


def get_brew_prefix(package: str) -> Path:
"""Get the prefix path for a specific Homebrew package."""
return Path(
subprocess.check_output(["brew", "--prefix", package]).strip().decode("utf-8"),
)


if platform.system() == "Darwin":
brew_prefix_llvm = get_brew_prefix("llvm")
brew_prefix_libomp = get_brew_prefix("libomp")

# Use Homebrew's clang/clang++
os.environ["CC"] = str(brew_prefix_llvm / "bin" / "clang")
os.environ["CXX"] = str(brew_prefix_llvm / "bin" / "clang++")

# Define OpenMP flags and libraries for macOS
openmp_flags = ["-Xpreprocessor", "-fopenmp"]
openmp_libs = ["omp"]

# Use the paths from Homebrew for libomp
openmp_include = str(brew_prefix_libomp / "include")
library_dirs = [
str(brew_prefix_libomp / "lib"),
str(brew_prefix_llvm / "lib"),
]
else:
openmp_flags = ["-fopenmp"]
openmp_libs = ["gomp"]
openmp_include = None
library_dirs = []

ext_modules = [
Pybind11Extension(
"_piqtree2",
["src/piqtree2/_libiqtree/_piqtree2.cpp"],
library_dirs=[LIBRARY_DIR],
libraries=["iqtree2", "z"],
library_dirs=[
*library_dirs,
LIBRARY_DIR,
],
libraries=["iqtree2", "z", *openmp_libs],
extra_compile_args=openmp_flags,
include_dirs=[openmp_include] if openmp_include else [],
),
]

Expand Down