Skip to content

Commit 7962f5d

Browse files
committed
simplifying process and using pkg-config
1 parent 6fb2df3 commit 7962f5d

File tree

2 files changed

+24
-62
lines changed

2 files changed

+24
-62
lines changed

quaddtype/meson.build

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@ 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+
# Add conda lib and include directories
1212
add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp'])
13-
add_project_link_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp'])
13+
add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp'])
1414

15-
sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib'])
16-
sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib'])
15+
# Use pkg-config to find SLEEF
16+
pkg = import('pkgconfig')
17+
sleef_dep = pkg.dependency('sleef', required: false)
1718

18-
if not sleef_dep.found() or not sleefquad_dep.found()
19-
error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.')
19+
if not sleef_dep.found()
20+
# Fallback to manual library detection
21+
sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib'])
22+
sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib'])
23+
24+
if not sleef_dep.found() or not sleefquad_dep.found()
25+
error('SLEEF library not found. Please ensure it is installed in your conda environment.')
26+
endif
27+
else
28+
sleefquad_dep = sleef_dep
2029
endif
2130

2231
incdir_numpy = run_command(py,
23-
[
24-
'-c',
25-
'import numpy; import os; print(os.path.relpath(numpy.get_include()))'
26-
],
32+
['-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))'],
2733
check: true
2834
).stdout().strip()
2935

3036
includes = include_directories(
31-
[
32-
incdir_numpy,
33-
'quaddtype/src',
34-
]
37+
[incdir_numpy, 'quaddtype/src']
3538
)
3639

3740
srcs = [
@@ -50,18 +53,15 @@ srcs = [
5053
]
5154

5255
py.install_sources(
53-
[
54-
'quaddtype/__init__.py',
55-
],
56+
['quaddtype/__init__.py'],
5657
subdir: 'quaddtype',
5758
pure: false
5859
)
5960

6061
py.extension_module('_quaddtype_main',
61-
srcs,
62-
c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'],
63-
dependencies: [sleef_dep, sleefquad_dep],
64-
install: true,
65-
subdir: 'quaddtype',
66-
include_directories: includes
62+
srcs,
63+
dependencies: [sleef_dep, sleefquad_dep],
64+
install: true,
65+
subdir: 'quaddtype',
66+
include_directories: includes
6767
)

quaddtype/pyproject.toml

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ conda config --set always_yes yes --set changeps1 no
4949
conda update -q conda
5050
conda info -a
5151
conda install -y -c conda-forge sleef
52-
if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then
53-
echo "sleef.h not found. Installation may have failed."
54-
exit 1
55-
fi
56-
ls -l $HOME/miniconda/include/sleef.h
5752
"""
5853
environment = { LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_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" }
5954
repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}"
@@ -70,39 +65,6 @@ conda config --set always_yes yes --set changeps1 no
7065
conda update -q conda
7166
conda info -a
7267
conda install -y -c conda-forge sleef pkg-config
73-
if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then
74-
echo "sleef.h not found. Installation may have failed."
75-
exit 1
76-
fi
77-
ls -l $HOME/miniconda/include/sleef.h
78-
ls -l $HOME/miniconda/lib/libsleef*
79-
80-
# Create a pkg-config file for SLEEF
81-
cat << EOF > $HOME/miniconda/lib/pkgconfig/sleef.pc
82-
prefix=$HOME/miniconda
83-
libdir=${prefix}/lib
84-
includedir=${prefix}/include
85-
86-
Name: SLEEF
87-
Description: SLEEF library
88-
Version: 3.5.1
89-
Libs: -L${libdir} -lsleef -lsleefquad
90-
Cflags: -I${includedir}
91-
EOF
92-
93-
export PKG_CONFIG_PATH="$HOME/minoconda/lib/pkgconfig:$PKG_CONFIG_PATH"
94-
pkg-config --libs --cflags sleef
9568
"""
9669
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"}
97-
repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}"
98-
99-
# [tool.cibuildwheel.windows]
100-
# before-all = [
101-
# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"",
102-
# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3",
103-
# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat",
104-
# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef"
105-
# ]
106-
# before-build = "pip install delvewheel"
107-
# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'"
108-
# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" }
70+
repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}"

0 commit comments

Comments
 (0)