Skip to content

Commit d475bee

Browse files
committed
sleef dep by pkg-config first
1 parent 20746a5 commit d475bee

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

quaddtype/meson.build

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,29 @@ c = meson.get_compiler('c')
88
# Get the conda prefix
99
conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip()
1010

11-
# Add conda lib directory to library path
11+
message('Conda prefix: ' + conda_prefix)
12+
13+
# Add conda lib and include directories
1214
add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp'])
15+
add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp'])
1316

14-
sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib'])
15-
sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib'])
17+
# Try to find SLEEF using pkg-config first
18+
sleef_dep = dependency('sleef', required: false)
1619

17-
if not sleef_dep.found() or not sleefquad_dep.found()
18-
error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.')
20+
if not sleef_dep.found()
21+
# If pkg-config fails, try to find the library manually
22+
sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib'])
23+
sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib'])
24+
25+
if not sleef_dep.found() or not sleefquad_dep.found()
26+
error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.')
27+
endif
28+
else
29+
sleefquad_dep = sleef_dep
1930
endif
2031

32+
message('SLEEF library found: ' + sleef_dep.found().to_string())
33+
2134
incdir_numpy = run_command(py,
2235
[
2336
'-c',
@@ -30,6 +43,7 @@ includes = include_directories(
3043
[
3144
incdir_numpy,
3245
'quaddtype/src',
46+
conda_prefix + '/include',
3347
]
3448
)
3549

@@ -57,10 +71,11 @@ py.install_sources(
5771
)
5872

5973
py.extension_module('_quaddtype_main',
60-
srcs,
61-
c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'],
62-
dependencies: [sleef_dep, sleefquad_dep],
63-
install: true,
64-
subdir: 'quaddtype',
65-
include_directories: includes
74+
srcs,
75+
c_args: ['-g', '-O0'],
76+
link_args: ['-lsleef', '-lsleefquad'],
77+
dependencies: [sleef_dep, sleefquad_dep],
78+
install: true,
79+
subdir: 'quaddtype',
80+
include_directories: includes
6681
)

quaddtype/pyproject.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ source ~/.bash_profile
6969
conda config --set always_yes yes --set changeps1 no
7070
conda update -q conda
7171
conda info -a
72-
conda install -y -c conda-forge sleef
72+
conda install -y -c conda-forge sleef pkg-config
7373
if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then
7474
echo "sleef.h not found. Installation may have failed."
7575
exit 1
7676
fi
7777
ls -l $HOME/miniconda/include/sleef.h
78+
ls -l $HOME/miniconda/lib/libsleef*
7879
79-
# Adding a pkg-config file for SLEEF
80+
# Create a pkg-config file for SLEEF
8081
cat << EOF > $HOME/miniconda/lib/pkgconfig/sleef.pc
8182
prefix=$HOME/miniconda
8283
libdir=${prefix}/lib
@@ -85,14 +86,14 @@ includedir=${prefix}/include
8586
Name: SLEEF
8687
Description: SLEEF library
8788
Version: 3.5.1
88-
Libs: -L${libdir} -lsleef
89+
Libs: -L${libdir} -lsleef -lsleefquad
8990
Cflags: -I${includedir}
9091
EOF
9192
92-
93-
export PKG_CONFIG_PATH="$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH"
93+
export PKG_CONFIG_PATH="$HOME/minoconda/lib/pkgconfig:$PKG_CONFIG_PATH"
94+
pkg-config --libs --cflags sleef
9495
"""
95-
environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", PKG_CONFIG_PATH = "$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH"}
96+
environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", PKG_CONFIG_PATH = "$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH", CONDA_PREFIX = "$HOME/miniconda"}
9697
repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}"
9798

9899
# [tool.cibuildwheel.windows]

0 commit comments

Comments
 (0)