Skip to content

Commit 724ea03

Browse files
authored
Merge pull request #9 from SwayamInSync/sdist
2 parents 6124e14 + 77f1a8e commit 724ea03

File tree

8 files changed

+101
-110
lines changed

8 files changed

+101
-110
lines changed

.github/workflows/build_wheels.yml

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,8 @@ jobs:
3939
CIBW_BEFORE_ALL: |
4040
yum update -y
4141
yum install -y cmake gcc gcc-c++ make git pkgconfig
42-
# Install SLEEF in container
43-
git clone --branch 3.8 https://github.com/shibatch/sleef.git
44-
cd sleef
45-
cmake -S . -B build \
46-
-DSLEEF_BUILD_QUAD:BOOL=ON \
47-
-DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \
48-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
49-
cmake --build build/ --clean-first -j
50-
cmake --install build --prefix /usr/local
5142
CIBW_ENVIRONMENT: >
52-
CFLAGS="-I/usr/local/include $CFLAGS"
53-
CXXFLAGS="-I/usr/local/include $CXXFLAGS"
54-
LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp $LDFLAGS"
55-
LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
56-
PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
43+
LDFLAGS="-fopenmp"
5744
CIBW_REPAIR_WHEEL_COMMAND: |
5845
auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}
5946
CIBW_TEST_COMMAND: |
@@ -98,22 +85,6 @@ jobs:
9885
brew cleanup
9986
brew install $packages
10087
101-
- name: Install SLEEF
102-
env:
103-
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}
104-
run: |
105-
git clone --branch 3.8 https://github.com/shibatch/sleef.git
106-
cd sleef
107-
cmake -S . -B build \
108-
-DSLEEF_BUILD_QUAD:BOOL=ON \
109-
-DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \
110-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
111-
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.os == 'macos-13' && '13.0' || '14.0' }} \
112-
-DCMAKE_INSTALL_RPATH="@loader_path/../lib" \
113-
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
114-
cmake --build build/ --clean-first -j
115-
sudo cmake --install build --prefix /usr/local
116-
11788
- name: Installing Python dependencies
11889
run: |
11990
pip install -U pip
@@ -128,11 +99,6 @@ jobs:
12899
CIBW_BUILD_VERBOSITY: "3"
129100
CIBW_ENVIRONMENT: >
130101
MACOSX_DEPLOYMENT_TARGET="${{ matrix.os == 'macos-13' && '13.0' || '14.0' }}"
131-
DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH"
132-
CFLAGS="-I/usr/local/include $CFLAGS"
133-
CXXFLAGS="-I/usr/local/include $CXXFLAGS"
134-
LDFLAGS="-L/usr/local/lib $LDFLAGS"
135-
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
136102
CIBW_REPAIR_WHEEL_COMMAND: >
137103
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}
138104
CIBW_TEST_COMMAND: |
@@ -177,15 +143,6 @@ jobs:
177143
- name: Install CMake
178144
uses: lukka/get-cmake@latest
179145

180-
- name: Clone and Build SLEEF
181-
shell: pwsh
182-
run: |
183-
git clone --branch 3.8 https://github.com/shibatch/sleef.git
184-
cd sleef
185-
cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture == 'x86' && 'Win32' || 'x64' }} -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
186-
cmake --build build --config Release
187-
cmake --install build --prefix "C:/sleef" --config Release
188-
189146
- name: Install build dependencies
190147
shell: bash -l {0}
191148
run: |
@@ -204,12 +161,8 @@ jobs:
204161
CIBW_BEFORE_BUILD: |
205162
pip install meson meson-python ninja numpy
206163
CIBW_ENVIRONMENT: >
207-
INCLUDE="C:/sleef/include;$INCLUDE"
208-
LIB="C:/sleef/lib;$LIB"
209-
PATH="C:/sleef/bin;$PATH"
210-
CFLAGS="/IC:/sleef/include /DDISABLE_QUADBLAS $CFLAGS"
211-
CXXFLAGS="/IC:/sleef/include /DDISABLE_QUADBLAS $CXXFLAGS"
212-
LDFLAGS="C:/sleef/lib/sleef.lib C:/sleef/lib/sleefquad.lib $LDFLAGS"
164+
CFLAGS="/DDISABLE_QUADBLAS $CFLAGS"
165+
CXXFLAGS="/DDISABLE_QUADBLAS $CXXFLAGS"
213166
CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin'
214167
CIBW_TEST_COMMAND: |
215168
pip install {package}[test]
@@ -247,29 +200,14 @@ jobs:
247200
sudo apt-get update -y
248201
sudo apt-get install -y cmake gcc g++ make git pkg-config
249202
250-
- name: Install SLEEF
251-
run: |
252-
git clone --branch 3.8 https://github.com/shibatch/sleef.git
253-
cd sleef
254-
cmake -S . -B build \
255-
-DSLEEF_BUILD_QUAD:BOOL=ON \
256-
-DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \
257-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
258-
cmake --build build/ --clean-first -j
259-
sudo cmake --install build --prefix /usr/local
260-
261203
- name: Install build dependencies
262204
run: |
263205
python -m pip install --upgrade pip
264206
python -m pip install build
265207
266208
- name: Build SDist
267209
env:
268-
CFLAGS: "-I/usr/local/include"
269-
CXXFLAGS: "-I/usr/local/include"
270-
LDFLAGS: "-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
271-
LD_LIBRARY_PATH: "/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
272-
PKG_CONFIG_PATH: "/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
210+
LDFLAGS: "-fopenmp"
273211
run: |
274212
python -m build --sdist --outdir dist/
275213
working-directory: ./quaddtype

.github/workflows/ci.yml

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,11 @@ jobs:
6060
sudo apt-get update
6161
sudo apt-get install -y libmpfr-dev libssl-dev libfftw3-dev
6262
63-
- name: Install SLEEF
64-
run: |
65-
sudo apt-get update -y
66-
sudo apt-get install -y cmake gcc g++ make git pkg-config
67-
git clone --branch 3.8 https://github.com/shibatch/sleef.git
68-
cd sleef
69-
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
70-
cmake --build build/ --clean-first -j
71-
sudo cmake --install build --prefix /usr/local
72-
7363
- name: Install quaddtype
7464
working-directory: quaddtype
7565
run: |
76-
# Set environment variables with proper export and correct paths
77-
export CFLAGS="-I/usr/local/include"
78-
export CXXFLAGS="-I/usr/local/include"
79-
export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
80-
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
81-
82-
# Install with meson args to ensure the C++ flags are passed through
83-
python -m pip install . -v --no-build-isolation \
84-
-Cbuilddir=build \
85-
-C'compile-args=-v' \
86-
-Csetup-args="-Dbuildtype=debug" \
87-
-Csetup-args="-Dcpp_args=-fext-numeric-literals"
66+
export LDFLAGS="-fopenmp"
67+
python -m pip install . -v
8868
8969
- name: Run quaddtype tests
9070
working-directory: quaddtype

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ compile_commands.json
140140

141141
# quddtype
142142
/quaddtype/subprojects/qblas/
143+
/quaddtype/subprojects/sleef/
143144
.wraplock

quaddtype/meson.build

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ if is_windows
1313
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
1414
endif
1515

16-
sleef_dep = [
17-
c.find_library('sleef', required : true),
18-
c.find_library('sleefquad', required : true)
19-
]
16+
sleef_subproj = subproject('sleef', required: true)
17+
sleef_dep = sleef_subproj.get_variable('sleef_dep')
18+
sleefquad_dep = sleef_subproj.get_variable('sleefquad_dep')
2019

2120
incdir_numpy = run_command(py,
2221
['-c', 'import numpy; print(numpy.get_include())'],
@@ -26,7 +25,7 @@ incdir_numpy = run_command(py,
2625
# OpenMP dependency (optional, for threading)
2726
openmp_dep = dependency('openmp', required: false)
2827
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
29-
dependencies = [sleef_dep, py_dep, qblas_dep]
28+
dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep]
3029
if openmp_dep.found()
3130
dependencies += openmp_dep
3231
endif
@@ -80,7 +79,6 @@ build_includes = include_directories('.') # compile time generated headers as pe
8079
includes = include_directories(
8180
[
8281
incdir_numpy,
83-
# 'subprojects/qblas/include',
8482
'numpy_quaddtype/src',
8583
]
8684
)
@@ -126,10 +124,9 @@ py.install_sources(
126124

127125
py.extension_module('_quaddtype_main',
128126
srcs,
129-
link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'],
130127
link_language: 'cpp',
131128
dependencies: dependencies,
132129
install: true,
133130
subdir: 'numpy_quaddtype',
134-
include_directories: [includes, build_includes]
131+
include_directories: [includes, build_includes],
135132
)

quaddtype/reinstall.sh

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
#!/bin/bash
2-
set -xeuo pipefail
3-
IFS=$'\n\t'
2+
set -x
43

5-
if [ -d "build/" ]
6-
then
4+
if [ -d "build/" ]; then
75
rm -r build
6+
rm -rf dist/
7+
rm -rf subprojects/qblas
8+
rm -rf subprojects/sleef
89
fi
910

10-
export CC=clang
11-
export CXX=clang++
12-
export SLEEF_DIR=$PWD/sleef/build
13-
export LIBRARY_PATH=$SLEEF_DIR/lib
14-
export C_INCLUDE_PATH=$SLEEF_DIR/include
15-
export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include
16-
17-
# Set RPATH via LDFLAGS
18-
export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib"
1911

2012
python -m pip uninstall -y numpy_quaddtype
21-
python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v'
13+
python -m pip install . -v

quaddtype/sdist_test.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -x
3+
4+
if [ -d "build/" ]; then
5+
rm -rf dist/
6+
fi
7+
8+
python -m pip uninstall -y numpy_quaddtype
9+
python -m build --sdist --outdir dist/
10+
python -m pip install dist/numpy_quaddtype-0.1.0.tar.gz -v
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
project('sleef', version: '3.8')
2+
3+
cmake = find_program('cmake')
4+
ninja = find_program('ninja', 'make', required: false)
5+
6+
sleef_build_dir = 'sleef_build'
7+
sleef_install_dir = 'sleef_install'
8+
9+
# turning off parallel build in windows
10+
parallel_flag = ['--parallel']
11+
if host_machine.system() == 'windows'
12+
parallel_flag = []
13+
endif
14+
15+
sleef_configure = run_command([
16+
cmake,
17+
'-S', meson.current_source_dir(),
18+
'-B', meson.current_build_dir() / sleef_build_dir,
19+
'-DCMAKE_BUILD_TYPE=Release',
20+
'-DSLEEF_BUILD_QUAD=ON',
21+
'-DSLEEF_BUILD_SHARED_LIBS=OFF',
22+
'-DSLEEF_BUILD_TESTS=OFF',
23+
'-DSLEEF_BUILD_INLINE_HEADERS=OFF',
24+
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
25+
'-DCMAKE_INSTALL_PREFIX=' + meson.current_build_dir() / sleef_install_dir
26+
], check: false, capture: true)
27+
28+
if sleef_configure.returncode() != 0
29+
error('SLEEF CMake configuration failed: ' + sleef_configure.stderr())
30+
endif
31+
32+
sleef_build_target = custom_target('sleef_build',
33+
command: [cmake, '--build', meson.current_build_dir() / sleef_build_dir, '--target', 'install'] + parallel_flag,
34+
output: 'sleef_built.stamp',
35+
console: true,
36+
build_always_stale: true,
37+
build_by_default: true
38+
)
39+
40+
sleef_include_path = meson.current_build_dir() / sleef_install_dir / 'include'
41+
42+
sleef_build_dep = declare_dependency(sources: [sleef_build_target])
43+
44+
sleef_static_define = ''
45+
if host_machine.system() == 'windows'
46+
sleef_static_define = '-DSLEEF_STATIC_LIBS'
47+
endif
48+
49+
compile_args_list = ['-I' + sleef_include_path]
50+
if sleef_static_define != ''
51+
compile_args_list += sleef_static_define
52+
endif
53+
54+
sleef_dep = declare_dependency(
55+
dependencies: [sleef_build_dep],
56+
compile_args: compile_args_list,
57+
link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleef'] #both lib and lib64 because of ubuntu vs redhat compatibility
58+
)
59+
60+
sleefquad_dep = declare_dependency(
61+
dependencies: [sleef_build_dep],
62+
compile_args: compile_args_list,
63+
link_args: ['-L' + meson.current_build_dir() / sleef_install_dir / 'lib', '-L' + meson.current_build_dir() / sleef_install_dir / 'lib64', '-lsleefquad']
64+
)

quaddtype/subprojects/sleef.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-git]
2+
directory=sleef
3+
url=https://github.com/shibatch/sleef.git
4+
revision=3.8
5+
patch_directory=sleef
6+
7+
[provide]
8+
sleef = sleef_dep
9+
sleefquad = sleefquad_dep

0 commit comments

Comments
 (0)