diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 3ab23ff..2d1d4d5 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -148,7 +148,7 @@ jobs: git clone --branch 3.8 https://github.com/shibatch/sleef.git cd sleef 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 - cmake --build build --config Release --parallel + cmake --build build --config Release cmake --install build --prefix "C:/sleef" --config Release - name: Setup build environment @@ -194,54 +194,61 @@ jobs: path: ./quaddtype/wheelhouse/*.whl name: wheels-windows-${{ matrix.architecture }} - publish_to_testpypi: - name: Publish to TestPyPI + publish_to_pypi: + name: Publish to PyPI needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/quaddtype-v') + + environment: + name: quadtype_release + url: https://pypi.org/p/numpy-quaddtype + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: - name: Download all workflow run artifacts uses: actions/download-artifact@v4 with: path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.9.0 + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - repository-url: https://test.pypi.org/legacy/ packages-dir: dist/* - create_release: - name: Create Release - needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/quaddtype-v') - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload Release Assets - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: ./artifacts/**/*.whl - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + # With the current setup, we are not creating a release on GitHub. + # create_release: + # name: Create Release + # needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] + # runs-on: ubuntu-latest + # if: startsWith(github.ref, 'refs/tags/quaddtype-v') + + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + + # - name: Download all workflow run artifacts + # uses: actions/download-artifact@v4 + # with: + # path: artifacts + + # - name: Create Release + # id: create_release + # uses: actions/create-release@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }} + # with: + # tag_name: ${{ github.ref }} + # release_name: Release ${{ github.ref }} + # draft: false + # prerelease: false + + # - name: Upload Release Assets + # uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + # with: + # files: ./artifacts/**/*.whl + # env: + # GITHUB_TOKEN: ${{ secrets.QUADDTYPE_GITHUB_TOKEN }} diff --git a/quaddtype/README.md b/quaddtype/README.md index bd06738..614a3c2 100644 --- a/quaddtype/README.md +++ b/quaddtype/README.md @@ -1,10 +1,12 @@ # Numpy-QuadDType +A cross-platform Quad (128-bit) float Data-Type for NumPy. + ## Installation -``` -pip install numpy==2.1.0 -pip install -i https://test.pypi.org/simple/ quaddtype +```bash +pip install numpy +pip install numpy-quaddtype ``` ## Usage @@ -21,7 +23,7 @@ np.array([1,2,3], dtype=QuadPrecDType("sleef")) np.array([1,2,3], dtype=QuadPrecDType("longdouble")) ``` -## Install from source +## Installation from source The code needs the quad precision pieces of the sleef library, which is not available on most systems by default, so we have to generate @@ -29,30 +31,33 @@ that first. The below assumes one has the required pieces to build sleef (cmake and libmpfr-dev), and that one is in the package directory locally. -``` -git clone https://github.com/shibatch/sleef.git +```bash +git clone --branch 3.8 https://github.com/shibatch/sleef.git cd sleef cmake -S . -B build -DSLEEF_BUILD_QUAD:BOOL=ON -DSLEEF_BUILD_SHARED_LIBS:BOOL=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON cmake --build build/ --clean-first -j cd .. ``` -In principle, one can now install this system-wide, but easier would -seem to use the version that was just created, as follows: -``` +Building the `numpy-quaddtype` package from locally installed sleef: +```bash export SLEEF_DIR=$PWD/sleef/build export LIBRARY_PATH=$SLEEF_DIR/lib export C_INCLUDE_PATH=$SLEEF_DIR/include export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include + +# setup the virtual env python3 -m venv temp source temp/bin/activate + +# Install the package pip install meson-python numpy pytest -pip install -e . -v --no-build-isolation -export LD_LIBRARY_PATH=$SLEEF_DIR/lib -``` -Here, we created an editable install on purpose, so one can just work -from the package directory if needed, e.g., to run the tests with, -``` +export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib" +python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' + +# Run the tests +cd .. python -m pytest ``` + diff --git a/quaddtype/reinstall.sh b/quaddtype/reinstall.sh index 5131f15..1c08f84 100755 --- a/quaddtype/reinstall.sh +++ b/quaddtype/reinstall.sh @@ -7,7 +7,15 @@ then rm -r build fi -#meson setup build -Db_sanitize=address,undefined +export CC=clang +export CXX=clang++ +export SLEEF_DIR=$PWD/sleef/build +export LIBRARY_PATH=$SLEEF_DIR/lib +export C_INCLUDE_PATH=$SLEEF_DIR/include +export CPLUS_INCLUDE_PATH=$SLEEF_DIR/include + +# Set RPATH via LDFLAGS +export LDFLAGS="-Wl,-rpath,$SLEEF_DIR/lib" + python -m pip uninstall -y numpy_quaddtype -# python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' \ No newline at end of file diff --git a/quaddtype/tests/test_quaddtype.py b/quaddtype/tests/test_quaddtype.py index 71dcb70..bf0762f 100644 --- a/quaddtype/tests/test_quaddtype.py +++ b/quaddtype/tests/test_quaddtype.py @@ -70,6 +70,10 @@ def test_unary_ops(op, val, expected): assert result == expected_val, f"{op}({val}) should be {expected}, but got {result}" +def test_inf(): + assert QuadPrecision("inf") > QuadPrecision("1e1000") + assert QuadPrecision("-inf") < QuadPrecision("-1e1000") + def test_dtype_creation(): dtype = QuadPrecDType()