Skip to content

Commit

Permalink
Use xsimd and eigen from conda-forge for packages
Browse files Browse the repository at this point in the history
Also update the conda build compiler to be C++

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Nov 21, 2023
1 parent f7632fe commit daafa05
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
5 changes: 4 additions & 1 deletion conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
requirements:
build:
# This is so that we can build cross-platform for osx-arm64
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- python {{ python }} # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- numpy >=1.20 # [build_platform != target_platform]
Expand All @@ -28,6 +28,9 @@ requirements:
- setuptools_scm
# Numba is only here to make sure we use a version of numpy that is compatible
- numba
- pybind11
- xsimd
- eigen

run:
- appdirs
Expand Down
28 changes: 21 additions & 7 deletions scripts/install/install_build_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def download_xsimd(path):
return str(target_path)


def download_eigen(path):
def download_eigen3(path):
url = 'https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz' # noqa
md5sum = '4c527a9171d71a72a9d4186e65bea559'
out_dir_name = 'eigen-3.4.0'
Expand Down Expand Up @@ -87,14 +87,28 @@ def download_pybind11(path):
return str(target_path)


INSTALL_FUNCTIONS = {
'eigen3': download_eigen3,
'xsimd': download_xsimd,
'pybind11': download_pybind11,
}


def install(library, destination):
if library not in INSTALL_FUNCTIONS:
raise NotImplementedError(library)

return INSTALL_FUNCTIONS[library](destination)


if __name__ == '__main__':
import sys

if len(sys.argv) < 2:
sys.exit('<script> <destination')
if len(sys.argv) < 3:
sys.exit('<script> <library> <destination>')

destination = sys.argv[1]
library = sys.argv[1]
destination = sys.argv[2]

# Call the functions to download and place the libraries
download_eigen(destination)
download_xsimd(destination)
print(f'Installing "{library}" to "{destination}"')
install(library, destination)
15 changes: 10 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pathlib import Path
from setuptools import setup, find_packages, Extension
import subprocess
import sysconfig
import sys

import numpy
Expand Down Expand Up @@ -69,7 +68,7 @@ def get_include_path(library_name):
if conda_include_dir:
full_path = Path(conda_include_dir) / 'include' / library_name
if full_path.exists():
return str(full_path)
return full_path

build_include_dir = Path(__file__).parent / 'build/include'
full_path = build_include_dir / library_name
Expand All @@ -80,7 +79,14 @@ def get_include_path(library_name):
scripts_path = Path(__file__).parent / 'scripts'
install_script = scripts_path / 'install/install_build_dependencies.py'

subprocess.run([sys.executable, install_script, str(build_include_dir)])
args = [
sys.executable,
install_script,
library_name,
build_include_dir,
]

result = subprocess.run(args, check=True)

# It should exist now
return full_path
Expand All @@ -96,15 +102,14 @@ def get_cpp_extensions():

# Define include directories
include_dirs = [
sysconfig.get_path('include'),
get_include_path('eigen3'),
get_include_path('xsimd'),
pybind11.get_include(),
numpy.get_include(),
]

inverse_distortion_ext = Extension(name='hexrd.extensions.inverse_distortion',
sources=[src_files[0]],
sources=src_files,
extra_compile_args=extra_compile_args,
include_dirs=include_dirs,
language='c++')
Expand Down

0 comments on commit daafa05

Please sign in to comment.