Skip to content

Commit 6eaea0e

Browse files
committed
fixing conflict
2 parents 4a93bae + db1ee6a commit 6eaea0e

27 files changed

Lines changed: 2929 additions & 177 deletions

.github/workflows/big_endian.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ permissions:
2222

2323
jobs:
2424
big_endian_tests:
25-
runs-on: ubuntu-22.04
25+
runs-on: ubuntu-24.04
2626
continue-on-error: true
2727
strategy:
2828
fail-fast: false
@@ -49,7 +49,7 @@ jobs:
4949

5050
name: "${{ matrix.BUILD_PROP[0] }}"
5151
steps:
52-
- uses: actions/checkout@v5
52+
- uses: actions/checkout@v6
5353
with:
5454
submodules: recursive
5555
fetch-tags: true
@@ -66,7 +66,7 @@ jobs:
6666
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
6767
6868
- name: Cache docker container
69-
uses: actions/cache@v4
69+
uses: actions/cache@v5
7070
id: container-cache
7171
with:
7272
path: ~/docker_${{ matrix.BUILD_PROP[1] }}

.github/workflows/build_wheels.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: Build wheels on Linux
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424

2525
- name: Set up Python
2626
uses: actions/setup-python@v6
@@ -61,7 +61,7 @@ jobs:
6161
python -m cibuildwheel --output-dir wheelhouse
6262
working-directory: ./quaddtype
6363

64-
- uses: actions/upload-artifact@v5
64+
- uses: actions/upload-artifact@v6
6565
with:
6666
path: ./quaddtype/wheelhouse/*.whl
6767
name: wheels-linux
@@ -74,7 +74,7 @@ jobs:
7474
os: [macos-14, macos-15, macos-15-intel]
7575

7676
steps:
77-
- uses: actions/checkout@v5
77+
- uses: actions/checkout@v6
7878

7979
- name: Set up Python
8080
uses: actions/setup-python@v6
@@ -125,7 +125,7 @@ jobs:
125125
python -m cibuildwheel --output-dir wheelhouse
126126
working-directory: ./quaddtype
127127

128-
- uses: actions/upload-artifact@v5
128+
- uses: actions/upload-artifact@v6
129129
with:
130130
path: ./quaddtype/wheelhouse/*.whl
131131
name: wheels-${{ matrix.os }}
@@ -139,7 +139,7 @@ jobs:
139139
architecture: [x64]
140140

141141
steps:
142-
- uses: actions/checkout@v5
142+
- uses: actions/checkout@v6
143143

144144
- name: Setup MSVC
145145
uses: ilammy/msvc-dev-cmd@v1
@@ -185,7 +185,7 @@ jobs:
185185
if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" }
186186
working-directory: ./quaddtype
187187

188-
- uses: actions/upload-artifact@v5
188+
- uses: actions/upload-artifact@v6
189189
with:
190190
path: ./quaddtype/wheelhouse/*.whl
191191
name: wheels-windows-${{ matrix.architecture }}
@@ -194,7 +194,7 @@ jobs:
194194
name: Build SDist
195195
runs-on: ubuntu-latest
196196
steps:
197-
- uses: actions/checkout@v5
197+
- uses: actions/checkout@v6
198198

199199
- name: Set up Python
200200
uses: actions/setup-python@v6
@@ -222,7 +222,7 @@ jobs:
222222
working-directory: ./quaddtype
223223

224224
- name: Upload SDist artifact
225-
uses: actions/upload-artifact@v5
225+
uses: actions/upload-artifact@v6
226226
with:
227227
name: sdist
228228
path: ./quaddtype/dist/*.tar.gz
@@ -248,7 +248,7 @@ jobs:
248248

249249
steps:
250250
- name: Download all workflow run artifacts
251-
uses: actions/download-artifact@v6
251+
uses: actions/download-artifact@v7
252252
with:
253253
pattern: "*"
254254
path: dist

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616
- name: Setup Python
1717
uses: actions/setup-python@v6
1818
with:

.github/workflows/typecheck.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
timeout-minutes: 2
2121

2222
steps:
23-
- uses: actions/checkout@v5
23+
- uses: actions/checkout@v6
2424

25-
- uses: astral-sh/setup-uv@v7.1.3
25+
- uses: astral-sh/setup-uv@v7.1.6
2626
with:
2727
activate-environment: true
28-
python-version: "3.11"
28+
python-version: "3.12"
2929

3030
- name: install
3131
working-directory: quaddtype

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ compile_commands.json
141141
# quaddtype
142142
/quaddtype/subprojects/qblas/
143143
/quaddtype/subprojects/sleef/
144+
/quaddtype/subprojects/pythoncapi-compat/
144145
.wraplock
145146

146147
# docs

quaddtype/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ Building the `numpy-quaddtype` package:
4242
python3 -m venv temp
4343
source temp/bin/activate
4444

45-
# Install the package
46-
pip install numpy pytest meson-python
45+
# Install NumPy from source
46+
pip install "numpy @ git+https://github.com/numpy/numpy.git"
47+
48+
# Install build and test dependencies
49+
pip install pytest meson meson-python
4750

4851
# To build without QBLAS (default for MSVC)
4952
# export CFLAGS="-DDISABLE_QUADBLAS"

quaddtype/meson.build

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ if sleef_dep.found() and sleef_dep.type_name() != 'internal'
2525
# SLEEF found system-wide - verify quad-precision support
2626
cpp = meson.get_compiler('cpp')
2727
sleefquad_lib = cpp.find_library('sleefquad', required: false)
28+
tlfloat_lib = cpp.find_library('tlfloat', required: false)
2829

29-
if sleefquad_lib.found()
30+
if sleefquad_lib.found() and tlfloat_lib.found()
3031
sleefquad_test_code = '''
3132
#include <sleefquad.h>
3233
@@ -40,40 +41,48 @@ if sleef_dep.found() and sleef_dep.type_name() != 'internal'
4041
# this should compile and link
4142
quad_works = cpp.links(
4243
sleefquad_test_code,
43-
dependencies: [sleef_dep, sleefquad_lib],
44+
dependencies: [sleef_dep, sleefquad_lib, tlfloat_lib],
4445
name: 'SLEEF quad-precision support'
4546
)
4647

4748
if quad_works
4849
sleefquad_dep = declare_dependency(
4950
dependencies: [sleef_dep, sleefquad_lib]
5051
)
52+
tlfloat_dep = declare_dependency(
53+
dependencies: [tlfloat_lib]
54+
)
5155
use_system_sleef = true
5256
else
53-
fallback_reason = 'quad-precision support is not working'
57+
fallback_reason = 'System-wide SLEEF installation found but a test for quad precision support failed.'
5458
endif
5559
else
56-
fallback_reason = 'sleefquad library is missing'
60+
fallback_reason = 'System-wide SLEEF installation does not have a sleefquad library.'
5761
endif
5862
else
59-
fallback_reason = 'SLEEF not found system-wide'
63+
fallback_reason = 'Cannot find system-wide SLEEF installation.'
6064
endif
6165

6266
if use_system_sleef
6367
message('Using system-wide SLEEF installation with quad-precision support')
6468
else
65-
warning('Falling back to SLEEF subproject: ' + fallback_reason)
6669
sleef_subproj = subproject('sleef')
6770
sleef_dep = sleef_subproj.get_variable('sleef_dep')
6871
sleefquad_dep = sleef_subproj.get_variable('sleefquad_dep')
69-
message('Using SLEEF subproject')
72+
tlfloat_dep = sleef_subproj.get_variable('tlfloat_dep')
73+
warning(fallback_reason)
74+
message('Proceeding with vendored SLEEF subproject instead')
7075
endif
7176

7277
incdir_numpy = run_command(py,
7378
['-c', 'import numpy; print(numpy.get_include())'],
7479
check : true
7580
).stdout().strip()
7681

82+
# pythoncapi-compat for portable C API usage across Python versions
83+
pythoncapi_compat_subproj = subproject('pythoncapi-compat')
84+
pythoncapi_compat_inc = pythoncapi_compat_subproj.get_variable('incdir')
85+
7786
# print numpy version used
7887
numpy_version = run_command(py,
7988
['-c', 'import numpy; print(numpy.__version__)'],
@@ -84,7 +93,7 @@ message('Using NumPy version: @0@'.format(numpy_version))
8493
npymath_path = incdir_numpy / '..' / 'lib'
8594
npymath_lib = c.find_library('npymath', dirs: npymath_path)
8695

87-
dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep, npymath_lib]
96+
dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep, tlfloat_dep, npymath_lib]
8897

8998
# Add OpenMP dependency (optional, for threading)
9099
openmp_dep = dependency('openmp', required: false, static: false)
@@ -99,6 +108,11 @@ if not is_windows
99108
if cpp.has_argument('-fext-numeric-literals')
100109
add_project_arguments('-fext-numeric-literals', language: 'cpp')
101110
endif
111+
112+
# Suppress warnings from system headers (sleefquad.h has many unused inline functions)
113+
if cpp.has_argument('-Wno-unused-function')
114+
add_project_arguments('-Wno-unused-function', language: ['c', 'cpp'])
115+
endif
102116
endif
103117

104118
# Thread-local storage detection (borrowed from NumPy)
@@ -144,6 +158,7 @@ includes = include_directories(
144158
'numpy_quaddtype/src',
145159
]
146160
)
161+
pythoncapi_includes = pythoncapi_compat_inc
147162

148163
srcs = [
149164
'numpy_quaddtype/src/quad_common.h',
@@ -198,5 +213,5 @@ py.extension_module('_quaddtype_main',
198213
dependencies: dependencies,
199214
install: true,
200215
subdir: 'numpy_quaddtype',
201-
include_directories: [includes, build_includes],
216+
include_directories: [includes, build_includes, pythoncapi_includes],
202217
)

quaddtype/numpy_quaddtype/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import enum
2+
13
from ._quaddtype_main import (
24
QuadPrecision,
35
QuadPrecDType,
@@ -10,8 +12,16 @@
1012

1113
__version__ = "0.2.0"
1214

15+
16+
class QuadBackend(enum.IntEnum):
17+
"""Backend type for QuadPrecision computations."""
18+
SLEEF = 0
19+
LONGDOUBLE = 1
20+
21+
1322
__all__ = [
14-
'QuadPrecision', 'QuadPrecDType', 'SleefQuadPrecision', 'LongDoubleQuadPrecision',
23+
'QuadPrecision', 'QuadPrecDType', 'QuadBackend',
24+
'SleefQuadPrecision', 'LongDoubleQuadPrecision',
1525
'SleefQuadPrecDType', 'LongDoubleQuadPrecDType', 'is_longdouble_128',
1626
# Constants
1727
'pi', 'e', 'log2e', 'log10e', 'ln2', 'ln10', 'max_value', 'epsilon',

quaddtype/numpy_quaddtype/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Final
2+
import enum
23

34
from ._quaddtype_main import (
45
QuadPrecDType,
@@ -10,9 +11,14 @@ from ._quaddtype_main import (
1011
set_num_threads,
1112
)
1213

14+
class QuadBackend(enum.IntEnum):
15+
SLEEF = 0
16+
LONGDOUBLE = 1
17+
1318
__all__ = [
1419
"QuadPrecision",
1520
"QuadPrecDType",
21+
"QuadBackend",
1622
"SleefQuadPrecision",
1723
"LongDoubleQuadPrecision",
1824
"SleefQuadPrecDType",

quaddtype/numpy_quaddtype/_quaddtype_main.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import numpy as np
44
from numpy._typing import _128Bit # pyright: ignore[reportPrivateUsage]
55
from typing_extensions import Never, Self, override
66

7+
from numpy_quaddtype import QuadBackend
8+
79
_Backend: TypeAlias = Literal["sleef", "longdouble"]
810
_IntoQuad: TypeAlias = (
911
QuadPrecision
@@ -20,6 +22,10 @@ _ScalarItemArg: TypeAlias = Literal[0, -1] | tuple[Literal[0, -1]] | tuple[()]
2022
class QuadPrecDType(np.dtype[QuadPrecision]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
2123
def __new__(cls, /, backend: _Backend = "sleef") -> Self: ...
2224

25+
# QuadPrecDType specific attributes
26+
@property
27+
def backend(self) -> QuadBackend: ...
28+
2329
# `numpy.dtype` overrides
2430
names: None # pyright: ignore[reportIncompatibleVariableOverride]
2531
@property
@@ -123,7 +129,7 @@ class QuadPrecision(np.floating[_128Bit]):
123129
@override
124130
def __add__(self, other: _IntoQuad, /) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
125131
@override
126-
def __radd__(self, other: _IntoQuad, /) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
132+
def __radd__(self, other: _IntoQuad, /) -> Self: ... # type: ignore[override, misc] # pyright: ignore[reportIncompatibleMethodOverride]
127133
@override
128134
def __sub__(self, other: _IntoQuad, /) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
129135
@override

0 commit comments

Comments
 (0)