Skip to content

Commit 2db17f4

Browse files
authored
Merge branch 'numpy:main' into nan-comparisons
2 parents a295e20 + 53ccf00 commit 2db17f4

File tree

4 files changed

+82
-58
lines changed

4 files changed

+82
-58
lines changed

.github/workflows/build_wheels.yml

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
git clone --branch 3.8 https://github.com/shibatch/sleef.git
149149
cd sleef
150150
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
151-
cmake --build build --config Release --parallel
151+
cmake --build build --config Release
152152
cmake --install build --prefix "C:/sleef" --config Release
153153
154154
- name: Setup build environment
@@ -194,54 +194,61 @@ jobs:
194194
path: ./quaddtype/wheelhouse/*.whl
195195
name: wheels-windows-${{ matrix.architecture }}
196196

197-
publish_to_testpypi:
198-
name: Publish to TestPyPI
197+
publish_to_pypi:
198+
name: Publish to PyPI
199199
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
200200
runs-on: ubuntu-latest
201201
if: startsWith(github.ref, 'refs/tags/quaddtype-v')
202+
203+
environment:
204+
name: quadtype_release
205+
url: https://pypi.org/p/numpy-quaddtype
206+
207+
permissions:
208+
id-token: write # IMPORTANT: mandatory for trusted publishing
209+
202210
steps:
203211
- name: Download all workflow run artifacts
204212
uses: actions/download-artifact@v4
205213
with:
206214
path: dist
207-
- name: Publish to TestPyPI
208-
uses: pypa/[email protected]
215+
216+
- name: Publish to PyPI
217+
uses: pypa/gh-action-pypi-publish@release/v1
209218
with:
210-
user: __token__
211-
password: ${{ secrets.PYPI_API_TOKEN }}
212-
repository-url: https://test.pypi.org/legacy/
213219
packages-dir: dist/*
214220

215-
create_release:
216-
name: Create Release
217-
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
218-
runs-on: ubuntu-latest
219-
if: startsWith(github.ref, 'refs/tags/quaddtype-v')
220-
221-
steps:
222-
- name: Checkout code
223-
uses: actions/checkout@v2
224-
225-
- name: Download all workflow run artifacts
226-
uses: actions/download-artifact@v4
227-
with:
228-
path: artifacts
229-
230-
- name: Create Release
231-
id: create_release
232-
uses: actions/create-release@v1
233-
env:
234-
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
235-
with:
236-
tag_name: ${{ github.ref }}
237-
release_name: Release ${{ github.ref }}
238-
draft: false
239-
prerelease: false
240-
241-
- name: Upload Release Assets
242-
uses: softprops/action-gh-release@v1
243-
if: startsWith(github.ref, 'refs/tags/')
244-
with:
245-
files: ./artifacts/**/*.whl
246-
env:
247-
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
221+
# With the current setup, we are not creating a release on GitHub.
222+
# create_release:
223+
# name: Create Release
224+
# needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
225+
# runs-on: ubuntu-latest
226+
# if: startsWith(github.ref, 'refs/tags/quaddtype-v')
227+
228+
# steps:
229+
# - name: Checkout code
230+
# uses: actions/checkout@v2
231+
232+
# - name: Download all workflow run artifacts
233+
# uses: actions/download-artifact@v4
234+
# with:
235+
# path: artifacts
236+
237+
# - name: Create Release
238+
# id: create_release
239+
# uses: actions/create-release@v1
240+
# env:
241+
# GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }}
242+
# with:
243+
# tag_name: ${{ github.ref }}
244+
# release_name: Release ${{ github.ref }}
245+
# draft: false
246+
# prerelease: false
247+
248+
# - name: Upload Release Assets
249+
# uses: softprops/action-gh-release@v1
250+
# if: startsWith(github.ref, 'refs/tags/')
251+
# with:
252+
# files: ./artifacts/**/*.whl
253+
# env:
254+
# GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }}

quaddtype/README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Numpy-QuadDType
22

3+
A cross-platform Quad (128-bit) float Data-Type for NumPy.
4+
35
## Installation
46

5-
```
6-
pip install numpy==2.1.0
7-
pip install -i https://test.pypi.org/simple/ quaddtype
7+
```bash
8+
pip install numpy
9+
pip install numpy-quaddtype
810
```
911

1012
## Usage
@@ -21,38 +23,41 @@ np.array([1,2,3], dtype=QuadPrecDType("sleef"))
2123
np.array([1,2,3], dtype=QuadPrecDType("longdouble"))
2224
```
2325

24-
## Install from source
26+
## Installation from source
2527

2628
The code needs the quad precision pieces of the sleef library, which
2729
is not available on most systems by default, so we have to generate
2830
that first. The below assumes one has the required pieces to build
2931
sleef (cmake and libmpfr-dev), and that one is in the package
3032
directory locally.
3133

32-
```
33-
git clone https://github.com/shibatch/sleef.git
34+
```bash
35+
git clone --branch 3.8 https://github.com/shibatch/sleef.git
3436
cd sleef
3537
cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON
3638
cmake --build build/ --clean-first -j
3739
cd ..
3840
```
3941

40-
In principle, one can now install this system-wide, but easier would
41-
seem to use the version that was just created, as follows:
42-
```
42+
Building the `numpy-quaddtype` package from locally installed sleef:
43+
```bash
4344
export SLEEF_DIR=$PWD/sleef/build
4445
export LIBRARY_PATH=$SLEEF_DIR/lib
4546
export C_INCLUDE_PATH=$SLEEF_DIR/include
4647
export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include
48+
49+
# setup the virtual env
4750
python3 -m venv temp
4851
source temp/bin/activate
52+
53+
# Install the package
4954
pip install meson-python numpy pytest
50-
pip install -e . -v --no-build-isolation
51-
export LD_LIBRARY_PATH=$SLEEF_DIR/lib
52-
```
5355

54-
Here, we created an editable install on purpose, so one can just work
55-
from the package directory if needed, e.g., to run the tests with,
56-
```
56+
export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib"
57+
python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v'
58+
59+
# Run the tests
60+
cd ..
5761
python -m pytest
5862
```
63+

quaddtype/reinstall.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ then
77
rm -r build
88
fi
99

10-
#meson setup build -Db_sanitize=address,undefined
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"
19+
1120
python -m pip uninstall -y numpy_quaddtype
12-
# python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug"
1321
python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v'

quaddtype/tests/test_quaddtype.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ def test_unary_ops(op, val, expected):
132132

133133
assert result == expected_val, f"{op}({val}) should be {expected}, but got {result}"
134134

135+
def test_inf():
136+
assert QuadPrecision("inf") > QuadPrecision("1e1000")
137+
assert QuadPrecision("-inf") < QuadPrecision("-1e1000")
138+
135139

136140
def test_dtype_creation():
137141
dtype = QuadPrecDType()

0 commit comments

Comments
 (0)