From 1575ac4c67bcfac43ee5d673a49ba58ac0c5d7ab Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 14:54:28 +0530 Subject: [PATCH 001/182] packaging quaddtype --- .../workflows/build_wheels_and_release.yml | 98 +++++++++++++++++++ .gitignore | 3 +- quaddtype/meson.build | 14 ++- quaddtype/pyproject.toml | 39 +++++++- 4 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build_wheels_and_release.yml diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml new file mode 100644 index 00000000..56b569fd --- /dev/null +++ b/.github/workflows/build_wheels_and_release.yml @@ -0,0 +1,98 @@ +name: Build quaddtype wheels and release + +on: + push: + branches: + - main + tags: + - 'v*' + pull_request: + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macos-11] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Set up Conda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: '3.10' + channels: conda-forge,defaults + channel-priority: strict + + - name: Install SLEEF and other dependencies + shell: bash -l {0} + run: | + conda install -y sleef numpy meson meson-python patchelf wheel + + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.11.2 + + - name: Build wheels + shell: bash -l {0} + run: | + export LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH + export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH + export CPATH=$CONDA_PREFIX/include:$CPATH + python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" + CIBW_BUILD_VERBOSITY: "1" + CIBW_ENVIRONMENT: > + LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH + LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH + CPATH=$CONDA_PREFIX/include:$CPATH + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v2 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels + + create_release: + name: Create Release + needs: build_wheels + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./artifacts/wheels/*.whl + asset_name: quaddtype-${{ github.ref_name }}.whl + asset_content_type: application/zip \ No newline at end of file diff --git a/.gitignore b/.gitignore index 65005454..441eecd1 100644 --- a/.gitignore +++ b/.gitignore @@ -133,4 +133,5 @@ compile_commands.json .ruff-cache/ .asv -.vscode/ \ No newline at end of file +.vscode/ +*.whl diff --git a/quaddtype/meson.build b/quaddtype/meson.build index f1f9eab1..e4aa4a98 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -5,8 +5,18 @@ py = py_mod.find_installation() c = meson.get_compiler('c') -sleef_dep = c.find_library('sleef') -sleefquad_dep = c.find_library('sleefquad') +# Get the conda prefix +conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() + +# Add conda lib directory to library path +add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) + +sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) +sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) + +if not sleef_dep.found() or not sleefquad_dep.found() + error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') +endif incdir_numpy = run_command(py, [ diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 68b61e7f..8d94cca4 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -13,7 +13,7 @@ name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" readme = 'README.md' -author = "Swayam Singh" +authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.9.0" dependencies = [ "numpy" @@ -23,3 +23,40 @@ dependencies = [ test = [ "pytest", ] + +[tool.cibuildwheel] +archs = ["auto64"] +skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] +environment = { PATH = "$PATH:/usr/share/miniconda3/bin" } + +[tool.cibuildwheel.linux] +before-all = """ + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p /usr/share/miniconda3 + export PATH="/usr/share/miniconda3/bin:$PATH" + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef +""" + +[tool.cibuildwheel.macos] +before-all = """ + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda3 + export PATH="$HOME/miniconda3/bin:$PATH" + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef +""" + +[tool.cibuildwheel.windows] +before-all = """ + powershell -Command "(New-Object Net.WebClient).DownloadFile('https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'miniconda.exe')" + start /wait "" miniconda.exe /S /D=C:\\Miniconda3 + set PATH=C:\\Miniconda3;C:\\Miniconda3\\Scripts;%PATH% + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef +""" +before-build = "pip install delvewheel" +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file From 00da2c7281bedde61ae7b241649f23aa24575fa6 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:12:20 +0530 Subject: [PATCH 002/182] fixing missing dependency --- .github/workflows/build_wheels_and_release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 56b569fd..987cf4e6 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -36,9 +36,7 @@ jobs: shell: bash -l {0} run: | conda install -y sleef numpy meson meson-python patchelf wheel - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.11.2 + pip install cibuildwheel==2.20.0 - name: Build wheels shell: bash -l {0} From 5333273978e780608484a389a12c464216016024 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:22:18 +0530 Subject: [PATCH 003/182] removing re-init of conda --- quaddtype/pyproject.toml | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 8d94cca4..57599357 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -27,36 +27,10 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] -environment = { PATH = "$PATH:/usr/share/miniconda3/bin" } -[tool.cibuildwheel.linux] -before-all = """ - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p /usr/share/miniconda3 - export PATH="/usr/share/miniconda3/bin:$PATH" - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef -""" - -[tool.cibuildwheel.macos] -before-all = """ - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda3 - export PATH="$HOME/miniconda3/bin:$PATH" - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef -""" +# The environment variable ensures the conda installation is available +environment = { PATH = "$CONDA_PREFIX/bin:$PATH", LD_LIBRARY_PATH = "$CONDA_PREFIX/lib:$LD_LIBRARY_PATH" } [tool.cibuildwheel.windows] -before-all = """ - powershell -Command "(New-Object Net.WebClient).DownloadFile('https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'miniconda.exe')" - start /wait "" miniconda.exe /S /D=C:\\Miniconda3 - set PATH=C:\\Miniconda3;C:\\Miniconda3\\Scripts;%PATH% - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef -""" before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file From 2ad4b40bb4effe7712370313f02c3fcb708b294c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:30:17 +0530 Subject: [PATCH 004/182] fixing wget issues and env issues --- .../workflows/build_wheels_and_release.yml | 26 +++---------------- quaddtype/pyproject.toml | 20 ++++++++++++-- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 987cf4e6..16f9df88 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -22,36 +22,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.10' - - - name: Set up Conda - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true python-version: '3.10' - channels: conda-forge,defaults - channel-priority: strict - - name: Install SLEEF and other dependencies - shell: bash -l {0} - run: | - conda install -y sleef numpy meson meson-python patchelf wheel - pip install cibuildwheel==2.20.0 + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 - name: Build wheels - shell: bash -l {0} - run: | - export LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH - export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH - export CPATH=$CONDA_PREFIX/include:$CPATH - python -m cibuildwheel --output-dir wheelhouse + run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" CIBW_BUILD_VERBOSITY: "1" - CIBW_ENVIRONMENT: > - LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH - LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH - CPATH=$CONDA_PREFIX/include:$CPATH working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 57599357..1330fb4c 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -28,8 +28,24 @@ test = [ archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] -# The environment variable ensures the conda installation is available -environment = { PATH = "$CONDA_PREFIX/bin:$PATH", LD_LIBRARY_PATH = "$CONDA_PREFIX/lib:$LD_LIBRARY_PATH" } +[tool.cibuildwheel.linux] +before-all = """ +yum install -y wget && +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && +bash miniconda.sh -b -p $HOME/miniconda && +export PATH=$HOME/miniconda/bin:$PATH && +conda install -y -c conda-forge sleef +""" +environment = {PATH = "$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH"} + +[tool.cibuildwheel.macos] +before-all = """ +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && +bash miniconda.sh -b -p $HOME/miniconda && +export PATH=$HOME/miniconda/bin:$PATH && +conda install -y -c conda-forge sleef +""" +environment = {PATH = "$HOME/miniconda/bin:$PATH", DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH"} [tool.cibuildwheel.windows] before-build = "pip install delvewheel" From 26f64ea1e0d0202e8b902233bd92e83ecc3237b1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:41:39 +0530 Subject: [PATCH 005/182] fixing PATH issues --- .github/workflows/build_wheels_and_release.yml | 7 ++++--- quaddtype/pyproject.toml | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 16f9df88..53aeda64 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -28,10 +28,11 @@ jobs: run: pip install cibuildwheel==2.20.0 - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse + run: | + python -m cibuildwheel --output-dir wheelhouse env: - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD_VERBOSITY: "3" + CIBW_ENVIRONMENT: PATH="$HOME/miniconda/bin:$PATH" LD_LIBRARY_PATH="$HOME/miniconda/lib:$LD_LIBRARY_PATH" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 1330fb4c..5e359a53 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -27,6 +27,8 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] +test-command = "pytest {project}/tests" +test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ @@ -47,6 +49,12 @@ conda install -y -c conda-forge sleef """ environment = {PATH = "$HOME/miniconda/bin:$PATH", DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH"} -[tool.cibuildwheel.windows] +# [tool.cibuildwheel.windows] +# before-all = """ +# powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" && +# start /wait "" miniconda.exe /S /D=%UserProfile%\Miniconda3 && +# set PATH=%UserProfile%\Miniconda3;%UserProfile%\Miniconda3\Scripts;%PATH% && +# conda install -y -c conda-forge sleef +# """ before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file From 028a62f80dced4533ed7cf7cf52b2c888bb81e54 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:46:41 +0530 Subject: [PATCH 006/182] trying to resolve path intereference with cibuildwheel --- quaddtype/pyproject.toml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 5e359a53..e7e49321 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -35,19 +35,17 @@ before-all = """ yum install -y wget && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda && -export PATH=$HOME/miniconda/bin:$PATH && -conda install -y -c conda-forge sleef +$HOME/miniconda/bin/conda install -y -c conda-forge sleef """ -environment = {PATH = "$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH"} +environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH"} [tool.cibuildwheel.macos] before-all = """ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda && -export PATH=$HOME/miniconda/bin:$PATH && -conda install -y -c conda-forge sleef +$HOME/miniconda/bin/conda install -y -c conda-forge sleef """ -environment = {PATH = "$HOME/miniconda/bin:$PATH", DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH"} +environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH"} # [tool.cibuildwheel.windows] # before-all = """ From 5dcc19bd24df50290a75521725e26a8d232d5147 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 15:54:35 +0530 Subject: [PATCH 007/182] remoed CIBW_ENVIRONMENT --- .github/workflows/build_wheels_and_release.yml | 1 - quaddtype/pyproject.toml | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 53aeda64..b9d2ca66 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -32,7 +32,6 @@ jobs: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD_VERBOSITY: "3" - CIBW_ENVIRONMENT: PATH="$HOME/miniconda/bin:$PATH" LD_LIBRARY_PATH="$HOME/miniconda/lib:$LD_LIBRARY_PATH" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e7e49321..c95922c9 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -37,7 +37,7 @@ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O mi bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef """ -environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH"} +environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS",LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS"} [tool.cibuildwheel.macos] before-all = """ @@ -45,14 +45,18 @@ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O m bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef """ -environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH"} +environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS"} # [tool.cibuildwheel.windows] # before-all = """ # powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" && # start /wait "" miniconda.exe /S /D=%UserProfile%\Miniconda3 && -# set PATH=%UserProfile%\Miniconda3;%UserProfile%\Miniconda3\Scripts;%PATH% && -# conda install -y -c conda-forge sleef +# %UserProfile%\Miniconda3\Scripts\conda install -y -c conda-forge sleef # """ before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" +# environment = { +# LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", +# INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", +# LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" +# } \ No newline at end of file From 7487a396bf6cc0cb534adab24249b912d769cb8b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:03:47 +0530 Subject: [PATCH 008/182] reduced verbosity level and added CXXFLAG --- .github/workflows/build_wheels_and_release.yml | 2 +- quaddtype/pyproject.toml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index b9d2ca66..a31b44ec 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -31,7 +31,7 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse env: - CIBW_BUILD_VERBOSITY: "3" + CIBW_BUILD_VERBOSITY: "1" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index c95922c9..f5edde0b 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -36,16 +36,18 @@ yum install -y wget && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef +ls -l $HOME/miniconda/include/sleef.h """ -environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS",LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS"} +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"} [tool.cibuildwheel.macos] before-all = """ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef +ls -l $HOME/miniconda/include/sleef.h """ -environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include $CFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS"} +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"} # [tool.cibuildwheel.windows] # before-all = """ From 5234cd225ba4e001939b941af1ace74c49baa200 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:16:56 +0530 Subject: [PATCH 009/182] fixing Py_NewRef error by switching to Py 3.10 --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index f5edde0b..2dd20b75 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -14,7 +14,7 @@ description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] -requires-python = ">=3.9.0" +requires-python = ">=3.10.0" dependencies = [ "numpy" ] From a582290edf6cbe5d33dd26e1c31ca353ac2b7d80 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:24:29 +0530 Subject: [PATCH 010/182] fixing manylinux issues --- quaddtype/pyproject.toml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 2dd20b75..38196c30 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -27,18 +27,37 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] +manylinux-x86_64-image = "manylinux2014" test-command = "pytest {project}/tests" test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ +set -ex yum install -y wget && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h +echo "CFLAGS: $CFLAGS" +echo "CXXFLAGS: $CXXFLAGS" +echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" +echo "LIBRARY_PATH: $LIBRARY_PATH" +g++ --version +conda list sleef """ -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"} +environment = { + LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", + LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", + CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", + CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", + LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", + AUDITWHEEL_PLAT = "manylinux2014_x86_64", + AUDITWHEEL_EXTRA_LIB = "/usr/local/lib", + AUDITWHEEL_SELINUX = "1" +} + +repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ From 7e1028fc28dcd7f5244a52e8c03e1ef5a263e796 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:26:13 +0530 Subject: [PATCH 011/182] fixing toml multiline issue :) --- quaddtype/pyproject.toml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 38196c30..60bb7b9f 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -46,16 +46,7 @@ echo "LIBRARY_PATH: $LIBRARY_PATH" g++ --version conda list sleef """ -environment = { - LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", - LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", - CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", - CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", - LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", - AUDITWHEEL_PLAT = "manylinux2014_x86_64", - AUDITWHEEL_EXTRA_LIB = "/usr/local/lib", - AUDITWHEEL_SELINUX = "1" -} +environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", AUDITWHEEL_EXTRA_LIB = "/usr/local/lib", AUDITWHEEL_SELINUX = "1"} repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" From b00f74a8f722c8430fe6b44c989897035c1b7e3d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:28:22 +0530 Subject: [PATCH 012/182] my bad conda typo --- quaddtype/pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 60bb7b9f..640065e4 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -39,12 +39,6 @@ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O mi bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h -echo "CFLAGS: $CFLAGS" -echo "CXXFLAGS: $CXXFLAGS" -echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" -echo "LIBRARY_PATH: $LIBRARY_PATH" -g++ --version -conda list sleef """ environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", AUDITWHEEL_EXTRA_LIB = "/usr/local/lib", AUDITWHEEL_SELINUX = "1"} From 0644f2820bbb7f58e4f4ba9b429788d073f003a6 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:39:28 +0530 Subject: [PATCH 013/182] still fixing multilinux issue --- quaddtype/pyproject.toml | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 640065e4..85633507 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "mesonpy" name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" -readme = 'README.md' +readme = "README.md" authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" dependencies = [ @@ -26,7 +26,7 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] -skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] +skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*"] manylinux-x86_64-image = "manylinux2014" test-command = "pytest {project}/tests" test-extras = ["test"] @@ -34,14 +34,15 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ set -ex -yum install -y wget && -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && -bash miniconda.sh -b -p $HOME/miniconda && +yum install -y wget centos-release-scl +yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh +bash miniconda.sh -b -p $HOME/miniconda $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h """ -environment = {LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", AUDITWHEEL_EXTRA_LIB = "/usr/local/lib", AUDITWHEEL_SELINUX = "1"} - +before-build = "source /opt/rh/devtoolset-7/enable" +environment = { PATH = "/opt/rh/devtoolset-7/root/usr/bin:$PATH", LD_LIBRARY_PATH = "/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:/opt/rh/devtoolset-7/root/usr/lib64/dyninst:/opt/rh/devtoolset-7/root/usr/lib/dyninst:/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/rh/devtoolset-7/root/usr/bin/gcc", CXX = "/opt/rh/devtoolset-7/root/usr/bin/g++" } repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] @@ -51,18 +52,8 @@ bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h """ -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"} +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" } -# [tool.cibuildwheel.windows] -# before-all = """ -# powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" && -# start /wait "" miniconda.exe /S /D=%UserProfile%\Miniconda3 && -# %UserProfile%\Miniconda3\Scripts\conda install -y -c conda-forge sleef -# """ +[tool.cibuildwheel.windows] before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" -# environment = { -# LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", -# INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", -# LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" -# } \ No newline at end of file +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file From 9288f5fb2417aad0f98025eb0739db156559d53d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:46:48 +0530 Subject: [PATCH 014/182] hmmm maybe can try switching to devtoolset-8 --- quaddtype/pyproject.toml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 85633507..13246084 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -34,23 +34,37 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ set -ex -yum install -y wget centos-release-scl -yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ +# Update ca-certificates +yum install -y ca-certificates +update-ca-trust + +# Install wget and other necessary tools +yum install -y wget + +# Install devtoolset-8 +yum install -y centos-release-scl +yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ + +# Install Miniconda and sleef wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda -$HOME/miniconda/bin/conda install -y -c conda-forge sleef -ls -l $HOME/miniconda/include/sleef.h +export PATH="$HOME/miniconda/bin:$PATH" +conda install -y -c conda-forge sleef + +# Verify sleef installation +ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" """ -before-build = "source /opt/rh/devtoolset-7/enable" -environment = { PATH = "/opt/rh/devtoolset-7/root/usr/bin:$PATH", LD_LIBRARY_PATH = "/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:/opt/rh/devtoolset-7/root/usr/lib64/dyninst:/opt/rh/devtoolset-7/root/usr/lib/dyninst:/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/rh/devtoolset-7/root/usr/bin/gcc", CXX = "/opt/rh/devtoolset-7/root/usr/bin/g++" } +before-build = "source /opt/rh/devtoolset-8/enable" +environment = { PATH = "/opt/rh/devtoolset-8/root/usr/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/rh/devtoolset-8/root/usr/bin/gcc", CXX = "/opt/rh/devtoolset-8/root/usr/bin/g++" } repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && -bash miniconda.sh -b -p $HOME/miniconda && -$HOME/miniconda/bin/conda install -y -c conda-forge sleef -ls -l $HOME/miniconda/include/sleef.h +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh +bash miniconda.sh -b -p $HOME/miniconda +export PATH="$HOME/miniconda/bin:$PATH" +conda install -y -c conda-forge sleef +ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" """ 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" } From 468e329d2aacadc6560557ab6d0f4e173b88ec89 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 16:57:50 +0530 Subject: [PATCH 015/182] replacng problematic yum commands by standalone installation --- quaddtype/pyproject.toml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 13246084..742b458a 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -34,16 +34,10 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ set -ex -# Update ca-certificates -yum install -y ca-certificates -update-ca-trust - -# Install wget and other necessary tools -yum install -y wget - -# Install devtoolset-8 -yum install -y centos-release-scl -yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ +# Download and install a standalone GCC +wget https://github.com/Aetherinox/gcc-arm64/releases/download/12.3.1-2023.10/aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz +tar xf aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz -C /opt +export PATH="/opt/aarch64-linux-gnu/bin:$PATH" # Install Miniconda and sleef wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh @@ -54,8 +48,8 @@ conda install -y -c conda-forge sleef # Verify sleef installation ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" """ -before-build = "source /opt/rh/devtoolset-8/enable" -environment = { PATH = "/opt/rh/devtoolset-8/root/usr/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/rh/devtoolset-8/root/usr/bin/gcc", CXX = "/opt/rh/devtoolset-8/root/usr/bin/g++" } +# have to give in one-line as toml does not allow multi-line here +environment = {PATH = "/opt/aarch64-linux-gnu/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++"} repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] From 8f3d62316db93838890a5f9abd832664fe06a39b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 17:01:29 +0530 Subject: [PATCH 016/182] switchg to curl --- quaddtype/pyproject.toml | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 742b458a..ba4dd743 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -34,27 +34,44 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ set -ex +# Function to download with curl and fallback to Python if curl fails +download_file() { + if ! curl -L -o "$2" "$1"; then + python -c "import urllib.request; urllib.request.urlretrieve('$1', '$2')" + fi +} + # Download and install a standalone GCC -wget https://github.com/Aetherinox/gcc-arm64/releases/download/12.3.1-2023.10/aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz -tar xf aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz -C /opt +GCC_URL="https://github.com/Aetherinox/gcc-arm64/releases/download/12.3.1-2023.10/aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz" +download_file "$GCC_URL" "gcc.tar.xz" +tar xf gcc.tar.xz -C /opt || echo "Failed to extract GCC" export PATH="/opt/aarch64-linux-gnu/bin:$PATH" # Install Miniconda and sleef -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -bash miniconda.sh -b -p $HOME/miniconda +MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" +download_file "$MINICONDA_URL" "miniconda.sh" +bash miniconda.sh -b -p $HOME/miniconda || echo "Failed to install Miniconda" export PATH="$HOME/miniconda/bin:$PATH" -conda install -y -c conda-forge sleef +conda install -y -c conda-forge sleef || echo "Failed to install sleef" # Verify sleef installation ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" + +# Print environment information for debugging +echo "PATH: $PATH" +echo "GCC version:" +gcc --version || echo "GCC not found" +echo "Python version:" +python --version +echo "Conda version:" +conda --version """ -# have to give in one-line as toml does not allow multi-line here -environment = {PATH = "/opt/aarch64-linux-gnu/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++"} +environment = { PATH = "/opt/aarch64-linux-gnu/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++" } repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh +curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda install -y -c conda-forge sleef From 667aabc8dc9a1120ce925fcbcac43a4c6d9a72c1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 17:05:35 +0530 Subject: [PATCH 017/182] using abs paths for linux paths --- quaddtype/pyproject.toml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index ba4dd743..fcd0e224 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -45,36 +45,32 @@ download_file() { GCC_URL="https://github.com/Aetherinox/gcc-arm64/releases/download/12.3.1-2023.10/aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz" download_file "$GCC_URL" "gcc.tar.xz" tar xf gcc.tar.xz -C /opt || echo "Failed to extract GCC" -export PATH="/opt/aarch64-linux-gnu/bin:$PATH" # Install Miniconda and sleef MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" download_file "$MINICONDA_URL" "miniconda.sh" bash miniconda.sh -b -p $HOME/miniconda || echo "Failed to install Miniconda" -export PATH="$HOME/miniconda/bin:$PATH" -conda install -y -c conda-forge sleef || echo "Failed to install sleef" +$HOME/miniconda/bin/conda install -y -c conda-forge sleef || echo "Failed to install sleef" # Verify sleef installation ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" # Print environment information for debugging -echo "PATH: $PATH" echo "GCC version:" -gcc --version || echo "GCC not found" +/opt/aarch64-linux-gnu/bin/gcc --version || echo "GCC not found" echo "Python version:" python --version echo "Conda version:" -conda --version +$HOME/miniconda/bin/conda --version """ -environment = { PATH = "/opt/aarch64-linux-gnu/bin:$HOME/miniconda/bin:$PATH", LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++" } +environment = { LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++" } repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh bash miniconda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -conda install -y -c conda-forge sleef +$HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" """ 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" } From 590b6822a921131a3b66a677032fa73a5d8be140 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 17:44:08 +0530 Subject: [PATCH 018/182] switching to auditool for linux --- quaddtype/pyproject.toml | 57 ++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index fcd0e224..c59643b9 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "mesonpy" name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" -readme = "README.md" +readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" dependencies = [ @@ -26,55 +26,36 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] -skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*"] -manylinux-x86_64-image = "manylinux2014" +skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] test-command = "pytest {project}/tests" test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ -set -ex -# Function to download with curl and fallback to Python if curl fails -download_file() { - if ! curl -L -o "$2" "$1"; then - python -c "import urllib.request; urllib.request.urlretrieve('$1', '$2')" - fi -} - -# Download and install a standalone GCC -GCC_URL="https://github.com/Aetherinox/gcc-arm64/releases/download/12.3.1-2023.10/aarch64-linux-gnu-12.3.1-2023.10-x86_64-linux.tar.xz" -download_file "$GCC_URL" "gcc.tar.xz" -tar xf gcc.tar.xz -C /opt || echo "Failed to extract GCC" - -# Install Miniconda and sleef -MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" -download_file "$MINICONDA_URL" "miniconda.sh" -bash miniconda.sh -b -p $HOME/miniconda || echo "Failed to install Miniconda" -$HOME/miniconda/bin/conda install -y -c conda-forge sleef || echo "Failed to install sleef" - -# Verify sleef installation -ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" - -# Print environment information for debugging -echo "GCC version:" -/opt/aarch64-linux-gnu/bin/gcc --version || echo "GCC not found" -echo "Python version:" -python --version -echo "Conda version:" -$HOME/miniconda/bin/conda --version +yum install -y wget && +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && +bash miniconda.sh -b -p $HOME/miniconda && +$HOME/miniconda/bin/conda install -y -c conda-forge sleef +ls -l $HOME/miniconda/include/sleef.h """ -environment = { LD_LIBRARY_PATH = "/opt/aarch64-linux-gnu/lib:$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRARY_PATH = "$HOME/miniconda/lib:$LIBRARY_PATH", CFLAGS = "-I$HOME/miniconda/include -fPIC $CFLAGS", CXXFLAGS = "-I$HOME/miniconda/include -fPIC $CXXFLAGS", LDFLAGS = "-L$HOME/miniconda/lib $LDFLAGS", AUDITWHEEL_PLAT = "manylinux2014_x86_64", CC = "/opt/aarch64-linux-gnu/bin/gcc", CXX = "/opt/aarch64-linux-gnu/bin/g++" } +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" } repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ -curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh -bash miniconda.sh -b -p $HOME/miniconda +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && +bash miniconda.sh -b -p $HOME/miniconda && $HOME/miniconda/bin/conda install -y -c conda-forge sleef -ls -l $HOME/miniconda/include/sleef.h || echo "sleef.h not found" +ls -l $HOME/miniconda/include/sleef.h """ -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" } +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"} [tool.cibuildwheel.windows] +before-all = """ +powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" && +start /wait "" miniconda.exe /S /D=%UserProfile%\\Miniconda3 && +%UserProfile%\\Miniconda3\\Scripts\\conda install -y -c conda-forge sleef +""" before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" \ No newline at end of file +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" +environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file From 5258efa5fcb6e5ef4a6b1fa262342e0bdd2dca0b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 17:49:08 +0530 Subject: [PATCH 019/182] fixing syntax issue --- quaddtype/pyproject.toml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index c59643b9..2a6e0d0d 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -32,9 +32,10 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = """ -yum install -y wget && -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && -bash miniconda.sh -b -p $HOME/miniconda && +set -ex +yum install -y wget +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh +bash miniconda.sh -b -p $HOME/miniconda $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h """ @@ -43,8 +44,8 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" [tool.cibuildwheel.macos] before-all = """ -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh && -bash miniconda.sh -b -p $HOME/miniconda && +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh +bash miniconda.sh -b -p $HOME/miniconda $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h """ @@ -52,8 +53,8 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB [tool.cibuildwheel.windows] before-all = """ -powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" && -start /wait "" miniconda.exe /S /D=%UserProfile%\\Miniconda3 && +powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" +start /wait "" miniconda.exe /S /D=%UserProfile%\\Miniconda3 %UserProfile%\\Miniconda3\\Scripts\\conda install -y -c conda-forge sleef """ before-build = "pip install delvewheel" From 62be500b47ec2e2b596242310066dd8a93bfe438 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 17:58:28 +0530 Subject: [PATCH 020/182] switching to manylinux_2_28_x86_64 --- quaddtype/pyproject.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 2a6e0d0d..60ef298a 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -40,7 +40,7 @@ $HOME/miniconda/bin/conda install -y -c conda-forge sleef ls -l $HOME/miniconda/include/sleef.h """ 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" } -repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" +repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] before-all = """ @@ -52,11 +52,12 @@ ls -l $HOME/miniconda/include/sleef.h 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"} [tool.cibuildwheel.windows] -before-all = """ -powershell -Command "Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe" -start /wait "" miniconda.exe /S /D=%UserProfile%\\Miniconda3 -%UserProfile%\\Miniconda3\\Scripts\\conda install -y -c conda-forge sleef -""" +before-all = [ + "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", + "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", + "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file From 12d509256ff18554d798d33f9bc816e98daafce0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 18:04:20 +0530 Subject: [PATCH 021/182] fixing testing environment issues --- quaddtype/pyproject.toml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 60ef298a..123ce3fc 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -26,9 +26,17 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] -skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"] -test-command = "pytest {project}/tests" +skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*"] +test-command = """ +python -c "import platform; print('Python version:', platform.python_version())" +python -c "import sys; print('sys.platform:', sys.platform)" +ldd --version +uname -a +pip install {package}[test] +pytest {project}/tests +""" test-extras = ["test"] +manylinux-x86_64-image = "manylinux_2_28" [tool.cibuildwheel.linux] before-all = """ From 607ef05ed81ae9cd878f1dbac7642563b4d81888 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 18:19:39 +0530 Subject: [PATCH 022/182] commenting windows for now --- quaddtype/pyproject.toml | 47 +++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 123ce3fc..1a64ec3b 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -30,7 +30,6 @@ skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*"] test-command = """ python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" -ldd --version uname -a pip install {package}[test] pytest {project}/tests @@ -44,7 +43,17 @@ set -ex yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda -$HOME/miniconda/bin/conda install -y -c conda-forge sleef +export PATH="$HOME/miniconda/bin:$PATH" +conda init bash +source ~/.bashrc +conda config --set always_yes yes --set changeps1 no +conda update -q conda +conda info -a +conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi ls -l $HOME/miniconda/include/sleef.h """ 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" } @@ -52,20 +61,32 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x8 [tool.cibuildwheel.macos] before-all = """ +set -ex wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda -$HOME/miniconda/bin/conda install -y -c conda-forge sleef +export PATH="$HOME/miniconda/bin:$PATH" +conda init bash +source ~/.bash_profile +conda config --set always_yes yes --set changeps1 no +conda update -q conda +conda info -a +conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi ls -l $HOME/miniconda/include/sleef.h """ 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"} +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" -[tool.cibuildwheel.windows] -before-all = [ - "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", - "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" -] -before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" -environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file +# [tool.cibuildwheel.windows] +# before-all = [ +# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", +# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", +# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", +# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +# ] +# before-build = "pip install delvewheel" +# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" +# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file From 3677bcce30a5bb090281e336c954eb9a6d49140b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 18:23:04 +0530 Subject: [PATCH 023/182] removing windows --- .github/workflows/build_wheels_and_release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index a31b44ec..86164465 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, windows-2019, macos-11] + os: [ubuntu-20.04, macos-11] steps: - uses: actions/checkout@v2 @@ -31,7 +31,7 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse env: - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD_VERBOSITY: '1' working-directory: ./quaddtype - uses: actions/upload-artifact@v2 @@ -44,7 +44,7 @@ jobs: needs: build_wheels runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - + steps: - name: Checkout code uses: actions/checkout@v2 @@ -73,4 +73,4 @@ jobs: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./artifacts/wheels/*.whl asset_name: quaddtype-${{ github.ref_name }}.whl - asset_content_type: application/zip \ No newline at end of file + asset_content_type: application/zip From 6b0d1f6517afd1143a87a702a6f170b986a009b5 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 21:19:11 +0530 Subject: [PATCH 024/182] switching to macos-latest in workflow --- .github/workflows/build_wheels_and_release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 86164465..c1d93ee6 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -5,7 +5,7 @@ on: branches: - main tags: - - 'v*' + - "v*" pull_request: jobs: @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-11] + os: [ubuntu-20.04, macos-latest] steps: - uses: actions/checkout@v2 @@ -22,7 +22,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.10' + python-version: "3.10" - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 @@ -31,7 +31,7 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse env: - CIBW_BUILD_VERBOSITY: '1' + CIBW_BUILD_VERBOSITY: "1" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 From f1052390d782b3bdb3883e6539d723860917c488 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 21:27:41 +0530 Subject: [PATCH 025/182] removing patchelf --- quaddtype/pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 1a64ec3b..e31fae23 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -2,7 +2,6 @@ requires = [ "meson>=1.3.2", "meson-python", - "patchelf", "wheel", "numpy" ] From 20746a5ba5f917c456c1f9962260b525f3d61e77 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 21:49:44 +0530 Subject: [PATCH 026/182] adding package-config file for sleef --- quaddtype/pyproject.toml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e31fae23..98f85965 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -61,7 +61,7 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x8 [tool.cibuildwheel.macos] before-all = """ set -ex -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash @@ -75,8 +75,24 @@ if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then exit 1 fi ls -l $HOME/miniconda/include/sleef.h + +# Adding a pkg-config file for SLEEF +cat << EOF > $HOME/miniconda/lib/pkgconfig/sleef.pc +prefix=$HOME/miniconda +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: SLEEF +Description: SLEEF library +Version: 3.5.1 +Libs: -L${libdir} -lsleef +Cflags: -I${includedir} +EOF + + +export PKG_CONFIG_PATH="$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH" """ -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"} +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"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From d475bee10a80efaddb5792d3462a6690537f5876 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 22:23:03 +0530 Subject: [PATCH 027/182] sleef dep by pkg-config first --- quaddtype/meson.build | 37 ++++++++++++++++++++++++++----------- quaddtype/pyproject.toml | 13 +++++++------ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index e4aa4a98..55936843 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -8,16 +8,29 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -# Add conda lib directory to library path +message('Conda prefix: ' + conda_prefix) + +# Add conda lib and include directories add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) +add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) -sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +# Try to find SLEEF using pkg-config first +sleef_dep = dependency('sleef', required: false) -if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') +if not sleef_dep.found() + # If pkg-config fails, try to find the library manually + sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) + sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) + + if not sleef_dep.found() or not sleefquad_dep.found() + error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') + endif +else + sleefquad_dep = sleef_dep endif +message('SLEEF library found: ' + sleef_dep.found().to_string()) + incdir_numpy = run_command(py, [ '-c', @@ -30,6 +43,7 @@ includes = include_directories( [ incdir_numpy, 'quaddtype/src', + conda_prefix + '/include', ] ) @@ -57,10 +71,11 @@ py.install_sources( ) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'quaddtype', -include_directories: includes + srcs, + c_args: ['-g', '-O0'], + link_args: ['-lsleef', '-lsleefquad'], + dependencies: [sleef_dep, sleefquad_dep], + install: true, + subdir: 'quaddtype', + include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 98f85965..ed747976 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -69,14 +69,15 @@ source ~/.bash_profile conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a -conda install -y -c conda-forge sleef +conda install -y -c conda-forge sleef pkg-config if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then echo "sleef.h not found. Installation may have failed." exit 1 fi ls -l $HOME/miniconda/include/sleef.h +ls -l $HOME/miniconda/lib/libsleef* -# Adding a pkg-config file for SLEEF +# Create a pkg-config file for SLEEF cat << EOF > $HOME/miniconda/lib/pkgconfig/sleef.pc prefix=$HOME/miniconda libdir=${prefix}/lib @@ -85,14 +86,14 @@ includedir=${prefix}/include Name: SLEEF Description: SLEEF library Version: 3.5.1 -Libs: -L${libdir} -lsleef +Libs: -L${libdir} -lsleef -lsleefquad Cflags: -I${includedir} EOF - -export PKG_CONFIG_PATH="$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH" +export PKG_CONFIG_PATH="$HOME/minoconda/lib/pkgconfig:$PKG_CONFIG_PATH" +pkg-config --libs --cflags sleef """ -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"} +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", CONDA_PREFIX = "$HOME/miniconda"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 6fb2df3aaa9827a462ee4cfe3604eb3925b3d348 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 22:33:16 +0530 Subject: [PATCH 028/182] fixing macos sleef not found --- quaddtype/meson.build | 38 ++++++++++++-------------------------- quaddtype/pyproject.toml | 2 +- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 55936843..56b20e61 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -8,29 +8,17 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -message('Conda prefix: ' + conda_prefix) - -# Add conda lib and include directories +# Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) +add_project_link_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -# Try to find SLEEF using pkg-config first -sleef_dep = dependency('sleef', required: false) +sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) +sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) -if not sleef_dep.found() - # If pkg-config fails, try to find the library manually - sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) - sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) - - if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') - endif -else - sleefquad_dep = sleef_dep +if not sleef_dep.found() or not sleefquad_dep.found() + error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') endif -message('SLEEF library found: ' + sleef_dep.found().to_string()) - incdir_numpy = run_command(py, [ '-c', @@ -43,7 +31,6 @@ includes = include_directories( [ incdir_numpy, 'quaddtype/src', - conda_prefix + '/include', ] ) @@ -71,11 +58,10 @@ py.install_sources( ) py.extension_module('_quaddtype_main', - srcs, - c_args: ['-g', '-O0'], - link_args: ['-lsleef', '-lsleefquad'], - dependencies: [sleef_dep, sleefquad_dep], - install: true, - subdir: 'quaddtype', - include_directories: includes +srcs, +c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], +dependencies: [sleef_dep, sleefquad_dep], +install: true, +subdir: 'quaddtype', +include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index ed747976..46ba3de2 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -93,7 +93,7 @@ EOF export PKG_CONFIG_PATH="$HOME/minoconda/lib/pkgconfig:$PKG_CONFIG_PATH" pkg-config --libs --cflags sleef """ -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", CONDA_PREFIX = "$HOME/miniconda"} +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"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 7962f5d67e1343c55105140ea7af1fd5fd6bebfd Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 22:43:46 +0530 Subject: [PATCH 029/182] simplifying process and using pkg-config --- quaddtype/meson.build | 46 ++++++++++++++++++++-------------------- quaddtype/pyproject.toml | 40 +--------------------------------- 2 files changed, 24 insertions(+), 62 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 56b20e61..2181a1bd 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -8,30 +8,33 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -# Add conda lib directory to library path +# Add conda lib and include directories add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -add_project_link_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) +add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) -sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +# Use pkg-config to find SLEEF +pkg = import('pkgconfig') +sleef_dep = pkg.dependency('sleef', required: false) -if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') +if not sleef_dep.found() + # Fallback to manual library detection + sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) + sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) + + if not sleef_dep.found() or not sleefquad_dep.found() + error('SLEEF library not found. Please ensure it is installed in your conda environment.') + endif +else + sleefquad_dep = sleef_dep endif incdir_numpy = run_command(py, - [ - '-c', - 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' - ], + ['-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))'], check: true ).stdout().strip() includes = include_directories( - [ - incdir_numpy, - 'quaddtype/src', - ] + [incdir_numpy, 'quaddtype/src'] ) srcs = [ @@ -50,18 +53,15 @@ srcs = [ ] py.install_sources( - [ - 'quaddtype/__init__.py', - ], + ['quaddtype/__init__.py'], subdir: 'quaddtype', pure: false ) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'quaddtype', -include_directories: includes + srcs, + dependencies: [sleef_dep, sleefquad_dep], + install: true, + subdir: 'quaddtype', + include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 46ba3de2..8f694456 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -49,11 +49,6 @@ conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a conda install -y -c conda-forge sleef -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h """ 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" } 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 conda update -q conda conda info -a conda install -y -c conda-forge sleef pkg-config -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h -ls -l $HOME/miniconda/lib/libsleef* - -# Create a pkg-config file for SLEEF -cat << EOF > $HOME/miniconda/lib/pkgconfig/sleef.pc -prefix=$HOME/miniconda -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: SLEEF -Description: SLEEF library -Version: 3.5.1 -Libs: -L${libdir} -lsleef -lsleefquad -Cflags: -I${includedir} -EOF - -export PKG_CONFIG_PATH="$HOME/minoconda/lib/pkgconfig:$PKG_CONFIG_PATH" -pkg-config --libs --cflags sleef """ 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"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" - -# [tool.cibuildwheel.windows] -# before-all = [ -# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", -# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", -# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", -# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" -# ] -# before-build = "pip install delvewheel" -# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" -# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From f6c67008ebdcff65e2f0f8a84453a8c0833b7852 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 22:47:28 +0530 Subject: [PATCH 030/182] typo fix --- quaddtype/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 2181a1bd..41183ce5 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -13,8 +13,8 @@ add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) # Use pkg-config to find SLEEF -pkg = import('pkgconfig') -sleef_dep = pkg.dependency('sleef', required: false) +pkgconfig = import('pkgconfig') +sleef_dep = dependency('sleef', required : false) if not sleef_dep.found() # Fallback to manual library detection From c98744bad75baa70c6cb5fe92c468b0b82880c53 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 22:55:24 +0530 Subject: [PATCH 031/182] trying some tweaks --- quaddtype/meson.build | 4 ++-- quaddtype/pyproject.toml | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 41183ce5..8c3a2890 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -12,7 +12,7 @@ conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdo add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -# Use pkg-config to find SLEEF +# Try to use pkg-config first pkgconfig = import('pkgconfig') sleef_dep = dependency('sleef', required : false) @@ -34,7 +34,7 @@ incdir_numpy = run_command(py, ).stdout().strip() includes = include_directories( - [incdir_numpy, 'quaddtype/src'] + [incdir_numpy, 'quaddtype/src', conda_prefix + '/include'] ) srcs = [ diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 8f694456..4b3aca01 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -1,10 +1,5 @@ [build-system] -requires = [ - "meson>=1.3.2", - "meson-python", - "wheel", - "numpy" -] +requires = ["meson>=1.3.2", "meson-python", "wheel", "numpy"] build-backend = "mesonpy" [project] @@ -14,14 +9,10 @@ version = "0.0.1" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" -dependencies = [ - "numpy" -] +dependencies = ["numpy"] [project.optional-dependencies] -test = [ - "pytest", -] +test = ["pytest"] [tool.cibuildwheel] archs = ["auto64"] @@ -48,9 +39,12 @@ source ~/.bashrc conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a -conda install -y -c conda-forge sleef +conda install -y -c conda-forge sleef pkg-config +pkg-config --version +echo $PKG_CONFIG_PATH +ls -l $HOME/miniconda/lib/pkgconfig """ -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" } +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", PKG_CONFIG_PATH = "$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH", PATH = "$HOME/miniconda/bin:$PATH" } repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] @@ -65,6 +59,9 @@ conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a conda install -y -c conda-forge sleef pkg-config +pkg-config --version +echo $PKG_CONFIG_PATH +ls -l $HOME/miniconda/lib/pkgconfig """ -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"} +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", PATH = "$HOME/miniconda/bin:$PATH" } repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From a1ccfc7afc4b46a3cee1779601e90d3c0d29dcc9 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 23:07:57 +0530 Subject: [PATCH 032/182] testing CI --- .../workflows/build_wheels_and_release.yml | 2 +- quaddtype/meson.build | 45 ++++++++------- quaddtype/pyproject.toml | 55 ++++++++++++++----- 3 files changed, 63 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index c1d93ee6..9f997d79 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels and release on: push: branches: - - main + - testing-pkg tags: - "v*" pull_request: diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 8c3a2890..e4aa4a98 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -8,33 +8,29 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -# Add conda lib and include directories +# Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -# Try to use pkg-config first -pkgconfig = import('pkgconfig') -sleef_dep = dependency('sleef', required : false) +sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) +sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) -if not sleef_dep.found() - # Fallback to manual library detection - sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) - sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) - - if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment.') - endif -else - sleefquad_dep = sleef_dep +if not sleef_dep.found() or not sleefquad_dep.found() + error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') endif incdir_numpy = run_command(py, - ['-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))'], + [ + '-c', + 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' + ], check: true ).stdout().strip() includes = include_directories( - [incdir_numpy, 'quaddtype/src', conda_prefix + '/include'] + [ + incdir_numpy, + 'quaddtype/src', + ] ) srcs = [ @@ -53,15 +49,18 @@ srcs = [ ] py.install_sources( - ['quaddtype/__init__.py'], + [ + 'quaddtype/__init__.py', + ], subdir: 'quaddtype', pure: false ) py.extension_module('_quaddtype_main', - srcs, - dependencies: [sleef_dep, sleefquad_dep], - install: true, - subdir: 'quaddtype', - include_directories: includes +srcs, +c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], +dependencies: [sleef_dep, sleefquad_dep], +install: true, +subdir: 'quaddtype', +include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 4b3aca01..1a64ec3b 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -1,5 +1,11 @@ [build-system] -requires = ["meson>=1.3.2", "meson-python", "wheel", "numpy"] +requires = [ + "meson>=1.3.2", + "meson-python", + "patchelf", + "wheel", + "numpy" +] build-backend = "mesonpy" [project] @@ -9,10 +15,14 @@ version = "0.0.1" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" -dependencies = ["numpy"] +dependencies = [ + "numpy" +] [project.optional-dependencies] -test = ["pytest"] +test = [ + "pytest", +] [tool.cibuildwheel] archs = ["auto64"] @@ -39,18 +49,20 @@ source ~/.bashrc conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a -conda install -y -c conda-forge sleef pkg-config -pkg-config --version -echo $PKG_CONFIG_PATH -ls -l $HOME/miniconda/lib/pkgconfig +conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi +ls -l $HOME/miniconda/include/sleef.h """ -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", PKG_CONFIG_PATH = "$HOME/miniconda/lib/pkgconfig:$PKG_CONFIG_PATH", PATH = "$HOME/miniconda/bin:$PATH" } +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" } repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] before-all = """ set -ex -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -O miniconda.sh +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash @@ -58,10 +70,23 @@ source ~/.bash_profile conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a -conda install -y -c conda-forge sleef pkg-config -pkg-config --version -echo $PKG_CONFIG_PATH -ls -l $HOME/miniconda/lib/pkgconfig +conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi +ls -l $HOME/miniconda/include/sleef.h """ -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", PATH = "$HOME/miniconda/bin:$PATH" } -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file +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"} +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" + +# [tool.cibuildwheel.windows] +# before-all = [ +# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", +# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", +# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", +# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +# ] +# before-build = "pip install delvewheel" +# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" +# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file From 59c358573aa92cb4af643fe7f7bc9e04f0ae5f04 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 23:11:20 +0530 Subject: [PATCH 033/182] removed patchelf --- .github/workflows/build_wheels_and_release.yml | 2 +- quaddtype/pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 9f997d79..c42ec3d3 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-latest] + os: [ubuntu-20.04] steps: - uses: actions/checkout@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 1a64ec3b..e31fae23 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -2,7 +2,6 @@ requires = [ "meson>=1.3.2", "meson-python", - "patchelf", "wheel", "numpy" ] From cb175bcf6082d9ddc6337fbc5fcccaca2bfb90ff Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 23:25:49 +0530 Subject: [PATCH 034/182] only macos --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index c42ec3d3..7fb8cd3d 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04] + os: [macos-latest] steps: - uses: actions/checkout@v2 From 6f8e40cd74e5089b7d4da4c4c0a6acb77d6fc07c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 23:36:39 +0530 Subject: [PATCH 035/182] adding support for macos-arm --- quaddtype/meson.build | 16 ++++++++++++++-- quaddtype/pyproject.toml | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index e4aa4a98..4d79b44d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -7,12 +7,24 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +is_macos = build_machine.system() == 'darwin' # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) -sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +if is_macos + sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() + sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() + + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) + add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) + + sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) + sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) +else + sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) + sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +endif if not sleef_dep.found() or not sleefquad_dep.found() error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e31fae23..633ab6c3 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -61,7 +61,7 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x8 [tool.cibuildwheel.macos] before-all = """ set -ex -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash @@ -75,8 +75,9 @@ if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then exit 1 fi ls -l $HOME/miniconda/include/sleef.h +ls -l $HOME/miniconda/lib/libsleef* """ -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"} +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 75179ba717a4d7319a79f6e6e0ca5e0c392d42c9 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Fri, 23 Aug 2024 23:54:40 +0530 Subject: [PATCH 036/182] pushing fixes for Py3.13 --- quaddtype/meson.build | 24 ++++++++++++++++++------ quaddtype/pyproject.toml | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 4d79b44d..c2f9ed7c 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -3,6 +3,18 @@ project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true py_mod = import('python') py = py_mod.find_installation() +py_version = py.language_version() +message('Python version: ' + py_version) + +if py_version.version_compare('>=3.13') + py_dep = declare_dependency( + include_directories: py.get_path('include'), + link_args: ['-L' + py.get_path('stdlib'), '-lpython' + py_version] + ) +else + py_dep = py.dependency(required: true) +endif + c = meson.get_compiler('c') # Get the conda prefix @@ -69,10 +81,10 @@ py.install_sources( ) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'quaddtype', -include_directories: includes + srcs, + c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], + dependencies: [sleef_dep, sleefquad_dep, py_dep], + install: true, + subdir: 'quaddtype', + include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 633ab6c3..3235e02c 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -77,7 +77,7 @@ fi ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* """ -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", PYTHON_LIBRARY = "$HOME/miniconda/lib"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 6d958fcc9012939b2746fc6fad68e72abdc534b7 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 00:19:54 +0530 Subject: [PATCH 037/182] supporting till 3.12 --- .../workflows/build_wheels_and_release.yml | 31 ++++++++++--------- quaddtype/meson.build | 24 ++++---------- quaddtype/pyproject.toml | 15 ++++++--- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 7fb8cd3d..472df547 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,15 +14,16 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest] + os: [ubuntu-latest, macos-latest] + python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 @@ -31,13 +32,15 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse env: + CIBW_BUILD: cp3${{ matrix.python-version == '3.10' && '10' || (matrix.python-version == '3.11' && '11' || '12') }}-* + CIBW_ARCHS_MACOS: "x86_64 arm64" CIBW_BUILD_VERBOSITY: "1" working-directory: ./quaddtype - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./quaddtype/wheelhouse/*.whl - name: wheels + name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} create_release: name: Create Release @@ -47,10 +50,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: artifacts @@ -66,11 +69,9 @@ jobs: prerelease: false - name: Upload Release Assets - uses: actions/upload-release-asset@v1 + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ./artifacts/**/*.whl env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./artifacts/wheels/*.whl - asset_name: quaddtype-${{ github.ref_name }}.whl - asset_content_type: application/zip diff --git a/quaddtype/meson.build b/quaddtype/meson.build index c2f9ed7c..4d79b44d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -3,18 +3,6 @@ project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true py_mod = import('python') py = py_mod.find_installation() -py_version = py.language_version() -message('Python version: ' + py_version) - -if py_version.version_compare('>=3.13') - py_dep = declare_dependency( - include_directories: py.get_path('include'), - link_args: ['-L' + py.get_path('stdlib'), '-lpython' + py_version] - ) -else - py_dep = py.dependency(required: true) -endif - c = meson.get_compiler('c') # Get the conda prefix @@ -81,10 +69,10 @@ py.install_sources( ) py.extension_module('_quaddtype_main', - srcs, - c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], - dependencies: [sleef_dep, sleefquad_dep, py_dep], - install: true, - subdir: 'quaddtype', - include_directories: includes +srcs, +c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], +dependencies: [sleef_dep, sleefquad_dep], +install: true, +subdir: 'quaddtype', +include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 3235e02c..92480b34 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -13,7 +13,7 @@ description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] -requires-python = ">=3.10.0" +requires-python = ">=3.10.0, <3.13" dependencies = [ "numpy" ] @@ -25,7 +25,7 @@ test = [ [tool.cibuildwheel] archs = ["auto64"] -skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*"] +skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] test-command = """ python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" @@ -59,9 +59,16 @@ environment = { LD_LIBRARY_PATH = "$HOME/miniconda/lib:$LD_LIBRARY_PATH", LIBRAR repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] +archs = ["x86_64", "arm64"] before-all = """ set -ex -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -O miniconda.sh +ARCH=$(uname -m) +if [ "$ARCH" = "arm64" ]; then + MINICONDA_ARCH="arm64" +else + MINICONDA_ARCH="x86_64" +fi +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${MINICONDA_ARCH}.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash @@ -77,7 +84,7 @@ fi ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* """ -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", PYTHON_LIBRARY = "$HOME/miniconda/lib"} +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 8e9f3697e5fe7ac6a2c4ff04e87aa487441a3fcc Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 00:27:00 +0530 Subject: [PATCH 038/182] switching back to prev --- quaddtype/meson.build | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 4d79b44d..e4aa4a98 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -7,24 +7,12 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -is_macos = build_machine.system() == 'darwin' # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -if is_macos - sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() - sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() - - add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) - add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) - - sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) - sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) -else - sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) - sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) -endif +sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) +sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) if not sleef_dep.found() or not sleefquad_dep.found() error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') From 3a3d38fd816a639e946b4cabb603c2a02d94183d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 00:37:31 +0530 Subject: [PATCH 039/182] fixing x86 & arm for mac --- quaddtype/meson.build | 16 +++++++++++++-- quaddtype/pyproject.toml | 44 +++++++++++----------------------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index e4aa4a98..4d79b44d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -7,12 +7,24 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +is_macos = build_machine.system() == 'darwin' # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) -sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +if is_macos + sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() + sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() + + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) + add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) + + sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) + sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) +else + sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) + sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +endif if not sleef_dep.found() or not sleefquad_dep.found() error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 92480b34..7a9fd0d8 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -1,43 +1,34 @@ [build-system] -requires = [ - "meson>=1.3.2", - "meson-python", - "wheel", - "numpy" -] +requires = ["meson>=1.3.2", "meson-python", "wheel", "numpy"] build-backend = "mesonpy" [project] name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" -readme = 'README.md' +readme = "README.md" authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0, <3.13" -dependencies = [ - "numpy" -] +dependencies = ["numpy"] [project.optional-dependencies] -test = [ - "pytest", -] +test = ["pytest"] [tool.cibuildwheel] archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] -test-command = """ +test-command = ''' python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" uname -a pip install {package}[test] pytest {project}/tests -""" +''' test-extras = ["test"] manylinux-x86_64-image = "manylinux_2_28" [tool.cibuildwheel.linux] -before-all = """ +before-all = ''' set -ex yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh @@ -54,13 +45,13 @@ if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then exit 1 fi ls -l $HOME/miniconda/include/sleef.h -""" +''' 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" } repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] -before-all = """ +before-all = ''' set -ex ARCH=$(uname -m) if [ "$ARCH" = "arm64" ]; then @@ -83,17 +74,6 @@ if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then fi ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* -""" -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" - -# [tool.cibuildwheel.windows] -# before-all = [ -# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", -# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", -# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", -# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" -# ] -# before-build = "pip install delvewheel" -# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" -# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file +''' +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib" } +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From b054b45acae0af71237ca42210839acb55045aef Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 00:45:15 +0530 Subject: [PATCH 040/182] fixing workflow --- .../workflows/build_wheels_and_release.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 472df547..b66b13c5 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -10,12 +10,23 @@ on: jobs: build_wheels: - name: Build wheels on ${{ matrix.os }} + name: Build wheels on ${{ matrix.os }} ${{ matrix.arch }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest] python-version: ["3.10", "3.11", "3.12"] + arch: [x86_64] + include: + - os: macos-latest + arch: arm64 + python-version: "3.10" + - os: macos-latest + arch: arm64 + python-version: "3.11" + - os: macos-latest + arch: arm64 + python-version: "3.12" steps: - uses: actions/checkout@v3 @@ -33,14 +44,16 @@ jobs: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: cp3${{ matrix.python-version == '3.10' && '10' || (matrix.python-version == '3.11' && '11' || '12') }}-* - CIBW_ARCHS_MACOS: "x86_64 arm64" + CIBW_ARCHS: ${{ matrix.arch }} CIBW_BUILD_VERBOSITY: "1" working-directory: ./quaddtype - uses: actions/upload-artifact@v3 with: path: ./quaddtype/wheelhouse/*.whl - name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} + name: wheels-${{ matrix.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} + + # ... rest of the workflow remains the same create_release: name: Create Release From ec2d2ec9ab518b11d407a692a5ba1ed6707c574e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:19:48 +0530 Subject: [PATCH 041/182] fixing workflow --- .../workflows/build_wheels_and_release.yml | 66 ++++------------- quaddtype/meson.build | 71 +++++-------------- quaddtype/pyproject.toml | 41 ++++------- 3 files changed, 45 insertions(+), 133 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index b66b13c5..be49a4c0 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -2,88 +2,46 @@ name: Build quaddtype wheels and release on: push: - branches: - - testing-pkg - tags: - - "v*" + branches: [testing-pkg] + tags: ["v*"] pull_request: jobs: build_wheels: - name: Build wheels on ${{ matrix.os }} ${{ matrix.arch }} + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-13, macos-14] python-version: ["3.10", "3.11", "3.12"] - arch: [x86_64] - include: - - os: macos-latest - arch: arm64 - python-version: "3.10" - - os: macos-latest - arch: arm64 - python-version: "3.11" - - os: macos-latest - arch: arm64 - python-version: "3.12" steps: - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse + uses: pypa/cibuildwheel@v2.20.0 env: CIBW_BUILD: cp3${{ matrix.python-version == '3.10' && '10' || (matrix.python-version == '3.11' && '11' || '12') }}-* - CIBW_ARCHS: ${{ matrix.arch }} + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_BUILD_VERBOSITY: "1" - working-directory: ./quaddtype - - uses: actions/upload-artifact@v3 with: - path: ./quaddtype/wheelhouse/*.whl - name: wheels-${{ matrix.os }}-${{ matrix.arch }}-py${{ matrix.python-version }} - - # ... rest of the workflow remains the same + path: ./wheelhouse/*.whl + name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} create_release: name: Create Release needs: build_wheels runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 with: path: artifacts - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.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/') + - uses: softprops/action-gh-release@v1 with: files: ./artifacts/**/*.whl env: diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 4d79b44d..c0121c6b 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -5,74 +5,39 @@ py = py_mod.find_installation() c = meson.get_compiler('c') -# Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() -is_macos = build_machine.system() == 'darwin' -# Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) +add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -if is_macos - sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() - sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() - - add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) - add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) - - sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) - sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) -else - sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) - sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) -endif +sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) +sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') + error('SLEEF library not found. Please ensure it is installed in your conda environment.') endif -incdir_numpy = run_command(py, - [ - '-c', - 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' - ], - check: true -).stdout().strip() +incdir_numpy = run_command(py, ['-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))'], check: true).stdout().strip() -includes = include_directories( - [ - incdir_numpy, - 'quaddtype/src', - ] -) +includes = include_directories([incdir_numpy, 'quaddtype/src']) srcs = [ - 'quaddtype/src/casts.h', - 'quaddtype/src/casts.cpp', - 'quaddtype/src/scalar.h', - 'quaddtype/src/scalar.c', - 'quaddtype/src/dtype.h', - 'quaddtype/src/dtype.c', + 'quaddtype/src/casts.h', 'quaddtype/src/casts.cpp', + 'quaddtype/src/scalar.h', 'quaddtype/src/scalar.c', + 'quaddtype/src/dtype.h', 'quaddtype/src/dtype.c', 'quaddtype/src/quaddtype_main.c', - 'quaddtype/src/scalar_ops.h', - 'quaddtype/src/scalar_ops.cpp', + 'quaddtype/src/scalar_ops.h', 'quaddtype/src/scalar_ops.cpp', 'quaddtype/src/ops.hpp', - 'quaddtype/src/umath.h', - 'quaddtype/src/umath.cpp' + 'quaddtype/src/umath.h', 'quaddtype/src/umath.cpp' ] -py.install_sources( - [ - 'quaddtype/__init__.py', - ], - subdir: 'quaddtype', - pure: false -) +py.install_sources(['quaddtype/__init__.py'], subdir: 'quaddtype', pure: false) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'quaddtype', -include_directories: includes + srcs, + c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], + dependencies: [sleef_dep, sleefquad_dep], + install: true, + subdir: 'quaddtype', + include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 7a9fd0d8..9285e34e 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -15,22 +15,19 @@ dependencies = ["numpy"] test = ["pytest"] [tool.cibuildwheel] -archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] -test-command = ''' +test-command = """ python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" uname -a pip install {package}[test] pytest {project}/tests -''' +""" test-extras = ["test"] -manylinux-x86_64-image = "manylinux_2_28" [tool.cibuildwheel.linux] before-all = ''' set -ex -yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" @@ -38,42 +35,34 @@ conda init bash source ~/.bashrc conda config --set always_yes yes --set changeps1 no conda update -q conda -conda info -a conda install -y -c conda-forge sleef -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h ''' 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" } repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" [tool.cibuildwheel.macos] -archs = ["x86_64", "arm64"] before-all = ''' set -ex ARCH=$(uname -m) -if [ "$ARCH" = "arm64" ]; then - MINICONDA_ARCH="arm64" -else - MINICONDA_ARCH="x86_64" -fi -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${MINICONDA_ARCH}.sh -O miniconda.sh +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash source ~/.bash_profile conda config --set always_yes yes --set changeps1 no conda update -q conda -conda info -a conda install -y -c conda-forge sleef -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h -ls -l $HOME/miniconda/lib/libsleef* ''' 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib" } -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" + +# [tool.cibuildwheel.windows] +# before-all = [ +# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", +# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", +# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", +# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +# ] +# before-build = "pip install delvewheel" +# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" +# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file From 899f256bcb2466fac9cd8c5e575c16d203af838b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:32:18 +0530 Subject: [PATCH 042/182] fixing workflow --- .../workflows/build_wheels_and_release.yml | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index be49a4c0..e8c62a0b 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -2,8 +2,10 @@ name: Build quaddtype wheels and release on: push: - branches: [testing-pkg] - tags: ["v*"] + branches: + - main + tags: + - "v*" pull_request: jobs: @@ -13,35 +15,60 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-13, macos-14] - python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + - name: Build wheels - uses: pypa/cibuildwheel@v2.20.0 + run: | + python -m cibuildwheel --output-dir wheelhouse env: - CIBW_BUILD: cp3${{ matrix.python-version == '3.10' && '10' || (matrix.python-version == '3.11' && '11' || '12') }}-* - CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_BUILD_VERBOSITY: "1" - - uses: actions/upload-artifact@v3 + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v2 with: - path: ./wheelhouse/*.whl - name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} + path: ./quaddtype/wheelhouse/*.whl + name: wheels-${{ matrix.os }} create_release: name: Create Release needs: build_wheels runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') + steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 with: path: artifacts - - uses: softprops/action-gh-release@v1 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.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: From ca8eda0560c9df11c539389140b6018ded4daf19 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:35:15 +0530 Subject: [PATCH 043/182] fixing workflow --- quaddtype/meson.build | 55 ++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index c0121c6b..e4aa4a98 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -5,39 +5,62 @@ py = py_mod.find_installation() c = meson.get_compiler('c') +# Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +# Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment.') + error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') endif -incdir_numpy = run_command(py, ['-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))'], check: true).stdout().strip() +incdir_numpy = run_command(py, + [ + '-c', + 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' + ], + check: true +).stdout().strip() -includes = include_directories([incdir_numpy, 'quaddtype/src']) +includes = include_directories( + [ + incdir_numpy, + 'quaddtype/src', + ] +) srcs = [ - 'quaddtype/src/casts.h', 'quaddtype/src/casts.cpp', - 'quaddtype/src/scalar.h', 'quaddtype/src/scalar.c', - 'quaddtype/src/dtype.h', 'quaddtype/src/dtype.c', + 'quaddtype/src/casts.h', + 'quaddtype/src/casts.cpp', + 'quaddtype/src/scalar.h', + 'quaddtype/src/scalar.c', + 'quaddtype/src/dtype.h', + 'quaddtype/src/dtype.c', 'quaddtype/src/quaddtype_main.c', - 'quaddtype/src/scalar_ops.h', 'quaddtype/src/scalar_ops.cpp', + 'quaddtype/src/scalar_ops.h', + 'quaddtype/src/scalar_ops.cpp', 'quaddtype/src/ops.hpp', - 'quaddtype/src/umath.h', 'quaddtype/src/umath.cpp' + 'quaddtype/src/umath.h', + 'quaddtype/src/umath.cpp' ] -py.install_sources(['quaddtype/__init__.py'], subdir: 'quaddtype', pure: false) +py.install_sources( + [ + 'quaddtype/__init__.py', + ], + subdir: 'quaddtype', + pure: false +) py.extension_module('_quaddtype_main', - srcs, - c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], - dependencies: [sleef_dep, sleefquad_dep], - install: true, - subdir: 'quaddtype', - include_directories: includes +srcs, +c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], +dependencies: [sleef_dep, sleefquad_dep], +install: true, +subdir: 'quaddtype', +include_directories: includes ) \ No newline at end of file From 9a5ba6249513c7acc1d758be7869c3853882f8b0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:38:28 +0530 Subject: [PATCH 044/182] fixing meson issues --- quaddtype/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index e4aa4a98..d8017cf4 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -10,6 +10,7 @@ conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdo # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) +add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) From 62de91d547983bc7c28fbf047c5157a97ffda6c6 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:39:18 +0530 Subject: [PATCH 045/182] fixing branch in workflow --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index e8c62a0b..a9924a6e 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels and release on: push: branches: - - main + - testing-pkg tags: - "v*" pull_request: From c2a7595deac845a4a0813a9b2d0f0e9249ee20d2 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:42:41 +0530 Subject: [PATCH 046/182] installing wget for linux --- quaddtype/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 9285e34e..eedcb260 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -28,6 +28,7 @@ test-extras = ["test"] [tool.cibuildwheel.linux] before-all = ''' set -ex +yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" From 543eaf72c846aa1d680227d15fa98195fc996296 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:51:23 +0530 Subject: [PATCH 047/182] simplifying to make it work --- quaddtype/meson.build | 17 ++++++++++++++--- quaddtype/pyproject.toml | 23 ++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index d8017cf4..4d79b44d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -7,13 +7,24 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +is_macos = build_machine.system() == 'darwin' # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -add_project_arguments('-I' + conda_prefix + '/include', language: ['c', 'cpp']) -sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) -sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +if is_macos + sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() + sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() + + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) + add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) + + sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) + sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) +else + sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) + sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) +endif if not sleef_dep.found() or not sleefquad_dep.found() error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index eedcb260..806155d7 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -34,9 +34,16 @@ bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" conda init bash source ~/.bashrc -conda config --set always_yes yes --set changeps1 no conda update -q conda +conda config --add channels conda-forge +conda config --set channel_priority strict conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi +ls -l $HOME/miniconda/include/sleef.h +ls -l $HOME/miniconda/lib/libsleef* ''' 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" } repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" @@ -48,13 +55,19 @@ ARCH=$(uname -m) wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" -conda init bash -source ~/.bash_profile -conda config --set always_yes yes --set changeps1 no +ource ~/.bash_profile conda update -q conda +conda config --add channels conda-forge +conda config --set channel_priority strict conda install -y -c conda-forge sleef +if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 +fi +ls -l $HOME/miniconda/include/sleef.h +ls -l $HOME/miniconda/lib/libsleef* ''' -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib" } +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From d6a98db229283378942a11891b6fc0178542860b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 01:55:42 +0530 Subject: [PATCH 048/182] fixing stupid typo --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 806155d7..0284a0f6 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -55,7 +55,7 @@ ARCH=$(uname -m) wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" -ource ~/.bash_profile +source ~/.bash_profile conda update -q conda conda config --add channels conda-forge conda config --set channel_priority strict From e924a0af6384a773147376877e157288721ea40c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:09:59 +0530 Subject: [PATCH 049/182] testing linux --- .../workflows/build_wheels_and_release.yml | 2 +- quaddtype/pyproject.toml | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index a9924a6e..24d235c5 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-13, macos-14] + os: [ubuntu-latest] steps: - uses: actions/checkout@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 0284a0f6..167aef5f 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -1,20 +1,32 @@ [build-system] -requires = ["meson>=1.3.2", "meson-python", "wheel", "numpy"] + +requires = [ + "meson>=1.3.2", + "meson-python", + "wheel", + "numpy" +] + build-backend = "mesonpy" [project] name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.1" -readme = "README.md" +readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] -requires-python = ">=3.10.0, <3.13" -dependencies = ["numpy"] +requires-python = ">=3.10.0" +dependencies = [ + "numpy" +] [project.optional-dependencies] -test = ["pytest"] +test = [ + "pytest", +] [tool.cibuildwheel] +archs = ["auto64"] skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] test-command = """ python -c "import platform; print('Python version:', platform.python_version())" @@ -24,6 +36,7 @@ pip install {package}[test] pytest {project}/tests """ test-extras = ["test"] +manylinux-x86_64-image = "manylinux_2_28" [tool.cibuildwheel.linux] before-all = ''' From 4cf263cbba457d07b8371b1663e865c8a3d30e82 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:13:20 +0530 Subject: [PATCH 050/182] testing macos-13 --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 24d235c5..1e1035e9 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] + os: [macos-13] steps: - uses: actions/checkout@v2 From 2d78060be97723fde3c8fd766fb1f89f5213c8ae Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:24:48 +0530 Subject: [PATCH 051/182] added MACOSX_DEPLOYMENT_TARGET=10.13 --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 167aef5f..1927f0cd 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -80,7 +80,7 @@ fi ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* ''' -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib"} +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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" # [tool.cibuildwheel.windows] From 6961f5fbf00d4a882c80117f27bedbfed1dd7194 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:32:06 +0530 Subject: [PATCH 052/182] testing macos-14 --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 1e1035e9..f224aa22 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-13] + os: [macos-14] steps: - uses: actions/checkout@v2 From dabbc9eab149d420f9e2fa27f74fa7c3dc66869f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:38:24 +0530 Subject: [PATCH 053/182] testing linux one last time --- .../workflows/build_wheels_and_release.yml | 2 +- quaddtype/pyproject.toml | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index f224aa22..24d235c5 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-14] + os: [ubuntu-latest] steps: - uses: actions/checkout@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 1927f0cd..e4e2d5da 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -1,12 +1,10 @@ [build-system] - requires = [ "meson>=1.3.2", "meson-python", "wheel", "numpy" ] - build-backend = "mesonpy" [project] @@ -31,7 +29,7 @@ skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*" test-command = """ python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" -uname -a +python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] pytest {project}/tests """ @@ -83,13 +81,15 @@ ls -l $HOME/miniconda/lib/libsleef* 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" -# [tool.cibuildwheel.windows] -# before-all = [ -# "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", -# "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", -# "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", -# "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" -# ] -# before-build = "pip install delvewheel" -# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --verbose || echo 'Repair failed, continuing anyway'" -# environment = { LIBRARY_PATH = "%UserProfile%\\Miniconda3\\Library\\lib;%LIBRARY_PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%" } \ No newline at end of file +[tool.cibuildwheel.windows] +before-all = [ + "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", + "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", + "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +] +before-build = "pip install delvewheel" +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" +environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From e780c2c3b51d686017fadc10d81f13437f10795e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:43:47 +0530 Subject: [PATCH 054/182] testing windows --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 24d235c5..8b0dee37 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] + os: [windows-latest] steps: - uses: actions/checkout@v2 From e098c42328b68e0573da38f9c657351e2223a5ac Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:46:31 +0530 Subject: [PATCH 055/182] switching to cmd --- quaddtype/pyproject.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e4e2d5da..47319454 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,12 +83,12 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", - "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" + "cmd /c \"powershell -Command \"\"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"\"\"", + "cmd /c start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", + "cmd /c %UserProfile%\\Miniconda3\\Scripts\\activate.bat", + "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", + "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", + "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" ] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From ee7e80483190a4b2d251cad2269296d0ef338d52 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:52:04 +0530 Subject: [PATCH 056/182] trying again --- quaddtype/pyproject.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 47319454..a9741533 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,12 +83,12 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "cmd /c \"powershell -Command \"\"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"\"\"", - "cmd /c start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "cmd /c %UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", - "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", - "cmd /c %UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" + "powershell Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe", + "powershell Start-Process -FilePath ./miniconda.exe -ArgumentList '/S', '/D=%UserProfile%\\Miniconda3' -NoNewWindow -Wait", + "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" ] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From 26b46a95a8c9f6487e17eb77b8e2d0ae29859aed Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:54:30 +0530 Subject: [PATCH 057/182] going complete vanilla --- quaddtype/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index a9741533..fa6c10eb 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,8 +83,8 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "powershell Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe", - "powershell Start-Process -FilePath ./miniconda.exe -ArgumentList '/S', '/D=%UserProfile%\\Miniconda3' -NoNewWindow -Wait", + "curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe", + "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", From 9a2e6a68a661e1f3ecbb7a8ad1c46e1caea92af5 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 02:56:37 +0530 Subject: [PATCH 058/182] using bitsadmin --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index fa6c10eb..4a4a8801 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe", + "bitsadmin /transfer download_miniconda https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe %CD%\\miniconda.exe", "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", From 071879acd4f53516292cd931d5a9d800fd830b25 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 03:00:20 +0530 Subject: [PATCH 059/182] installing powershell with winget --- quaddtype/pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 4a4a8801..a8a16753 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,9 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "bitsadmin /transfer download_miniconda https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe %CD%\\miniconda.exe", + "winget install --id Microsoft.Powershell --source winget", + "start /wait powershell.msi /quiet /norestart", + "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", From 82021f8d2defb1acee550542ac50fb9c258a19bc Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 03:08:58 +0530 Subject: [PATCH 060/182] pushing for linux, mac --- .github/workflows/build_wheels_and_release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 8b0dee37..662b3aec 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] + os: [ubuntu-latest, macos-13, macos-14] steps: - uses: actions/checkout@v2 @@ -59,7 +59,7 @@ jobs: id: create_release uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} with: tag_name: ${{ github.ref }} release_name: Release ${{ github.ref }} @@ -72,4 +72,4 @@ jobs: with: files: ./artifacts/**/*.whl env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} From 3fe7899a23084e3a041478859eb96329d4b10635 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:05:32 +0530 Subject: [PATCH 061/182] win: switch to curl --- quaddtype/pyproject.toml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index a8a16753..46d6fe38 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,14 +83,12 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "winget install --id Microsoft.Powershell --source winget", - "start /wait powershell.msi /quiet /norestart", - "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", - "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" + "curl -o miniconda.exe https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe", + "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", + "set PATH=%UserProfile%\\Miniconda3;%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", + "conda config --add channels conda-forge", + "conda config --set channel_priority strict", + "conda install -y -c conda-forge sleef" ] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From 29085b0d2a431f114c2250df7f7a129e6748749b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:06:46 +0530 Subject: [PATCH 062/182] win: switch to curl --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 662b3aec..4cfac19c 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-13, macos-14] + os: [windows-latest] steps: - uses: actions/checkout@v2 From 406bf50711a53fa938ac600149a8bc2569f5fb0b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:10:11 +0530 Subject: [PATCH 063/182] win: switch to Python --- quaddtype/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 46d6fe38..bb5467db 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,9 +83,10 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "curl -o miniconda.exe https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe", + "python -c \"import urllib.request; urllib.request.urlretrieve('https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'miniconda.exe')\"", "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", "set PATH=%UserProfile%\\Miniconda3;%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", + "call %UserProfile%\\Miniconda3\\Scripts\\activate.bat", "conda config --add channels conda-forge", "conda config --set channel_priority strict", "conda install -y -c conda-forge sleef" From bb2f00151ff7e5242198f93a2722ff1de17da246 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:22:07 +0530 Subject: [PATCH 064/182] win: switch to powershell --- quaddtype/pyproject.toml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index bb5467db..15399ad7 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,13 +83,12 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "python -c \"import urllib.request; urllib.request.urlretrieve('https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'miniconda.exe')\"", + "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"$env:PATH; Get-Command python; python -c 'import sys; print(sys.executable)'\"", + "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'\"", "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "set PATH=%UserProfile%\\Miniconda3;%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", - "call %UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "conda config --add channels conda-forge", - "conda config --set channel_priority strict", - "conda install -y -c conda-forge sleef" + "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH\"", + "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1\"", + "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"conda config --add channels conda-forge; conda config --set channel_priority strict; conda install -y -c conda-forge sleef\"" ] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From e01907a1ded44db46a139e40825bd5be7874181f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:26:00 +0530 Subject: [PATCH 065/182] win: switch to powershell --- .../workflows/build_wheels_and_release.yml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 4cfac19c..58bc30f0 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -24,15 +24,33 @@ jobs: with: python-version: "3.10" + - name: Display Python version + shell: cmd + run: | + "C:\Program Files\PowerShell\7\pwsh.exe" -Command "$env:PATH; Get-Command python; python --version; python -c 'import sys; print(sys.executable)'" + - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + shell: cmd + run: | + "C:\Program Files\PowerShell\7\pwsh.exe" -Command "python -m pip install --upgrade pip; pip install cibuildwheel==2.20.0" - name: Build wheels + shell: cmd run: | - python -m cibuildwheel --output-dir wheelhouse + "C:\Program Files\PowerShell\7\pwsh.exe" -Command "python -m cibuildwheel --output-dir wheelhouse" env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + CIBW_BEFORE_ALL_WINDOWS: > + cmd /c ""C:\Program Files\PowerShell\7\pwsh.exe" -Command " + Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; + Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\Miniconda3' -Wait; + $env:PATH = '$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;' + $env:PATH; + & $env:UserProfile\Miniconda3\Scripts\activate.ps1; + conda config --add channels conda-forge; + conda config --set channel_priority strict; + conda install -y -c conda-forge sleef + "" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 From 779736e74699f7e245ce62f7f160b11116f56163 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:30:12 +0530 Subject: [PATCH 066/182] win: switch to pwsh --- .../workflows/build_wheels_and_release.yml | 22 ++----------------- quaddtype/pyproject.toml | 13 ++++++----- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 58bc30f0..4cfac19c 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -24,33 +24,15 @@ jobs: with: python-version: "3.10" - - name: Display Python version - shell: cmd - run: | - "C:\Program Files\PowerShell\7\pwsh.exe" -Command "$env:PATH; Get-Command python; python --version; python -c 'import sys; print(sys.executable)'" - - name: Install cibuildwheel - shell: cmd - run: | - "C:\Program Files\PowerShell\7\pwsh.exe" -Command "python -m pip install --upgrade pip; pip install cibuildwheel==2.20.0" + run: pip install cibuildwheel==2.20.0 - name: Build wheels - shell: cmd run: | - "C:\Program Files\PowerShell\7\pwsh.exe" -Command "python -m cibuildwheel --output-dir wheelhouse" + python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_BEFORE_ALL_WINDOWS: > - cmd /c ""C:\Program Files\PowerShell\7\pwsh.exe" -Command " - Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; - Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\Miniconda3' -Wait; - $env:PATH = '$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;' + $env:PATH; - & $env:UserProfile\Miniconda3\Scripts\activate.ps1; - conda config --add channels conda-forge; - conda config --set channel_priority strict; - conda install -y -c conda-forge sleef - "" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 15399ad7..042120ed 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,12 +83,13 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = [ - "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"$env:PATH; Get-Command python; python -c 'import sys; print(sys.executable)'\"", - "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'\"", - "start /wait \"\" miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH\"", - "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1\"", - "C:\\Program Files\\PowerShell\\7\\pwsh.EXE -Command \"conda config --add channels conda-forge; conda config --set channel_priority strict; conda install -y -c conda-forge sleef\"" + "Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'", + "Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait", + "$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH", + "& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1", + "conda config --add channels conda-forge", + "conda config --set channel_priority strict", + "conda install -y -c conda-forge sleef" ] before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From 9a523a550415c06ee4aee8fb722f058c243c64d7 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:35:33 +0530 Subject: [PATCH 067/182] win: refacgor --- quaddtype/pyproject.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 042120ed..208fa883 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,15 +82,15 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = [ - "Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'", - "Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait", - "$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH", - "& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1", - "conda config --add channels conda-forge", - "conda config --set channel_priority strict", - "conda install -y -c conda-forge sleef" -] +before-all = ''' +Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' +Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait +$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH +$env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 +conda config --add channels conda-forge +conda config --set channel_priority strict +conda install -y -c conda-forge sleef +''' before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 4a3cfa66b32472c70a941d35f965721ebcf38c66 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:37:29 +0530 Subject: [PATCH 068/182] win: refactor --- quaddtype/pyproject.toml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 208fa883..d66862aa 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,15 +82,8 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = ''' -Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait -$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH -$env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 -conda config --add channels conda-forge -conda config --set channel_priority strict -conda install -y -c conda-forge sleef -''' +before-all = "pwsh -Command @'\nInvoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'\nStart-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait\n$env:PATH = \"$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH\"\n& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1\nconda config --add channels conda-forge\nconda config --set channel_priority strict\nconda install -y -c conda-forge sleef\n'@" + before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 5622a2ad2918b79606431a8fb92238d0031fa72b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:45:59 +0530 Subject: [PATCH 069/182] win: refactor --- quaddtype/pyproject.toml | 2 +- setup_miniconda.ps1 | 7 +++++++ setup_miniconda.psi | 0 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 setup_miniconda.ps1 create mode 100644 setup_miniconda.psi diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index d66862aa..2d7a9c0b 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,7 +82,7 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "pwsh -Command @'\nInvoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'\nStart-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait\n$env:PATH = \"$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH\"\n& $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1\nconda config --add channels conda-forge\nconda config --set channel_priority strict\nconda install -y -c conda-forge sleef\n'@" +before-all = "powershell.exe -ExecutionPolicy Bypass -File setup_miniconda.ps1" before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" diff --git a/setup_miniconda.ps1 b/setup_miniconda.ps1 new file mode 100644 index 00000000..97831992 --- /dev/null +++ b/setup_miniconda.ps1 @@ -0,0 +1,7 @@ +Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' +Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\Miniconda3' -Wait +$env:PATH = "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH" +& $env:UserProfile\Miniconda3\Scripts\activate.ps1 +conda config --add channels conda-forge +conda config --set channel_priority strict +conda install -y -c conda-forge sleef \ No newline at end of file diff --git a/setup_miniconda.psi b/setup_miniconda.psi new file mode 100644 index 00000000..e69de29b From d2e94957e403abdcd5d6c0a896eb31ef4baa0c2d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:49:47 +0530 Subject: [PATCH 070/182] win: refactor --- quaddtype/pyproject.toml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 2d7a9c0b..73271d33 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,8 +82,15 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "powershell.exe -ExecutionPolicy Bypass -File setup_miniconda.ps1" - +before-all = ''' +C:\Program Files\PowerShell\7\pwsh.EXE -command "& {Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'}" +Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait +$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH +$env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 +conda config --add channels conda-forge +conda config --set channel_priority strict +conda install -y -c conda-forge sleef +''' before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 8ab8a0c10d35186be4d2dfb9ab737239964faa29 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:52:07 +0530 Subject: [PATCH 071/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 73271d33..80147b3d 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -C:\Program Files\PowerShell\7\pwsh.EXE -command "& {Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'}" +"C:\Program Files\PowerShell\7\pwsh.EXE" -command "& {Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'}" Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait $env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 From 6199620d85cb5cca68f3c478eb3682d78568d80b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 11:57:29 +0530 Subject: [PATCH 072/182] win: refactor --- quaddtype/pyproject.toml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 80147b3d..5bf83006 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,13 +83,17 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\Program Files\PowerShell\7\pwsh.EXE" -command "& {Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'}" -Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait -$env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;$env:PATH -$env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 -conda config --add channels conda-forge -conda config --set channel_priority strict -conda install -y -c conda-forge sleef +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -Command "& { + Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' + Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait + $env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH + & $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y -c conda-forge sleef + Write-Host 'PATH:' $env:PATH + Get-Command python | Format-List +}" ''' before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" From d6c555f01cbf4b80cb177a80d9ac981cdd32b058 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:01:59 +0530 Subject: [PATCH 073/182] win: refactor --- quaddtype/pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 5bf83006..016940a2 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -Command "& { +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait $env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH @@ -91,8 +91,6 @@ before-all = ''' conda config --add channels conda-forge conda config --set channel_priority strict conda install -y -c conda-forge sleef - Write-Host 'PATH:' $env:PATH - Get-Command python | Format-List }" ''' before-build = "pip install delvewheel" From b3bbbc33c69da8a6ef51b36ee209b20e248923d9 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:04:16 +0530 Subject: [PATCH 074/182] win: refactor --- quaddtype/pyproject.toml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 016940a2..e401ec74 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -84,13 +84,29 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' "C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { + $ErrorActionPreference = 'Stop' + $ProgressPreference = 'SilentlyContinue' + + Write-Host 'Downloading Miniconda...' Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' - Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\\Miniconda3' -Wait - $env:PATH = '$env:UserProfile\\Miniconda3;$env:UserProfile\\Miniconda3\\Scripts;$env:UserProfile\\Miniconda3\\Library\\bin;' + $env:PATH - & $env:UserProfile\\Miniconda3\\Scripts\\activate.ps1 + + Write-Host 'Installing Miniconda...' + Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait + + Write-Host 'Updating PATH...' + $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH + + Write-Host 'Activating Conda...' + & C:\\Miniconda3\\Scripts\\activate.ps1 + + Write-Host 'Configuring Conda...' conda config --add channels conda-forge conda config --set channel_priority strict + + Write-Host 'Installing sleef...' conda install -y -c conda-forge sleef + + Write-Host 'Setup completed successfully.' }" ''' before-build = "pip install delvewheel" From ff1f28d3238da6acf83f3066dc8529c90338907e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:06:42 +0530 Subject: [PATCH 075/182] win: refactor --- quaddtype/pyproject.toml | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e401ec74..c366ee5c 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,32 +83,9 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { - $ErrorActionPreference = 'Stop' - $ProgressPreference = 'SilentlyContinue' - - Write-Host 'Downloading Miniconda...' - Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' - - Write-Host 'Installing Miniconda...' - Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait - - Write-Host 'Updating PATH...' - $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH - - Write-Host 'Activating Conda...' - & C:\\Miniconda3\\Scripts\\activate.ps1 - - Write-Host 'Configuring Conda...' - conda config --add channels conda-forge - conda config --set channel_priority strict - - Write-Host 'Installing sleef...' - conda install -y -c conda-forge sleef - - Write-Host 'Setup completed successfully.' -}" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' + before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 1e7cce59c1d3509ec02f49d535aae8474e81f079 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:10:10 +0530 Subject: [PATCH 076/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index c366ee5c..023a5a42 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' before-build = "pip install delvewheel" From 95498179ac5664171660817322d650970195400f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:13:08 +0530 Subject: [PATCH 077/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 023a5a42..3ce59006 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/RegisterPython=1','/AddToPath=1','/D=C:\\Miniconda3' -Wait -PassThru; if ($process.ExitCode -ne 0) { Write-Host 'Miniconda installer exited with code: ' + $process.ExitCode; throw 'Miniconda installation failed' }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Host 'Contents of C:\\Miniconda3:'; Get-ChildItem -Path 'C:\\Miniconda3' -Recurse | Select-Object FullName; throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.'; Write-Host 'Final PATH:'; Write-Host $env:PATH }" ''' before-build = "pip install delvewheel" From 3bbb0ae156cac60b0af27d671ea59baaf2c64779 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:18:34 +0530 Subject: [PATCH 078/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 3ce59006..e55a2194 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/RegisterPython=1','/AddToPath=1','/D=C:\\Miniconda3' -Wait -PassThru; if ($process.ExitCode -ne 0) { Write-Host 'Miniconda installer exited with code: ' + $process.ExitCode; throw 'Miniconda installation failed' }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Host 'Contents of C:\\Miniconda3:'; Get-ChildItem -Path 'C:\\Miniconda3' -Recurse | Select-Object FullName; throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.'; Write-Host 'Final PATH:'; Write-Host $env:PATH }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 5; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' before-build = "pip install delvewheel" From d2e19bb8e2b829ae2beb44d3bf90063ce8ec3c59 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:23:24 +0530 Subject: [PATCH 079/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index e55a2194..89732ea7 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 5; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking Miniconda installation...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe')) { Write-Error 'Miniconda download failed'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' before-build = "pip install delvewheel" From 0119906cad2f4b422cb0cce4ae4c988cc4889eea Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:26:20 +0530 Subject: [PATCH 080/182] win: refactor --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 89732ea7..5dc6c195 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,7 +83,7 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe')) { Write-Error 'Miniconda download failed'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe')) { Write-Error 'Miniconda download failed'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' before-build = "pip install delvewheel" From 36d4dabfa6467a680196f2f80fa51b1634321eec Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:30:01 +0530 Subject: [PATCH 081/182] fixing win --- quaddtype/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 5dc6c195..f8b78489 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,9 +83,10 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe')) { Write-Error 'Miniconda download failed'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if ((Get-Item 'miniconda.exe').Length -eq 0) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3','/LOG=miniconda_install.log' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' + before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 2729a2feb6cbb4777a06ae739dfe790cf09db13b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:33:32 +0530 Subject: [PATCH 082/182] fixing win --- quaddtype/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index f8b78489..13795f65 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,10 +83,11 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if ((Get-Item 'miniconda.exe').Length -eq 0) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3','/LOG=miniconda_install.log' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls $installPath /grant $env:USERNAME:(OI)(CI)F /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' + before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 9429ca8460b7d2a8a6357115a73eb07c2f801e88 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:35:25 +0530 Subject: [PATCH 083/182] fixing win --- quaddtype/pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 13795f65..70b0b7c5 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,11 +83,9 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls $installPath /grant $env:USERNAME:(OI)(CI)F /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls $installPath /grant $env:USERNAME:(OI)(CI)(F) /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' - - before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 8261c63331ca8ab5622118f01fa73f04d2c57750 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:37:08 +0530 Subject: [PATCH 084/182] fixing win --- quaddtype/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 70b0b7c5..88c3fb1c 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -83,9 +83,10 @@ repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls $installPath /grant $env:USERNAME:(OI)(CI)(F) /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" +"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls "$installPath" /grant $env:USERNAME:(OI)(CI)(F) /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" ''' + before-build = "pip install delvewheel" repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file From 7405e4d41fe45a449fdefeb84436e3caede561c8 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:50:37 +0530 Subject: [PATCH 085/182] fixing win --- quaddtype/pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 88c3fb1c..517dde48 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,9 +82,8 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = ''' -"C:\\Program Files\\PowerShell\\7\\pwsh.EXE" -command "& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if (!(Test-Path 'miniconda.exe') -or ((Get-Item 'miniconda.exe').Length -eq 0)) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Setting up permissions for Miniconda installation directory...'; $installPath = 'C:\\Users\\$env:USERNAME\\Miniconda3'; if (!(Test-Path $installPath)) { New-Item -ItemType Directory -Force -Path $installPath; }; icacls "$installPath" /grant $env:USERNAME:(OI)(CI)(F) /T; if ($LASTEXITCODE -ne 0) { Write-Error 'Failed to set permissions on installation directory'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }" -''' +before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if ((Get-Item 'miniconda.exe').Length -eq 0) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3','/LOG=miniconda_install.log' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }\"" + before-build = "pip install delvewheel" From 72b597ee0f1e9373ad0c16f10926dd04fafcee88 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:52:08 +0530 Subject: [PATCH 086/182] fixing win --- quaddtype/pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 517dde48..0f59093e 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,7 +82,9 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Write-Host 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe'; if ((Get-Item 'miniconda.exe').Length -eq 0) { Write-Error 'Miniconda download failed or file is empty'; Exit 1; }; Write-Host 'Installing Miniconda...'; Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Users\\$env:USERNAME\\Miniconda3','/LOG=miniconda_install.log' -Wait; if ($LASTEXITCODE -ne 0) { Write-Error 'Miniconda installation failed'; Exit 1; }; Write-Host 'Waiting for installation to complete...'; Start-Sleep -Seconds 10; Write-Host 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3')) { Write-Error 'Miniconda directory not found, installation failed'; Exit 1; }; Write-Host 'Updating PATH...'; $env:PATH = 'C:\\Users\\$env:USERNAME\\Miniconda3;C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts;C:\\Users\\$env:USERNAME\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Host 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1')) { Write-Error 'Miniconda installation failed or activate.ps1 not found'; Exit 1; }; Write-Host 'Activating Conda...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Host 'Conda not found in PATH, trying to initialize...'; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Users\\$env:USERNAME\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Host 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Host 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Host 'Setup completed successfully.' }\"" +before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose 'Installing Miniconda...'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3','/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -ErrorAction Stop; if ($process.ExitCode -ne 0) { throw 'Miniconda installation failed with exit code: ' + $process.ExitCode }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; }; exit 1; } }\"" + + From 0f58ceae86d4e2b00b1ecd8d68d4154c3548785a Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:54:40 +0530 Subject: [PATCH 087/182] fixing win --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 0f59093e..14e21264 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,7 +82,7 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose 'Installing Miniconda...'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=C:\\Miniconda3','/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -ErrorAction Stop; if ($process.ExitCode -ne 0) { throw 'Miniconda installation failed with exit code: ' + $process.ExitCode }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path 'C:\\Miniconda3')) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = 'C:\\Miniconda3;C:\\Miniconda3\\Scripts;C:\\Miniconda3\\Library\\bin;' + $env:PATH; Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path 'C:\\Miniconda3\\Scripts\\activate.ps1')) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & C:\\Miniconda3\\Scripts\\activate.ps1; if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & C:\\Miniconda3\\Scripts\\conda.exe init powershell; & C:\\Miniconda3\\Scripts\\conda.exe activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; }; exit 1; } }\"" +before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Checking available disk space...'; $disk = Get-WmiObject Win32_LogicalDisk -Filter 'DeviceID='C:''; Write-Verbose ('Available disk space: ' + [math]::Round($disk.FreeSpace / 1GB, 2) + ' GB'); Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-Verbose 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -ErrorAction Stop; if ($process.ExitCode -ne 0) { throw 'Miniconda installation failed with exit code: ' + $process.ExitCode }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path $installPath)) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; Write-Verbose ('Current PATH: ' + $env:PATH); Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path ($installPath + '\\Scripts\\activate.ps1'))) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & ($installPath + '\\Scripts\\activate.ps1'); if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & ($installPath + '\\Scripts\\conda.exe') init powershell; & ($installPath + '\\Scripts\\conda.exe') activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; }; exit 1; } }\"" From cec694984aa919532a9c5a398ff01e7393aab959 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:56:38 +0530 Subject: [PATCH 088/182] fixing win --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 14e21264..4366e959 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,7 +82,7 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Checking available disk space...'; $disk = Get-WmiObject Win32_LogicalDisk -Filter 'DeviceID='C:''; Write-Verbose ('Available disk space: ' + [math]::Round($disk.FreeSpace / 1GB, 2) + ' GB'); Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-Verbose 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -ErrorAction Stop; if ($process.ExitCode -ne 0) { throw 'Miniconda installation failed with exit code: ' + $process.ExitCode }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path $installPath)) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; Write-Verbose ('Current PATH: ' + $env:PATH); Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path ($installPath + '\\Scripts\\activate.ps1'))) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & ($installPath + '\\Scripts\\activate.ps1'); if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & ($installPath + '\\Scripts\\conda.exe') init powershell; & ($installPath + '\\Scripts\\conda.exe') activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; }; exit 1; } }\"" +before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Checking available disk space...'; $disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='C:'\"; Write-Verbose ('Available disk space: ' + [math]::Round($disk.FreeSpace / 1GB, 2) + ' GB'); Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-Verbose 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -NoNewWindow -ErrorAction Stop; if ($process.ExitCode -ne 0) { Write-Verbose ('Miniconda installation failed with exit code: ' + $process.ExitCode); Write-Verbose 'Checking for miniconda_install.log...'; if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; } else { Write-Verbose 'miniconda_install.log not found.'; }; throw 'Miniconda installation failed with exit code: ' + $process.ExitCode; }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path $installPath)) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; Write-Verbose ('Current PATH: ' + $env:PATH); Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path ($installPath + '\\Scripts\\activate.ps1'))) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & ($installPath + '\\Scripts\\activate.ps1'); if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & ($installPath + '\\Scripts\\conda.exe') init powershell; & ($installPath + '\\Scripts\\conda.exe') activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); exit 1; } }\"" From a8d2314b204b406d232bb396a11dc4e0d5eab9ba Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 12:59:38 +0530 Subject: [PATCH 089/182] fixing win --- quaddtype/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 4366e959..4ce2fa31 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -82,7 +82,8 @@ environment = {DYLD_LIBRARY_PATH = "$HOME/miniconda/lib:$DYLD_LIBRARY_PATH", LIB repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" [tool.cibuildwheel.windows] -before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; Write-Verbose 'Starting Miniconda installation process...'; try { Write-Verbose 'Checking available disk space...'; $disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='C:'\"; Write-Verbose ('Available disk space: ' + [math]::Round($disk.FreeSpace / 1GB, 2) + ' GB'); Write-Verbose 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-Verbose ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-Verbose 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0','/LOG=miniconda_install.log' -Wait -PassThru -NoNewWindow -ErrorAction Stop; if ($process.ExitCode -ne 0) { Write-Verbose ('Miniconda installation failed with exit code: ' + $process.ExitCode); Write-Verbose 'Checking for miniconda_install.log...'; if (Test-Path 'miniconda_install.log') { Write-Verbose 'Contents of miniconda_install.log:'; Get-Content 'miniconda_install.log' | ForEach-Object { Write-Verbose $_ }; } else { Write-Verbose 'miniconda_install.log not found.'; }; throw 'Miniconda installation failed with exit code: ' + $process.ExitCode; }; Write-Verbose 'Waiting for installation to complete...'; Start-Sleep -Seconds 30; Write-Verbose 'Checking if Miniconda was installed...'; if (!(Test-Path $installPath)) { throw 'Miniconda directory not found, installation failed' }; Write-Verbose 'Updating PATH...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; Write-Verbose ('Current PATH: ' + $env:PATH); Write-Verbose 'Checking for activate.ps1...'; if (!(Test-Path ($installPath + '\\Scripts\\activate.ps1'))) { throw 'Miniconda installation failed or activate.ps1 not found' }; Write-Verbose 'Activating Conda...'; & ($installPath + '\\Scripts\\activate.ps1'); if (!(Get-Command conda -ErrorAction SilentlyContinue)) { Write-Verbose 'Conda not found in PATH, trying to initialize...'; & ($installPath + '\\Scripts\\conda.exe') init powershell; & ($installPath + '\\Scripts\\conda.exe') activate; }; Write-Verbose 'Configuring Conda...'; conda config --add channels conda-forge; conda config --set channel_priority strict; Write-Verbose 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-Verbose 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-Verbose 'Error details:'; Write-Verbose $_.Exception.ToString(); exit 1; } }\"" +before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; function Write-VerboseAndOutput($message) { Write-Verbose $message; Write-Output $message; }; try { Write-VerboseAndOutput 'Starting Miniconda installation process...'; Write-VerboseAndOutput 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-VerboseAndOutput ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-VerboseAndOutput 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0' -Wait -PassThru -NoNewWindow -RedirectStandardOutput 'miniconda_install.log' -RedirectStandardError 'miniconda_install_error.log'; if ($process.ExitCode -ne 0) { Write-VerboseAndOutput ('Miniconda installation failed with exit code: ' + $process.ExitCode); Write-VerboseAndOutput 'Contents of miniconda_install.log:'; if (Test-Path 'miniconda_install.log') { Get-Content 'miniconda_install.log' | ForEach-Object { Write-VerboseAndOutput $_ }; } else { Write-VerboseAndOutput 'miniconda_install.log not found.'; }; Write-VerboseAndOutput 'Contents of miniconda_install_error.log:'; if (Test-Path 'miniconda_install_error.log') { Get-Content 'miniconda_install_error.log' | ForEach-Object { Write-VerboseAndOutput $_ }; } else { Write-VerboseAndOutput 'miniconda_install_error.log not found.'; }; throw 'Miniconda installation failed with exit code: ' + $process.ExitCode; }; Write-VerboseAndOutput 'Miniconda installation completed. Configuring...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; & ($installPath + '\\Scripts\\activate.ps1'); conda config --add channels conda-forge; conda config --set channel_priority strict; Write-VerboseAndOutput 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-VerboseAndOutput 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-VerboseAndOutput ('Error: ' + $_.Exception.Message); Write-VerboseAndOutput ('Stack Trace: ' + $_.ScriptStackTrace); exit 1; } }\"" + From 30883aa23d4db282960ecf8300670485ba1e6487 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 13:07:07 +0530 Subject: [PATCH 090/182] fixing win --- .../workflows/build_wheels_and_release.yml | 30 ++++++++++++++++++- quaddtype/pyproject.toml | 14 +-------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 4cfac19c..81b94997 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] + os: [windows-latest, ubuntu-latest, macos-13, macos-14] steps: - uses: actions/checkout@v2 @@ -27,12 +27,40 @@ jobs: - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 + - name: Install Miniconda (Windows only) + if: runner.os == 'Windows' + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $ProgressPreference = 'SilentlyContinue' + Write-Host "Downloading Miniconda..." + Invoke-WebRequest -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" -OutFile "miniconda.exe" + Write-Host "Installing Miniconda..." + Start-Process -FilePath "miniconda.exe" -ArgumentList "/S", "/D=$env:UserProfile\Miniconda3" -Wait -NoNewWindow + Write-Host "Miniconda installed. Configuring..." + $env:Path = "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;" + $env:Path + conda init powershell + conda config --set auto_activate_base false + conda config --add channels conda-forge + conda config --set channel_priority strict + Write-Host "Installing sleef..." + conda install -y -c conda-forge sleef + Write-Host "Miniconda setup completed." + - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + CIBW_ENVIRONMENT_WINDOWS: >- + PATH="$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH" + INCLUDE="$env:UserProfile\Miniconda3\Library\include;$env:INCLUDE" + LIB="$env:UserProfile\Miniconda3\Library\lib;$env:LIB" + SLEEF_INCLUDE_DIR="$env:UserProfile\Miniconda3\Library\include" + SLEEF_LIBRARY="$env:UserProfile\Miniconda3\Library\lib" + CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > + delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\Miniconda3\Library\bin working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 4ce2fa31..08044968 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -79,16 +79,4 @@ ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* ''' 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" - -[tool.cibuildwheel.windows] -before-all = "\"C:\\Program Files\\PowerShell\\7\\pwsh.EXE\" -command \"& { $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; function Write-VerboseAndOutput($message) { Write-Verbose $message; Write-Output $message; }; try { Write-VerboseAndOutput 'Starting Miniconda installation process...'; Write-VerboseAndOutput 'Downloading Miniconda...'; Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -ErrorAction Stop; if ((Get-Item 'miniconda.exe').Length -eq 0) { throw 'Miniconda download failed or file is empty' }; Write-VerboseAndOutput ('Miniconda installer size: ' + (Get-Item 'miniconda.exe').Length + ' bytes'); Write-VerboseAndOutput 'Installing Miniconda...'; $installPath = 'C:\\Miniconda3'; $process = Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S',('/D=' + $installPath),'/RegisterPython=0','/AddToPath=0' -Wait -PassThru -NoNewWindow -RedirectStandardOutput 'miniconda_install.log' -RedirectStandardError 'miniconda_install_error.log'; if ($process.ExitCode -ne 0) { Write-VerboseAndOutput ('Miniconda installation failed with exit code: ' + $process.ExitCode); Write-VerboseAndOutput 'Contents of miniconda_install.log:'; if (Test-Path 'miniconda_install.log') { Get-Content 'miniconda_install.log' | ForEach-Object { Write-VerboseAndOutput $_ }; } else { Write-VerboseAndOutput 'miniconda_install.log not found.'; }; Write-VerboseAndOutput 'Contents of miniconda_install_error.log:'; if (Test-Path 'miniconda_install_error.log') { Get-Content 'miniconda_install_error.log' | ForEach-Object { Write-VerboseAndOutput $_ }; } else { Write-VerboseAndOutput 'miniconda_install_error.log not found.'; }; throw 'Miniconda installation failed with exit code: ' + $process.ExitCode; }; Write-VerboseAndOutput 'Miniconda installation completed. Configuring...'; $env:PATH = $installPath + ';' + $installPath + '\\Scripts;' + $installPath + '\\Library\\bin;' + $env:PATH; & ($installPath + '\\Scripts\\activate.ps1'); conda config --add channels conda-forge; conda config --set channel_priority strict; Write-VerboseAndOutput 'Installing sleef...'; conda install -y -c conda-forge sleef; Write-VerboseAndOutput 'Setup completed successfully.'; } catch { Write-Error $_.Exception.Message; Write-VerboseAndOutput ('Error: ' + $_.Exception.Message); Write-VerboseAndOutput ('Stack Trace: ' + $_.ScriptStackTrace); exit 1; } }\"" - - - - - - -before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" -environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From 3def6f92e6bd8db425a5f544664122551d55b497 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 13:07:38 +0530 Subject: [PATCH 091/182] fixing win --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 81b94997..79d9ce02 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-13, macos-14] + os: [windows-latest] steps: - uses: actions/checkout@v2 From 328cad63bb4065cba3610e37e36201c900e2042f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 13:16:49 +0530 Subject: [PATCH 092/182] fixing win --- .../workflows/build_wheels_and_release.yml | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 79d9ce02..313f296a 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -47,20 +47,32 @@ jobs: conda install -y -c conda-forge sleef Write-Host "Miniconda setup completed." + # Set environment variables for the build + $env:INCLUDE = "$env:UserProfile\Miniconda3\Library\include;$env:INCLUDE" + $env:LIB = "$env:UserProfile\Miniconda3\Library\lib;$env:LIB" + $env:SLEEF_INCLUDE_DIR = "$env:UserProfile\Miniconda3\Library\include" + $env:SLEEF_LIBRARY = "$env:UserProfile\Miniconda3\Library\lib" + + # Make the environment variables available to subsequent steps + echo "INCLUDE=$env:INCLUDE" >> $env:GITHUB_ENV + echo "LIB=$env:LIB" >> $env:GITHUB_ENV + echo "SLEEF_INCLUDE_DIR=$env:SLEEF_INCLUDE_DIR" >> $env:GITHUB_ENV + echo "SLEEF_LIBRARY=$env:SLEEF_LIBRARY" >> $env:GITHUB_ENV + echo "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin" >> $env:GITHUB_PATH + - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse + run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_ENVIRONMENT_WINDOWS: >- PATH="$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH" - INCLUDE="$env:UserProfile\Miniconda3\Library\include;$env:INCLUDE" - LIB="$env:UserProfile\Miniconda3\Library\lib;$env:LIB" - SLEEF_INCLUDE_DIR="$env:UserProfile\Miniconda3\Library\include" - SLEEF_LIBRARY="$env:UserProfile\Miniconda3\Library\lib" + INCLUDE="$env:INCLUDE" + LIB="$env:LIB" + SLEEF_INCLUDE_DIR="$env:SLEEF_INCLUDE_DIR" + SLEEF_LIBRARY="$env:SLEEF_LIBRARY" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > - delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\Miniconda3\Library\bin + python -m pip install delvewheel && python -m delvewheel repair -w {dest_dir} {wheel} --add-path "%UserProfile%\Miniconda3\Library\bin" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 From 843f9c1ca267d78dad39261717ea39b75858e9a6 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 13:20:14 +0530 Subject: [PATCH 093/182] fixing win --- .github/workflows/build_wheels_and_release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 313f296a..40f25644 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -45,6 +45,7 @@ jobs: conda config --set channel_priority strict Write-Host "Installing sleef..." conda install -y -c conda-forge sleef + pip install cibuildwheel==2.20.0 Write-Host "Miniconda setup completed." # Set environment variables for the build From de462e35df7f12e38da3c5d2b114b62b8de76d1d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 13:28:26 +0530 Subject: [PATCH 094/182] ignoring win for now --- .../workflows/build_wheels_and_release.yml | 47 ++----------------- quaddtype/pyproject.toml | 17 ++++++- setup_miniconda.ps1 | 7 --- 3 files changed, 19 insertions(+), 52 deletions(-) delete mode 100644 setup_miniconda.ps1 diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 40f25644..662b3aec 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest] + os: [ubuntu-latest, macos-13, macos-14] steps: - uses: actions/checkout@v2 @@ -27,53 +27,12 @@ jobs: - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 - - name: Install Miniconda (Windows only) - if: runner.os == 'Windows' - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - $ProgressPreference = 'SilentlyContinue' - Write-Host "Downloading Miniconda..." - Invoke-WebRequest -Uri "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" -OutFile "miniconda.exe" - Write-Host "Installing Miniconda..." - Start-Process -FilePath "miniconda.exe" -ArgumentList "/S", "/D=$env:UserProfile\Miniconda3" -Wait -NoNewWindow - Write-Host "Miniconda installed. Configuring..." - $env:Path = "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;" + $env:Path - conda init powershell - conda config --set auto_activate_base false - conda config --add channels conda-forge - conda config --set channel_priority strict - Write-Host "Installing sleef..." - conda install -y -c conda-forge sleef - pip install cibuildwheel==2.20.0 - Write-Host "Miniconda setup completed." - - # Set environment variables for the build - $env:INCLUDE = "$env:UserProfile\Miniconda3\Library\include;$env:INCLUDE" - $env:LIB = "$env:UserProfile\Miniconda3\Library\lib;$env:LIB" - $env:SLEEF_INCLUDE_DIR = "$env:UserProfile\Miniconda3\Library\include" - $env:SLEEF_LIBRARY = "$env:UserProfile\Miniconda3\Library\lib" - - # Make the environment variables available to subsequent steps - echo "INCLUDE=$env:INCLUDE" >> $env:GITHUB_ENV - echo "LIB=$env:LIB" >> $env:GITHUB_ENV - echo "SLEEF_INCLUDE_DIR=$env:SLEEF_INCLUDE_DIR" >> $env:GITHUB_ENV - echo "SLEEF_LIBRARY=$env:SLEEF_LIBRARY" >> $env:GITHUB_ENV - echo "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin" >> $env:GITHUB_PATH - - name: Build wheels - run: python -m cibuildwheel --output-dir wheelhouse + run: | + python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_ENVIRONMENT_WINDOWS: >- - PATH="$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH" - INCLUDE="$env:INCLUDE" - LIB="$env:LIB" - SLEEF_INCLUDE_DIR="$env:SLEEF_INCLUDE_DIR" - SLEEF_LIBRARY="$env:SLEEF_LIBRARY" - CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: > - python -m pip install delvewheel && python -m delvewheel repair -w {dest_dir} {wheel} --add-path "%UserProfile%\Miniconda3\Library\bin" working-directory: ./quaddtype - uses: actions/upload-artifact@v2 diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 08044968..a8a16753 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -79,4 +79,19 @@ ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* ''' 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" + +[tool.cibuildwheel.windows] +before-all = [ + "winget install --id Microsoft.Powershell --source winget", + "start /wait powershell.msi /quiet /norestart", + "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", + "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", + "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", + "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" +] +before-build = "pip install delvewheel" +repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" +environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file diff --git a/setup_miniconda.ps1 b/setup_miniconda.ps1 deleted file mode 100644 index 97831992..00000000 --- a/setup_miniconda.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -Invoke-WebRequest -Uri 'https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe' -OutFile 'miniconda.exe' -Start-Process -FilePath 'miniconda.exe' -ArgumentList '/S','/D=$env:UserProfile\Miniconda3' -Wait -$env:PATH = "$env:UserProfile\Miniconda3;$env:UserProfile\Miniconda3\Scripts;$env:UserProfile\Miniconda3\Library\bin;$env:PATH" -& $env:UserProfile\Miniconda3\Scripts\activate.ps1 -conda config --add channels conda-forge -conda config --set channel_priority strict -conda install -y -c conda-forge sleef \ No newline at end of file From c00e50a5b210b6e9049a03a199028700acbd4b16 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 21:46:52 +0530 Subject: [PATCH 095/182] adding testpypi --- .../workflows/build_wheels_and_release.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 662b3aec..843bc0af 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -40,6 +40,26 @@ jobs: path: ./quaddtype/wheelhouse/*.whl name: wheels-${{ matrix.os }} + publish_to_testpypi: + name: Publish to TestPyPI + needs: build_wheels + runs-on: ubuntu-latest + if: github.event_name == 'push' && (github.ref == 'refs/heads/testing-pkg' || startsWith(github.ref, 'refs/tags/')) + + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 + with: + path: dist + + - name: Publish to TestPyPI + 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 From abd5826825631035e74b9d8393c73b6b0c525680 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 21:50:01 +0530 Subject: [PATCH 096/182] fixed wheel location --- .github/workflows/build_wheels_and_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 843bc0af..d8f7dbf0 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -58,7 +58,7 @@ jobs: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ - packages-dir: dist/* + packages-dir: dist/*/wheelhouse create_release: name: Create Release From dd82dda20162de0793c4f6a33368e9b7d0ce1c00 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 23:24:49 +0530 Subject: [PATCH 097/182] fixed wheel location --- .github/workflows/build_wheels_and_release.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index d8f7dbf0..37bc25eb 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -44,21 +44,19 @@ jobs: name: Publish to TestPyPI needs: build_wheels runs-on: ubuntu-latest - if: github.event_name == 'push' && (github.ref == 'refs/heads/testing-pkg' || startsWith(github.ref, 'refs/tags/')) - + if: startsWith(github.ref, 'refs/tags/') steps: - name: Download all workflow run artifacts uses: actions/download-artifact@v2 with: path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@v1.9.0 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ - packages-dir: dist/*/wheelhouse + packages-dir: dist/* create_release: name: Create Release From b6dee9e45dd15410d99d0b97c137ae9beb1d1e80 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sat, 24 Aug 2024 23:45:15 +0530 Subject: [PATCH 098/182] removed psi file as ignoring windows currently --- setup_miniconda.psi | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 setup_miniconda.psi diff --git a/setup_miniconda.psi b/setup_miniconda.psi deleted file mode 100644 index e69de29b..00000000 From 7aff5f1ba7e6b3d4a6df486440e39744680b788c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 12:16:37 +0530 Subject: [PATCH 099/182] testing win --- .github/workflows/windows.yml | 110 ++++++++++++++++++++++++++++++++++ quaddtype/pyproject.toml | 17 +----- 2 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..b65197e6 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,110 @@ +name: Build quaddtype wheels for Windows + +on: + push: + branches: + - testing-pkg + tags: + - "v*" + pull_request: + +jobs: + build_wheels: + name: Build wheels on Windows + runs-on: windows-latest + strategy: + matrix: + architecture: [x64, x86] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + architecture: ${{ matrix.architecture }} + + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + python-version: "3.10" + architecture: ${{ matrix.architecture }} + + - name: Install SLEEF and other dependencies + shell: bash -l {0} + run: | + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef + conda list + if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l "$CONDA_PREFIX/Library/include/sleef.h" + ls -l "$CONDA_PREFIX/Library/lib/sleef"* + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels + env: + CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} + CIBW_BUILD_VERBOSITY: "1" + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib + CFLAGS: "-I${{ env.CONDA_PREFIX }}\\Library\\include %CFLAGS%" + CXXFLAGS: "-I${{ env.CONDA_PREFIX }}\\Library\\include %CXXFLAGS%" + LDFLAGS: "-L${{ env.CONDA_PREFIX }}\\Library\\lib %LDFLAGS%" + run: | + python -m cibuildwheel --output-dir wheelhouse + if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-windows-${{ matrix.architecture }} + + publish_to_testpypi: + name: Publish to TestPyPI + needs: build_wheels + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: dist + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.8.5 + 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 + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/**/*.whl diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index a8a16753..08044968 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -79,19 +79,4 @@ ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* ''' 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" - -[tool.cibuildwheel.windows] -before-all = [ - "winget install --id Microsoft.Powershell --source winget", - "start /wait powershell.msi /quiet /norestart", - "powershell -Command \"Invoke-WebRequest -Uri https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -OutFile miniconda.exe\"", - "start /wait miniconda.exe /S /D=%UserProfile%\\Miniconda3", - "%UserProfile%\\Miniconda3\\Scripts\\activate.bat", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --add channels conda-forge", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe config --set channel_priority strict", - "%UserProfile%\\Miniconda3\\Scripts\\conda.exe install -y -c conda-forge sleef" -] -before-build = "pip install delvewheel" -repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel} --add-path %UserProfile%\\Miniconda3\\Library\\bin" -environment = { PATH = "%UserProfile%\\Miniconda3\\Scripts;%UserProfile%\\Miniconda3\\Library\\bin;%PATH%", INCLUDE = "%UserProfile%\\Miniconda3\\Library\\include;%INCLUDE%", LIB = "%UserProfile%\\Miniconda3\\Library\\lib;%LIB%", SLEEF_INCLUDE_DIR = "%UserProfile%\\Miniconda3\\Library\\include", SLEEF_LIBRARY = "%UserProfile%\\Miniconda3\\Library\\lib"} \ No newline at end of file +repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From 1cf99186577dc0da321ab5a0450b1000ce546a1d Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 12:32:42 +0530 Subject: [PATCH 100/182] win: changed action --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b65197e6..54e91672 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -26,7 +26,7 @@ jobs: architecture: ${{ matrix.architecture }} - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true python-version: "3.10" From 63a48de8f281c29e75748f3aa8e45a5df19c595c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 12:42:14 +0530 Subject: [PATCH 101/182] edit win --- .github/workflows/windows.yml | 18 +++++++++++++----- quaddtype/meson.build | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 54e91672..8302a1af 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,6 +19,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.architecture }} + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: @@ -46,8 +51,10 @@ jobs: ls -l "$CONDA_PREFIX/Library/include/sleef.h" ls -l "$CONDA_PREFIX/Library/lib/sleef"* - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + - name: Install build dependencies + run: | + pip install -U pip + pip install cibuildwheel==2.20.0 ninja meson meson-python - name: Build wheels env: @@ -56,10 +63,11 @@ jobs: CIBW_BUILD_VERBOSITY: "1" SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib - CFLAGS: "-I${{ env.CONDA_PREFIX }}\\Library\\include %CFLAGS%" - CXXFLAGS: "-I${{ env.CONDA_PREFIX }}\\Library\\include %CXXFLAGS%" - LDFLAGS: "-L${{ env.CONDA_PREFIX }}\\Library\\lib %LDFLAGS%" + DISTUTILS_USE_SDK: "1" + MSSdk: "1" + shell: pwsh run: | + $env:PATH = "$env:CONDA_PREFIX\Library\bin;$env:PATH" python -m cibuildwheel --output-dir wheelhouse if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } working-directory: ./quaddtype diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 4d79b44d..48190d8b 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -7,12 +7,27 @@ c = meson.get_compiler('c') # Get the conda prefix conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +is_windows = build_machine.system() == 'windows' is_macos = build_machine.system() == 'darwin' # Add conda lib directory to library path add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) -if is_macos +if is_windows + # Use MSVC on Windows + add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) + # Add SLEEF paths from environment variables + sleef_include_dir = run_command('cmd', '/c', 'echo %SLEEF_INCLUDE_DIR%', check: true).stdout().strip() + sleef_library_dir = run_command('cmd', '/c', 'echo %SLEEF_LIBRARY%', check: true).stdout().strip() + + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) + add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) + + sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) + sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) +elif is_macos + # Existing macOS configuration + conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() @@ -22,6 +37,8 @@ if is_macos sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) else + conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() + add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) endif From f64291c117cf0c3c2389bb1fdb345bf8e9038381 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 12:50:52 +0530 Subject: [PATCH 102/182] meson edit --- .github/workflows/windows.yml | 2 +- quaddtype/meson.build | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8302a1af..efdf1825 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -49,7 +49,7 @@ jobs: exit 1 fi ls -l "$CONDA_PREFIX/Library/include/sleef.h" - ls -l "$CONDA_PREFIX/Library/lib/sleef"* + ls -l "$CONDA_PREFIX/Library/lib/sleef*" - name: Install build dependencies run: | diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 48190d8b..7e344a6f 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -14,17 +14,20 @@ is_macos = build_machine.system() == 'darwin' add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) if is_windows - # Use MSVC on Windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) - # Add SLEEF paths from environment variables - sleef_include_dir = run_command('cmd', '/c', 'echo %SLEEF_INCLUDE_DIR%', check: true).stdout().strip() - sleef_library_dir = run_command('cmd', '/c', 'echo %SLEEF_LIBRARY%', check: true).stdout().strip() + + conda_env_dir = run_command('cmd', '/c', 'echo %CONDA_PREFIX%', check: true).stdout().strip() + sleef_include_dir = conda_env_dir + '\\Library\\include' + sleef_library_dir = conda_env_dir + '\\Library\\lib' add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) - sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) - sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) + sleef_lib = c.find_library('sleef', dirs: [sleef_library_dir]) + sleefquad_lib = c.find_library('sleefquad', dirs: [sleef_library_dir]) + + sleef_dep = declare_dependency(include_directories: include_directories(sleef_include_dir), + dependencies: [sleef_lib, sleefquad_lib]) elif is_macos # Existing macOS configuration conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() @@ -86,10 +89,12 @@ py.install_sources( ) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'quaddtype', -include_directories: includes + srcs, + c_args: ['-g', '-O0'] + (is_windows ? [] : ['-lsleef', '-lsleefquad']), + cpp_args: ['-g', '-O0'] + (is_windows ? [] : ['-lsleef', '-lsleefquad']), + link_args: is_windows ? ['-DEFAULTLIB:sleef', '-DEFAULTLIB:sleefquad'] : [], + dependencies: [sleef_dep] + (is_windows ? [] : [sleefquad_dep]), + install: true, + subdir: 'quaddtype', + include_directories: includes ) \ No newline at end of file From 710ad26dd9831d1d409e626a8ba26ca7ca76f377 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 12:54:18 +0530 Subject: [PATCH 103/182] meson edit --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index efdf1825..8302a1af 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -49,7 +49,7 @@ jobs: exit 1 fi ls -l "$CONDA_PREFIX/Library/include/sleef.h" - ls -l "$CONDA_PREFIX/Library/lib/sleef*" + ls -l "$CONDA_PREFIX/Library/lib/sleef"* - name: Install build dependencies run: | From 6c48ddcbe516cb24e18e3e2af88d5c53799accda Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 18:49:16 +0530 Subject: [PATCH 104/182] refactoring linux and macos --- .../workflows/build_wheels_and_release.yml | 68 ++++++++++++------- quaddtype/pyproject.toml | 60 +--------------- 2 files changed, 43 insertions(+), 85 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 37bc25eb..9b25d809 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -1,4 +1,4 @@ -name: Build quaddtype wheels and release +name: Build quaddtype wheels for Linux and macOS on: push: @@ -17,25 +17,53 @@ jobs: os: [ubuntu-latest, macos-13, macos-14] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 with: python-version: "3.10" - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.10" - - name: Build wheels + - name: Install SLEEF and other dependencies + shell: bash -l {0} run: | - python -m cibuildwheel --output-dir wheelhouse + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef + conda list + if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l "$CONDA_PREFIX/include/sleef.h" + ls -l "$CONDA_PREFIX/lib/libsleef"* + + - name: Install build dependencies + run: | + pip install -U pip + pip install cibuildwheel==2.20.0 ninja meson meson-python + + - name: Build wheels env: - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD: cp310-* CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + CIBW_BUILD_VERBOSITY: "1" + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}/include + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}/lib + shell: bash + run: | + export PATH="$CONDA_PREFIX/bin:$PATH" + python -m cibuildwheel --output-dir wheelhouse + if [ ! -f wheelhouse/*.whl ]; then echo "Wheel was not created" && exit 1; fi working-directory: ./quaddtype - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: path: ./quaddtype/wheelhouse/*.whl name: wheels-${{ matrix.os }} @@ -47,11 +75,11 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: path: dist - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.9.0 + uses: pypa/gh-action-pypi-publish@v1.8.5 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} @@ -66,28 +94,16 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 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 }} diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 08044968..49e5a70f 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -21,62 +21,4 @@ dependencies = [ [project.optional-dependencies] test = [ "pytest", -] - -[tool.cibuildwheel] -archs = ["auto64"] -skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] -test-command = """ -python -c "import platform; print('Python version:', platform.python_version())" -python -c "import sys; print('sys.platform:', sys.platform)" -python -c "import quaddtype; print('quaddtype imported successfully')" -pip install {package}[test] -pytest {project}/tests -""" -test-extras = ["test"] -manylinux-x86_64-image = "manylinux_2_28" - -[tool.cibuildwheel.linux] -before-all = ''' -set -ex -yum install -y wget -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -bash miniconda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -conda init bash -source ~/.bashrc -conda update -q conda -conda config --add channels conda-forge -conda config --set channel_priority strict -conda install -y -c conda-forge sleef -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h -ls -l $HOME/miniconda/lib/libsleef* -''' -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" } -repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" - -[tool.cibuildwheel.macos] -before-all = ''' -set -ex -ARCH=$(uname -m) -wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh -bash miniconda.sh -b -p $HOME/miniconda -export PATH="$HOME/miniconda/bin:$PATH" -source ~/.bash_profile -conda update -q conda -conda config --add channels conda-forge -conda config --set channel_priority strict -conda install -y -c conda-forge sleef -if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 -fi -ls -l $HOME/miniconda/include/sleef.h -ls -l $HOME/miniconda/lib/libsleef* -''' -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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} -repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file +] \ No newline at end of file From 2f47d2bca6d9c58a6b092b3e70a6bba0205bd457 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 18:54:41 +0530 Subject: [PATCH 105/182] fixing python env --- .github/workflows/build_wheels_and_release.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index 9b25d809..d2f18ffb 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -19,16 +19,12 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install Miniconda + - name: Set up Miniconda uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true python-version: "3.10" + activate-environment: build-env - name: Install SLEEF and other dependencies shell: bash -l {0} @@ -45,20 +41,20 @@ jobs: ls -l "$CONDA_PREFIX/lib/libsleef"* - name: Install build dependencies + shell: bash -l {0} run: | pip install -U pip pip install cibuildwheel==2.20.0 ninja meson meson-python - name: Build wheels + shell: bash -l {0} env: CIBW_BUILD: cp310-* CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_BUILD_VERBOSITY: "1" SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}/include SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}/lib - shell: bash run: | - export PATH="$CONDA_PREFIX/bin:$PATH" python -m cibuildwheel --output-dir wheelhouse if [ ! -f wheelhouse/*.whl ]; then echo "Wheel was not created" && exit 1; fi working-directory: ./quaddtype From 34cbc76a9f874cbea3f4abcf1108c9a96a4fe1ea Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 19:01:38 +0530 Subject: [PATCH 106/182] refactoring useless env --- .github/workflows/build_wheels_and_release.yml | 3 +-- quaddtype/meson.build | 18 ++++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml index d2f18ffb..8f3a121a 100644 --- a/.github/workflows/build_wheels_and_release.yml +++ b/.github/workflows/build_wheels_and_release.yml @@ -52,8 +52,7 @@ jobs: CIBW_BUILD: cp310-* CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_BUILD_VERBOSITY: "1" - SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}/include - SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}/lib + CIBW_ENVIRONMENT: CONDA_PREFIX=$CONDA_PREFIX run: | python -m cibuildwheel --output-dir wheelhouse if [ ! -f wheelhouse/*.whl ]; then echo "Wheel was not created" && exit 1; fi diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 7e344a6f..77bfbce1 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -28,26 +28,20 @@ if is_windows sleef_dep = declare_dependency(include_directories: include_directories(sleef_include_dir), dependencies: [sleef_lib, sleefquad_lib]) -elif is_macos - # Existing macOS configuration - conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() - sleef_include_dir = run_command('bash', '-c', 'echo $SLEEF_INCLUDE_DIR', check: true).stdout().strip() - sleef_library_dir = run_command('bash', '-c', 'echo $SLEEF_LIBRARY', check: true).stdout().strip() +else + # Linux and macOS configuration + sleef_include_dir = conda_prefix + '/include' + sleef_library_dir = conda_prefix + '/lib' add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) -else - conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() - add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) - sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib']) - sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib']) endif -if not sleef_dep.found() or not sleefquad_dep.found() - error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.') +if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) + error('SLEEF library not found. Please ensure it is installed in your conda environment.') endif incdir_numpy = run_command(py, From 240fcb365604ba0d92e2b08e04abea6f47092324 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 19:41:47 +0530 Subject: [PATCH 107/182] testing linux --- .github/workflows/build_linux.yml | 115 ++++++++++++++++++ .../workflows/build_wheels_and_release.yml | 104 ---------------- .../{windows.yml => build_windows.yml} | 2 +- quaddtype/pyproject.toml | 60 ++++++++- 4 files changed, 175 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/build_linux.yml delete mode 100644 .github/workflows/build_wheels_and_release.yml rename .github/workflows/{windows.yml => build_windows.yml} (99%) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml new file mode 100644 index 00000000..cdbac8b2 --- /dev/null +++ b/.github/workflows/build_linux.yml @@ -0,0 +1,115 @@ +name: Build quaddtype wheels for Linux + +on: + push: + branches: + - sep-workflows + tags: + - "v*" + pull_request: + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels + env: + CIBW_BUILD_VERBOSITY: "1" + CIBW_ARCHS_LINUX: "auto64" + CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_BEFORE_ALL_LINUX: | + set -ex + yum install -y wget + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + conda init bash + source ~/.bashrc + conda update -q conda + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y -c conda-forge sleef + if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l $HOME/miniconda/include/sleef.h + ls -l $HOME/miniconda/lib/libsleef* + CIBW_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" + CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" + CIBW_TEST_COMMAND: | + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" + run: | + python -m cibuildwheel --output-dir wheelhouse + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-${{ matrix.os }} + + publish_to_testpypi: + name: Publish to TestPyPI + needs: build_wheels + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: dist + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.8.5 + 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 + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/**/*.whl diff --git a/.github/workflows/build_wheels_and_release.yml b/.github/workflows/build_wheels_and_release.yml deleted file mode 100644 index 8f3a121a..00000000 --- a/.github/workflows/build_wheels_and_release.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Build quaddtype wheels for Linux and macOS - -on: - push: - branches: - - testing-pkg - tags: - - "v*" - pull_request: - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-13, macos-14] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.10" - activate-environment: build-env - - - name: Install SLEEF and other dependencies - shell: bash -l {0} - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef - conda list - if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l "$CONDA_PREFIX/include/sleef.h" - ls -l "$CONDA_PREFIX/lib/libsleef"* - - - name: Install build dependencies - shell: bash -l {0} - run: | - pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python - - - name: Build wheels - shell: bash -l {0} - env: - CIBW_BUILD: cp310-* - CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_BUILD_VERBOSITY: "1" - CIBW_ENVIRONMENT: CONDA_PREFIX=$CONDA_PREFIX - run: | - python -m cibuildwheel --output-dir wheelhouse - if [ ! -f wheelhouse/*.whl ]; then echo "Wheel was not created" && exit 1; fi - working-directory: ./quaddtype - - - uses: actions/upload-artifact@v3 - with: - path: ./quaddtype/wheelhouse/*.whl - name: wheels-${{ matrix.os }} - - publish_to_testpypi: - name: Publish to TestPyPI - needs: build_wheels - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 - 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 - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Create Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - files: ./artifacts/**/*.whl diff --git a/.github/workflows/windows.yml b/.github/workflows/build_windows.yml similarity index 99% rename from .github/workflows/windows.yml rename to .github/workflows/build_windows.yml index 8302a1af..1530614f 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/build_windows.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Windows on: push: branches: - - testing-pkg + - sep-workflows tags: - "v*" pull_request: diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 49e5a70f..c477fe36 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -21,4 +21,62 @@ dependencies = [ [project.optional-dependencies] test = [ "pytest", -] \ No newline at end of file +] + +# [tool.cibuildwheel] +# archs = ["auto64"] +# skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] +# test-command = """ +# python -c "import platform; print('Python version:', platform.python_version())" +# python -c "import sys; print('sys.platform:', sys.platform)" +# python -c "import quaddtype; print('quaddtype imported successfully')" +# pip install {package}[test] +# pytest {project}/tests +# """ +# test-extras = ["test"] +# manylinux-x86_64-image = "manylinux_2_28" + +# [tool.cibuildwheel.linux] +# before-all = ''' +# set -ex +# yum install -y wget +# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh +# bash miniconda.sh -b -p $HOME/miniconda +# export PATH="$HOME/miniconda/bin:$PATH" +# conda init bash +# source ~/.bashrc +# conda update -q conda +# conda config --add channels conda-forge +# conda config --set channel_priority strict +# conda install -y -c conda-forge sleef +# if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then +# echo "sleef.h not found. Installation may have failed." +# exit 1 +# fi +# ls -l $HOME/miniconda/include/sleef.h +# ls -l $HOME/miniconda/lib/libsleef* +# ''' +# 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" } +# repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" + +# [tool.cibuildwheel.macos] +# before-all = ''' +# set -ex +# ARCH=$(uname -m) +# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh +# bash miniconda.sh -b -p $HOME/miniconda +# export PATH="$HOME/miniconda/bin:$PATH" +# source ~/.bash_profile +# conda update -q conda +# conda config --add channels conda-forge +# conda config --set channel_priority strict +# conda install -y -c conda-forge sleef +# if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then +# echo "sleef.h not found. Installation may have failed." +# exit 1 +# fi +# ls -l $HOME/miniconda/include/sleef.h +# ls -l $HOME/miniconda/lib/libsleef* +# ''' +# 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} +# repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file From ddb5e0b7c041c333bd5ace04d7ea24be6603d1e3 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 19:51:02 +0530 Subject: [PATCH 108/182] testing macos --- .github/workflows/build_macos.yml | 114 ++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/workflows/build_macos.yml diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml new file mode 100644 index 00000000..1a2b427a --- /dev/null +++ b/.github/workflows/build_macos.yml @@ -0,0 +1,114 @@ +name: Build quaddtype wheels for macOS + +on: + push: + branches: + - sep-workflows + tags: + - "v*" + pull_request: + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13, macos-14] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels + env: + CIBW_BUILD_VERBOSITY: "1" + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BEFORE_ALL_MACOS: | + set -ex + ARCH=$(uname -m) + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + source ~/.bash_profile + conda update -q conda + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y -c conda-forge sleef + if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l $HOME/miniconda/include/sleef.h + ls -l $HOME/miniconda/lib/libsleef* + CIBW_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" + MACOSX_DEPLOYMENT_TARGET="10.13" + CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" + CIBW_TEST_COMMAND: | + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" + run: | + python -m cibuildwheel --output-dir wheelhouse + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-${{ matrix.os }} + + publish_to_testpypi: + name: Publish to TestPyPI + needs: build_wheels + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: dist + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.8.5 + 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 + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/**/*.whl From 8ede50843b14266732147197dd6ced5bb69aabe1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 19:54:21 +0530 Subject: [PATCH 109/182] testing macos --- .github/workflows/build_macos.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 1a2b427a..1b507135 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -38,7 +38,7 @@ jobs: wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda export PATH="$HOME/miniconda/bin:$PATH" - source ~/.bash_profile + source $HOME/miniconda/bin/activate conda update -q conda conda config --add channels conda-forge conda config --set channel_priority strict @@ -50,6 +50,8 @@ jobs: ls -l $HOME/miniconda/include/sleef.h ls -l $HOME/miniconda/lib/libsleef* CIBW_ENVIRONMENT: > + CONDA_PREFIX="$HOME/miniconda" + PATH="$HOME/miniconda/bin:$PATH" DYLD_LIBRARY_PATH="$HOME/miniconda/lib:$DYLD_LIBRARY_PATH" LIBRARY_PATH="$HOME/miniconda/lib:$LIBRARY_PATH" CFLAGS="-I$HOME/miniconda/include $CFLAGS" @@ -58,6 +60,7 @@ jobs: MACOSX_DEPLOYMENT_TARGET="10.13" CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" CIBW_TEST_COMMAND: | + python -c "import os; print('CONDA_PREFIX:', os.environ.get('CONDA_PREFIX', 'Not set'))" python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" From 9627822204fb24f1f01ce015dcf95ee2134fb57e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 19:59:46 +0530 Subject: [PATCH 110/182] testing macos --- .github/workflows/build_macos.yml | 51 ++++++++++++++----------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 1b507135..bb87431e 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -19,44 +19,39 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 with: + auto-update-conda: true python-version: "3.10" - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 + - name: Install dependencies + shell: bash -l {0} + run: | + pip install cibuildwheel==2.20.0 + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef + if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l $CONDA_PREFIX/include/sleef.h + ls -l $CONDA_PREFIX/lib/libsleef* - name: Build wheels + shell: bash -l {0} env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" - CIBW_BEFORE_ALL_MACOS: | - set -ex - ARCH=$(uname -m) - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - source $HOME/miniconda/bin/activate - conda update -q conda - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y -c conda-forge sleef - if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l $HOME/miniconda/include/sleef.h - ls -l $HOME/miniconda/lib/libsleef* CIBW_ENVIRONMENT: > - CONDA_PREFIX="$HOME/miniconda" - PATH="$HOME/miniconda/bin:$PATH" - 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" + PATH="$CONDA_PREFIX/bin:$PATH" + DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH" + LIBRARY_PATH="$CONDA_PREFIX/lib:$LIBRARY_PATH" + CFLAGS="-I$CONDA_PREFIX/include $CFLAGS" + CXXFLAGS="-I$CONDA_PREFIX/include $CXXFLAGS" + LDFLAGS="-L$CONDA_PREFIX/lib $LDFLAGS" MACOSX_DEPLOYMENT_TARGET="10.13" CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" CIBW_TEST_COMMAND: | From a46a3d02401291b0a8b050ecc7c5b7e09a7955d0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:03:21 +0530 Subject: [PATCH 111/182] testing mac --- .github/workflows/build_macos.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index bb87431e..e312af3a 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -24,14 +24,13 @@ jobs: with: auto-update-conda: true python-version: "3.10" + channels: conda-forge - name: Install dependencies shell: bash -l {0} run: | - pip install cibuildwheel==2.20.0 - conda config --add channels conda-forge - conda config --set channel_priority strict conda install -y sleef + pip install cibuildwheel==2.20.0 if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then echo "sleef.h not found. Installation may have failed." exit 1 @@ -46,6 +45,7 @@ jobs: CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ENVIRONMENT: > + CONDA_PREFIX="$CONDA_PREFIX" PATH="$CONDA_PREFIX/bin:$PATH" DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH" LIBRARY_PATH="$CONDA_PREFIX/lib:$LIBRARY_PATH" @@ -63,7 +63,7 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - python -m cibuildwheel --output-dir wheelhouse + cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype - uses: actions/upload-artifact@v3 From b551a27f3f8ddfee15803b41f6580b69ede4ca0b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:05:49 +0530 Subject: [PATCH 112/182] testing mac --- .github/workflows/build_macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index e312af3a..0dcdeaaa 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies shell: bash -l {0} run: | + conda activate test conda install -y sleef pip install cibuildwheel==2.20.0 if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then From 1f4f37000721a4dcfeee08a03070980d55207595 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:09:04 +0530 Subject: [PATCH 113/182] testing mac --- .github/workflows/build_macos.yml | 57 +++++++++++++++++-------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 0dcdeaaa..ffb1589b 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -19,44 +19,49 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + - name: Set up Python + uses: actions/setup-python@v4 with: - auto-update-conda: true python-version: "3.10" - channels: conda-forge - - name: Install dependencies - shell: bash -l {0} - run: | - conda activate test - conda install -y sleef - pip install cibuildwheel==2.20.0 - if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l $CONDA_PREFIX/include/sleef.h - ls -l $CONDA_PREFIX/lib/libsleef* + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 - name: Build wheels - shell: bash -l {0} env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BEFORE_ALL_MACOS: | + set -ex + ARCH=$(uname -m) + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + source ~/.bash_profile + conda update -q conda + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y -c conda-forge sleef + if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l $HOME/miniconda/include/sleef.h + ls -l $HOME/miniconda/lib/libsleef* CIBW_ENVIRONMENT: > - CONDA_PREFIX="$CONDA_PREFIX" - PATH="$CONDA_PREFIX/bin:$PATH" - DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH" - LIBRARY_PATH="$CONDA_PREFIX/lib:$LIBRARY_PATH" - CFLAGS="-I$CONDA_PREFIX/include $CFLAGS" - CXXFLAGS="-I$CONDA_PREFIX/include $CXXFLAGS" - LDFLAGS="-L$CONDA_PREFIX/lib $LDFLAGS" + CONDA_PREFIX="$HOME/miniconda" + PATH="$HOME/miniconda/bin:$PATH" + 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" + SLEEF_INCLUDE_DIR="$HOME/miniconda/include" + SLEEF_LIBRARY="$HOME/miniconda/lib" MACOSX_DEPLOYMENT_TARGET="10.13" CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" CIBW_TEST_COMMAND: | - python -c "import os; print('CONDA_PREFIX:', os.environ.get('CONDA_PREFIX', 'Not set'))" python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" @@ -64,7 +69,7 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - cibuildwheel --output-dir wheelhouse + python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype - uses: actions/upload-artifact@v3 From dff3ad6e37399df988767280131ea7f7f94ca8b1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:12:51 +0530 Subject: [PATCH 114/182] testing mac --- .github/workflows/build_macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index ffb1589b..dc773397 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -69,6 +69,7 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | + pip install cibuildwheel==2.20.0 python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype From 95460825d03b1bbabf4d71a3c5dfe8a31e101cd9 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:15:07 +0530 Subject: [PATCH 115/182] testing mac --- .github/workflows/build_linux.yml | 2 +- .github/workflows/build_macos.yml | 5 +---- .github/workflows/build_windows.yml | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index cdbac8b2..86f2b50d 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Linux on: push: branches: - - sep-workflows + - sep-workflow tags: - "v*" pull_request: diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index dc773397..596835ed 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -24,9 +24,6 @@ jobs: with: python-version: "3.10" - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 - - name: Build wheels env: CIBW_BUILD_VERBOSITY: "1" @@ -43,6 +40,7 @@ jobs: conda config --add channels conda-forge conda config --set channel_priority strict conda install -y -c conda-forge sleef + pip install cibuildwheel==2.20.0 if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then echo "sleef.h not found. Installation may have failed." exit 1 @@ -69,7 +67,6 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - pip install cibuildwheel==2.20.0 python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 1530614f..59189fb1 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Windows on: push: branches: - - sep-workflows + - sep-workflow tags: - "v*" pull_request: From 23db450bdc214de68c36936de23e96414c3b37ef Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:21:23 +0530 Subject: [PATCH 116/182] testing mac --- .github/workflows/build_macos.yml | 54 +++++++++++++------------------ 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 596835ed..017907bb 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -19,44 +19,26 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 with: + auto-update-conda: true python-version: "3.10" + channels: conda-forge - - name: Build wheels + - name: Install dependencies and build wheels + shell: bash -l {0} env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" - CIBW_BEFORE_ALL_MACOS: | - set -ex - ARCH=$(uname -m) - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - source ~/.bash_profile - conda update -q conda - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y -c conda-forge sleef - pip install cibuildwheel==2.20.0 - if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l $HOME/miniconda/include/sleef.h - ls -l $HOME/miniconda/lib/libsleef* CIBW_ENVIRONMENT: > - CONDA_PREFIX="$HOME/miniconda" - PATH="$HOME/miniconda/bin:$PATH" - 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" - SLEEF_INCLUDE_DIR="$HOME/miniconda/include" - SLEEF_LIBRARY="$HOME/miniconda/lib" + PATH="$CONDA_PREFIX/bin:$PATH" + DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH" + LIBRARY_PATH="$CONDA_PREFIX/lib:$LIBRARY_PATH" + CFLAGS="-I$CONDA_PREFIX/include $CFLAGS" + CXXFLAGS="-I$CONDA_PREFIX/include $CXXFLAGS" + LDFLAGS="-L$CONDA_PREFIX/lib $LDFLAGS" MACOSX_DEPLOYMENT_TARGET="10.13" CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" CIBW_TEST_COMMAND: | @@ -67,8 +49,16 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - python -m cibuildwheel --output-dir wheelhouse - working-directory: ./quaddtype + conda install -y -c conda-forge sleef + pip install cibuildwheel==2.20.0 + if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l $CONDA_PREFIX/include/sleef.h + ls -l $CONDA_PREFIX/lib/libsleef* + cd quaddtype + cibuildwheel --output-dir wheelhouse - uses: actions/upload-artifact@v3 with: From cefde3089db986308af61a5906d8f3f65011fc6c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:24:56 +0530 Subject: [PATCH 117/182] testing mac --- .github/workflows/build_macos.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 017907bb..3d0ae9b1 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -25,6 +25,7 @@ jobs: auto-update-conda: true python-version: "3.10" channels: conda-forge + activate-environment: build_env - name: Install dependencies and build wheels shell: bash -l {0} @@ -57,8 +58,10 @@ jobs: fi ls -l $CONDA_PREFIX/include/sleef.h ls -l $CONDA_PREFIX/lib/libsleef* + echo "Using Python: $(which python)" + echo "Using pip: $(which pip)" cd quaddtype - cibuildwheel --output-dir wheelhouse + python -m cibuildwheel --output-dir wheelhouse - uses: actions/upload-artifact@v3 with: From 87707c9290d5ba621037ab4f8885b17713aed2dd Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:27:02 +0530 Subject: [PATCH 118/182] testing mac --- .github/workflows/build_macos.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 3d0ae9b1..29ed027c 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -25,7 +25,6 @@ jobs: auto-update-conda: true python-version: "3.10" channels: conda-forge - activate-environment: build_env - name: Install dependencies and build wheels shell: bash -l {0} From 4b71bc8373903eb75616be2c35d314a3d3880f59 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:30:46 +0530 Subject: [PATCH 119/182] testing mac --- .github/workflows/build_macos.yml | 47 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 29ed027c..3d180619 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -19,29 +19,44 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Miniconda + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Setup Miniconda and install SLEEF uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true python-version: "3.10" channels: conda-forge + activate-environment: sleef_env - - name: Install dependencies and build wheels + - name: Install SLEEF shell: bash -l {0} + run: | + conda install -y -c conda-forge sleef + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels env: CIBW_BUILD_VERBOSITY: "1" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ENVIRONMENT: > - PATH="$CONDA_PREFIX/bin:$PATH" - DYLD_LIBRARY_PATH="$CONDA_PREFIX/lib:$DYLD_LIBRARY_PATH" - LIBRARY_PATH="$CONDA_PREFIX/lib:$LIBRARY_PATH" - CFLAGS="-I$CONDA_PREFIX/include $CFLAGS" - CXXFLAGS="-I$CONDA_PREFIX/include $CXXFLAGS" - LDFLAGS="-L$CONDA_PREFIX/lib $LDFLAGS" + SLEEF_PATH="${{ env.SLEEF_PATH }}" + DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" + LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" + CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" + CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" + LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" MACOSX_DEPLOYMENT_TARGET="10.13" CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" CIBW_TEST_COMMAND: | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" @@ -49,16 +64,12 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - conda install -y -c conda-forge sleef - pip install cibuildwheel==2.20.0 - if [ ! -f "$CONDA_PREFIX/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l $CONDA_PREFIX/include/sleef.h - ls -l $CONDA_PREFIX/lib/libsleef* - echo "Using Python: $(which python)" - echo "Using pip: $(which pip)" + echo "SLEEF_PATH: $SLEEF_PATH" + echo "PATH: $PATH" + which python + python --version + which pip + pip --version cd quaddtype python -m cibuildwheel --output-dir wheelhouse From 3e0cd78bd35f864c7a12b10e9fc871652d1e33c8 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:35:59 +0530 Subject: [PATCH 120/182] testing mac --- .github/workflows/build_macos.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 3d180619..eb4d135a 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -24,18 +24,18 @@ jobs: with: python-version: "3.10" - - name: Setup Miniconda and install SLEEF + - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true python-version: "3.10" channels: conda-forge - activate-environment: sleef_env - name: Install SLEEF shell: bash -l {0} run: | conda install -y -c conda-forge sleef + echo $CONDA_PREFIX echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV - name: Install cibuildwheel @@ -47,6 +47,7 @@ jobs: CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ENVIRONMENT: > + CONDA_PREFIX= SLEEF_PATH="${{ env.SLEEF_PATH }}" DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" From 42788432299bfbea4dd150240cfb8c0918825d2a Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 20:41:02 +0530 Subject: [PATCH 121/182] testing mac --- .github/workflows/build_macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index eb4d135a..d2d9a909 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -47,7 +47,6 @@ jobs: CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ENVIRONMENT: > - CONDA_PREFIX= SLEEF_PATH="${{ env.SLEEF_PATH }}" DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" @@ -66,6 +65,7 @@ jobs: CIBW_TEST_EXTRAS: "test" run: | echo "SLEEF_PATH: $SLEEF_PATH" + ls $SLEEF_PATH/include/sleef* echo "PATH: $PATH" which python python --version From b200adb084aec3dc810565fffcc6de51c3f6eca3 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:04:57 +0530 Subject: [PATCH 122/182] testing mac --- quaddtype/meson.build | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 77bfbce1..0b04281d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -5,13 +5,21 @@ py = py_mod.find_installation() c = meson.get_compiler('c') -# Get the conda prefix -conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip() +# Get the SLEEF path +sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() +if sleef_path == '' + sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() +endif + +if sleef_path == '' + error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') +endif + is_windows = build_machine.system() == 'windows' is_macos = build_machine.system() == 'darwin' -# Add conda lib directory to library path -add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp']) +# Add SLEEF lib directory to library path +add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) if is_windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) @@ -30,8 +38,8 @@ if is_windows dependencies: [sleef_lib, sleefquad_lib]) else # Linux and macOS configuration - sleef_include_dir = conda_prefix + '/include' - sleef_library_dir = conda_prefix + '/lib' + sleef_include_dir = sleef_path + '/include' + sleef_library_dir = sleef_path + '/lib' add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 3e0938e18f61b98cb7f6b9a74fb899131b737de3 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:09:51 +0530 Subject: [PATCH 123/182] testing mac --- .github/workflows/build_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 86f2b50d..cdbac8b2 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Linux on: push: branches: - - sep-workflow + - sep-workflows tags: - "v*" pull_request: From 8d110df3c3112164a876837f570631efa3dfde89 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:15:56 +0530 Subject: [PATCH 124/182] testing mac --- .github/workflows/build_linux.yml | 55 ++++++++++++++++++------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index cdbac8b2..8d5c6fbb 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -24,6 +24,20 @@ jobs: with: python-version: "3.10" + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.10" + channels: conda-forge + + - name: Install SLEEF + shell: bash -l {0} + run: | + conda install -y -c conda-forge sleef + echo $CONDA_PREFIX + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 @@ -33,32 +47,20 @@ jobs: CIBW_ARCHS_LINUX: "auto64" CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_ENVIRONMENT: > + SLEEF_PATH="${{ env.SLEEF_PATH }}" + LD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LD_LIBRARY_PATH" + LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" + CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" + CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" + LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" CIBW_BEFORE_ALL_LINUX: | - set -ex yum install -y wget - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - conda init bash - source ~/.bashrc - conda update -q conda - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y -c conda-forge sleef - if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l $HOME/miniconda/include/sleef.h - ls -l $HOME/miniconda/lib/libsleef* - CIBW_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" + . $SLEEF_PATH/etc/profile.d/conda.sh + conda activate base CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" CIBW_TEST_COMMAND: | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" @@ -66,8 +68,15 @@ jobs: pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | + echo "SLEEF_PATH: $SLEEF_PATH" + ls $SLEEF_PATH/include/sleef* + echo "PATH: $PATH" + which python + python --version + which pip + pip --version + cd quaddtype python -m cibuildwheel --output-dir wheelhouse - working-directory: ./quaddtype - uses: actions/upload-artifact@v3 with: From b0753c595fe3eee8390dcef8619cc3e68b5f9348 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:19:14 +0530 Subject: [PATCH 125/182] testing mac --- .github/workflows/build_linux.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 8d5c6fbb..1f043397 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -54,10 +54,6 @@ jobs: CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" - CIBW_BEFORE_ALL_LINUX: | - yum install -y wget - . $SLEEF_PATH/etc/profile.d/conda.sh - conda activate base CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" CIBW_TEST_COMMAND: | python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" From eee4533990642023d76886454ca8fe13d980ec50 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:24:44 +0530 Subject: [PATCH 126/182] testing mac --- quaddtype/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 0b04281d..4a4d0c04 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -14,7 +14,7 @@ endif if sleef_path == '' error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') endif - +message('SLEEF_PATH from environment: ', sleef_path) is_windows = build_machine.system() == 'windows' is_macos = build_machine.system() == 'darwin' From e57909ee0491418b87d5d2eaf7f3e1447f9402c1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:30:21 +0530 Subject: [PATCH 127/182] testing mac --- quaddtype/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 4a4d0c04..3af845ec 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -14,9 +14,8 @@ endif if sleef_path == '' error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') endif -message('SLEEF_PATH from environment: ', sleef_path) + is_windows = build_machine.system() == 'windows' -is_macos = build_machine.system() == 'darwin' # Add SLEEF lib directory to library path add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) @@ -40,7 +39,8 @@ else # Linux and macOS configuration sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' - + message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/include/sleef*', check: false).stdout().strip()) + message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/lib/libsleef*', check: false).stdout().strip()) add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 959c9befe62675fe07ba08ea426d4fbf76249849 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:34:05 +0530 Subject: [PATCH 128/182] testing mac --- .github/workflows/build_linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 1f043397..30b15472 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -37,6 +37,7 @@ jobs: conda install -y -c conda-forge sleef echo $CONDA_PREFIX echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + ls $CONDA_PREFIX/include/sleef* - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 From 7a56e410d9d9402031557c75e40bf7dc9a544969 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:37:15 +0530 Subject: [PATCH 129/182] testing mac --- quaddtype/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 3af845ec..3c2423e5 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -39,6 +39,7 @@ else # Linux and macOS configuration sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' + message('$SLEEF_PATH: ', sleef_path) message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/include/sleef*', check: false).stdout().strip()) message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/lib/libsleef*', check: false).stdout().strip()) add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) From 2f0e02ef0ac4db3c4b1e203deda80854a1e4110e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:40:08 +0530 Subject: [PATCH 130/182] testing mac --- quaddtype/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 3c2423e5..993469f1 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -40,7 +40,7 @@ else sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' message('$SLEEF_PATH: ', sleef_path) - message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/include/sleef*', check: false).stdout().strip()) + message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls -l $SLEEF_PATH/include', check: false).stdout().strip()) message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/lib/libsleef*', check: false).stdout().strip()) add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 59ac1558b6ff9c016b1a70fa149061e4b2d67c24 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:42:38 +0530 Subject: [PATCH 131/182] testing mac --- quaddtype/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 993469f1..2eae671d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -40,7 +40,7 @@ else sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' message('$SLEEF_PATH: ', sleef_path) - message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls -l $SLEEF_PATH/include', check: false).stdout().strip()) + message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls -l $SLEEF_PATH', check: false).stdout().strip()) message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/lib/libsleef*', check: false).stdout().strip()) add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 5373d0b93b2c966accbe1c3d682c3ff3f20dcea0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 21:47:10 +0530 Subject: [PATCH 132/182] testing mac --- quaddtype/meson.build | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 2eae671d..9060db49 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -40,8 +40,17 @@ else sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' message('$SLEEF_PATH: ', sleef_path) - message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls -l $SLEEF_PATH', check: false).stdout().strip()) - message('SLEEF_PATH from environment: ', run_command('bash', '-c', 'ls $SLEEF_PATH/lib/libsleef*', check: false).stdout().strip()) + ls_command = 'ls ' + sleef_path + '/include/sleef*' + ls_result = run_command('bash', '-c', ls_command, check: false) + + if ls_result.returncode() == 0 + message('SLEEF libraries found:') + foreach line : ls_result.stdout().strip().split('\n') + message(' - ', line) + endforeach + else + message('Error listing SLEEF libraries: ', ls_result.stderr().strip()) +endif add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 63fa5791406d1ae15a98402d58df105935ef4456 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 22:10:44 +0530 Subject: [PATCH 133/182] testing mac --- .github/workflows/build_linux.yml | 79 ++++++++++--------------------- quaddtype/meson.build | 13 +---- 2 files changed, 27 insertions(+), 65 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 30b15472..42af2151 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,19 +3,15 @@ name: Build quaddtype wheels for Linux on: push: branches: - - sep-workflows + - testing-pkg tags: - "v*" pull_request: jobs: build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - + name: Build wheels on Linux + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -24,61 +20,41 @@ jobs: with: python-version: "3.10" - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.10" - channels: conda-forge - - - name: Install SLEEF - shell: bash -l {0} - run: | - conda install -y -c conda-forge sleef - echo $CONDA_PREFIX - echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV - ls $CONDA_PREFIX/include/sleef* - - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 - name: Build wheels env: + CIBW_BUILD: cp310-manylinux_x86_64 + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28_x86_64 CIBW_BUILD_VERBOSITY: "1" - CIBW_ARCHS_LINUX: "auto64" - CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-* cp38-* cp39-* cp313-*" - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_ENVIRONMENT: > - SLEEF_PATH="${{ env.SLEEF_PATH }}" - LD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LD_LIBRARY_PATH" - LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" - CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" - CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" - LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" - CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" - CIBW_TEST_COMMAND: | - python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" - pip install {package}[test] - pytest {project}/tests - CIBW_TEST_EXTRAS: "test" + CIBW_BEFORE_ALL: | + yum install -y wget + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + conda config --set always_yes yes --set changeps1 no + conda update -q conda + conda info -a + conda config --add channels conda-forge + conda config --set channel_priority strict + conda create -n build_env python=3.10 + source activate build_env + conda install -y sleef + conda list + CIBW_ENVIRONMENT: >- + PATH="$HOME/miniconda/bin:$PATH" + CONDA_PREFIX="$HOME/miniconda/envs/build_env" + CIBW_REPAIR_WHEEL_COMMAND: > + auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} run: | - echo "SLEEF_PATH: $SLEEF_PATH" - ls $SLEEF_PATH/include/sleef* - echo "PATH: $PATH" - which python - python --version - which pip - pip --version - cd quaddtype python -m cibuildwheel --output-dir wheelhouse + working-directory: ./quaddtype - uses: actions/upload-artifact@v3 with: path: ./quaddtype/wheelhouse/*.whl - name: wheels-${{ matrix.os }} + name: wheels-linux publish_to_testpypi: name: Publish to TestPyPI @@ -103,16 +79,13 @@ jobs: needs: build_wheels runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - steps: - name: Checkout code uses: actions/checkout@v3 - - name: Download all workflow run artifacts uses: actions/download-artifact@v3 with: path: artifacts - - name: Create Release env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 9060db49..20ae3353 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -39,18 +39,7 @@ else # Linux and macOS configuration sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' - message('$SLEEF_PATH: ', sleef_path) - ls_command = 'ls ' + sleef_path + '/include/sleef*' - ls_result = run_command('bash', '-c', ls_command, check: false) - - if ls_result.returncode() == 0 - message('SLEEF libraries found:') - foreach line : ls_result.stdout().strip().split('\n') - message(' - ', line) - endforeach - else - message('Error listing SLEEF libraries: ', ls_result.stderr().strip()) -endif + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) From 8b3192b15e750d8cc8a33c26a823fd7f48fd8837 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 22:12:16 +0530 Subject: [PATCH 134/182] testing mac --- .github/workflows/build_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 42af2151..a10e7095 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Linux on: push: branches: - - testing-pkg + - sep-workflows tags: - "v*" pull_request: From c75c11d28288ac32c959d9b9669e486fb18b3690 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 22:13:04 +0530 Subject: [PATCH 135/182] testing mac --- .github/workflows/build_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index a10e7095..5a4e5167 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -26,7 +26,7 @@ jobs: - name: Build wheels env: CIBW_BUILD: cp310-manylinux_x86_64 - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28_x86_64 + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "1" CIBW_BEFORE_ALL: | yum install -y wget From 43d664c31d91607bd1511a0120c58f52a8242da4 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 22:15:51 +0530 Subject: [PATCH 136/182] testing mac --- .github/workflows/build_linux.yml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 5a4e5167..0b8bc436 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -27,12 +27,12 @@ jobs: env: CIBW_BUILD: cp310-manylinux_x86_64 CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" + bash miniconda.sh -b -p /root/miniconda + export PATH="/root/miniconda/bin:$PATH" conda config --set always_yes yes --set changeps1 no conda update -q conda conda info -a @@ -42,11 +42,22 @@ jobs: source activate build_env conda install -y sleef conda list - CIBW_ENVIRONMENT: >- - PATH="$HOME/miniconda/bin:$PATH" - CONDA_PREFIX="$HOME/miniconda/envs/build_env" + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + CIBW_ENVIRONMENT: > + PATH="/root/miniconda/envs/build_env/bin:$PATH" + LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" + LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" + CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" + CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS" + LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS" + SLEEF_PATH="/root/miniconda/envs/build_env" CIBW_REPAIR_WHEEL_COMMAND: > auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} + CIBW_TEST_COMMAND: | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" run: | python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype From 90d9534667b9a32a315b89199c1932f1b6a5fa33 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 22:18:35 +0530 Subject: [PATCH 137/182] testing mac --- .github/workflows/build_linux.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 0b8bc436..85aea1a4 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -41,8 +41,6 @@ jobs: conda create -n build_env python=3.10 source activate build_env conda install -y sleef - conda list - echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV CIBW_ENVIRONMENT: > PATH="/root/miniconda/envs/build_env/bin:$PATH" LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" From 5e59a0e851c942973d041db8ef883b290d9bb69c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 23:27:22 +0530 Subject: [PATCH 138/182] testing mac --- .github/workflows/build_linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 85aea1a4..bb620288 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -42,7 +42,6 @@ jobs: source activate build_env conda install -y sleef CIBW_ENVIRONMENT: > - PATH="/root/miniconda/envs/build_env/bin:$PATH" LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" From 659c2ad1e2d6cc72c91da8923c2df7200ac6125f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 23:34:38 +0530 Subject: [PATCH 139/182] testing mac --- .github/workflows/build_macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index d2d9a909..f7b91987 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ">=3.10.0" - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v3 From 2375e0d7e85b82ddc819a2d914a3bf119baf6690 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 23:34:50 +0530 Subject: [PATCH 140/182] testing mac --- .github/workflows/build_linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index bb620288..d609f7c1 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ">=3.10.0" - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 From 7bdea6f84b65cbe93db11a3933478bca1e1ff1f0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Sun, 25 Aug 2024 23:56:17 +0530 Subject: [PATCH 141/182] testing mac --- .github/workflows/build_linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index d609f7c1..2ee645d7 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -25,7 +25,6 @@ jobs: - name: Build wheels env: - CIBW_BUILD: cp310-manylinux_x86_64 CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | From c473eb762aaf41361e43fbed79d31900a9493264 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 00:10:21 +0530 Subject: [PATCH 142/182] testing mac --- .github/workflows/build_linux.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 2ee645d7..d2b32c33 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -25,6 +25,7 @@ jobs: - name: Build wheels env: + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | From 0059e1548b86d61c668510933a0794dd41d66cfc Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 00:14:17 +0530 Subject: [PATCH 143/182] final test --- .github/workflows/build_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 59189fb1..1530614f 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -3,7 +3,7 @@ name: Build quaddtype wheels for Windows on: push: branches: - - sep-workflow + - sep-workflows tags: - "v*" pull_request: From decab079689f5336023d01fe812d894c823cd83e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 06:31:24 +0530 Subject: [PATCH 144/182] testing win --- .github/workflows/build_windows.yml | 4 ++-- quaddtype/meson.build | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 1530614f..90ea74c3 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -14,7 +14,7 @@ jobs: runs-on: windows-latest strategy: matrix: - architecture: [x64, x86] + architecture: [x64] steps: - uses: actions/checkout@v3 @@ -54,7 +54,7 @@ jobs: - name: Install build dependencies run: | pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy - name: Build wheels env: diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 20ae3353..b68c5a6c 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -39,7 +39,7 @@ else # Linux and macOS configuration sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' - + add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) @@ -56,9 +56,11 @@ incdir_numpy = run_command(py, '-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' ], - check: true + check: false ).stdout().strip() +message("numpy directory: ", incdir_numpy) + includes = include_directories( [ incdir_numpy, From 4ed0f2dc244cc93d5e346749f03ec7ac0918c45a Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 06:34:49 +0530 Subject: [PATCH 145/182] testing win --- quaddtype/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index b68c5a6c..6f18c759 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -59,7 +59,7 @@ incdir_numpy = run_command(py, check: false ).stdout().strip() -message("numpy directory: ", incdir_numpy) +message('numpy directory: ', incdir_numpy) includes = include_directories( [ From b79048c005590c74c8b73dbebf7965355dd3a9b5 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 06:45:24 +0530 Subject: [PATCH 146/182] testing win --- .github/workflows/build_windows.yml | 6 +++--- quaddtype/meson.build | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 90ea74c3..70a76126 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -42,7 +42,7 @@ jobs: run: | conda config --add channels conda-forge conda config --set channel_priority strict - conda install -y sleef + conda install -y sleef numpy conda list if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then echo "sleef.h not found. Installation may have failed." @@ -54,7 +54,7 @@ jobs: - name: Install build dependencies run: | pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python numpy + pip install cibuildwheel==2.20.0 ninja meson meson-python - name: Build wheels env: @@ -65,9 +65,9 @@ jobs: SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib DISTUTILS_USE_SDK: "1" MSSdk: "1" + NUMPY_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Lib\site-packages\numpy\core\include shell: pwsh run: | - $env:PATH = "$env:CONDA_PREFIX\Library\bin;$env:PATH" python -m cibuildwheel --output-dir wheelhouse if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } working-directory: ./quaddtype diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 6f18c759..b6b612b2 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -93,10 +93,11 @@ py.install_sources( py.extension_module('_quaddtype_main', srcs, - c_args: ['-g', '-O0'] + (is_windows ? [] : ['-lsleef', '-lsleefquad']), - cpp_args: ['-g', '-O0'] + (is_windows ? [] : ['-lsleef', '-lsleefquad']), - link_args: is_windows ? ['-DEFAULTLIB:sleef', '-DEFAULTLIB:sleefquad'] : [], + c_args: is_windows ? ['/DWIN32', '/D_WINDOWS'] : ['-g', '-O0'], + cpp_args: is_windows ? ['/DWIN32', '/D_WINDOWS', '/EHsc'] : ['-g', '-O0'], + link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'], dependencies: [sleef_dep] + (is_windows ? [] : [sleefquad_dep]), + link_language: 'cpp', install: true, subdir: 'quaddtype', include_directories: includes From ffdb44b46df6ac7f4f5e47fe5a383b39852b0c8c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 06:50:28 +0530 Subject: [PATCH 147/182] testing win --- .github/workflows/build_windows.yml | 2 +- quaddtype/meson.build | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 70a76126..768f7ea1 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -54,7 +54,7 @@ jobs: - name: Install build dependencies run: | pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy - name: Build wheels env: diff --git a/quaddtype/meson.build b/quaddtype/meson.build index b6b612b2..9aa99131 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -56,11 +56,9 @@ incdir_numpy = run_command(py, '-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' ], - check: false + check: true ).stdout().strip() -message('numpy directory: ', incdir_numpy) - includes = include_directories( [ incdir_numpy, From 89e0f90603b51cba5a4725e27d1f68328d2f6267 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:00:12 +0530 Subject: [PATCH 148/182] testing win --- .github/workflows/build_windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 768f7ea1..e8029583 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -52,11 +52,13 @@ jobs: ls -l "$CONDA_PREFIX/Library/lib/sleef"* - name: Install build dependencies + shell: bash -l {0} run: | pip install -U pip pip install cibuildwheel==2.20.0 ninja meson meson-python numpy - name: Build wheels + shell: bash -l {0} env: CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} @@ -66,7 +68,6 @@ jobs: DISTUTILS_USE_SDK: "1" MSSdk: "1" NUMPY_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Lib\site-packages\numpy\core\include - shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } From 795938e38bbfd4efa4807a53886038547e04bd55 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:05:34 +0530 Subject: [PATCH 149/182] testing win --- .github/workflows/build_windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index e8029583..a6f07ad6 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -50,6 +50,7 @@ jobs: fi ls -l "$CONDA_PREFIX/Library/include/sleef.h" ls -l "$CONDA_PREFIX/Library/lib/sleef"* + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV - name: Install build dependencies shell: bash -l {0} @@ -58,7 +59,6 @@ jobs: pip install cibuildwheel==2.20.0 ninja meson meson-python numpy - name: Build wheels - shell: bash -l {0} env: CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} @@ -68,6 +68,7 @@ jobs: DISTUTILS_USE_SDK: "1" MSSdk: "1" NUMPY_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Lib\site-packages\numpy\core\include + shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } From 3c6bf2e4dec95ad05c718739882bbdfff2659f5e Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:11:50 +0530 Subject: [PATCH 150/182] testing win --- .github/workflows/build_windows.yml | 3 ++- h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 h diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index a6f07ad6..ecd13b45 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -50,7 +50,7 @@ jobs: fi ls -l "$CONDA_PREFIX/Library/include/sleef.h" ls -l "$CONDA_PREFIX/Library/lib/sleef"* - echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + echo $CONDA_PREFIX >> $GITHUB_ENV - name: Install build dependencies shell: bash -l {0} @@ -60,6 +60,7 @@ jobs: - name: Build wheels env: + CONDA_PREFIX: ${{ env.CONDA_PREFIX }} CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} CIBW_BUILD_VERBOSITY: "1" diff --git a/h b/h new file mode 100644 index 00000000..a661abaa --- /dev/null +++ b/h @@ -0,0 +1 @@ +/Users/swayam From 51d9eab51e9c657b3471ef213ab43f399df3fe6c Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:18:05 +0530 Subject: [PATCH 151/182] testing win --- .github/workflows/build_windows.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index ecd13b45..6912bc8f 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -50,7 +50,11 @@ jobs: fi ls -l "$CONDA_PREFIX/Library/include/sleef.h" ls -l "$CONDA_PREFIX/Library/lib/sleef"* - echo $CONDA_PREFIX >> $GITHUB_ENV + + - name: Set CONDA_PREFIX in GitHub Environment + shell: pwsh + run: | + echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install build dependencies shell: bash -l {0} From 111a23a9b1c3e1e759a019d82622b3effc6df1d9 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:32:09 +0530 Subject: [PATCH 152/182] testing win --- .github/workflows/build_windows.yml | 20 +++++++++++--------- quaddtype/meson.build | 22 +++++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 6912bc8f..e8801021 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -55,6 +55,7 @@ jobs: shell: pwsh run: | echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "NUMPY_INCLUDE_DIR=$env:CONDA_PREFIX\Lib\site-packages\numpy\core\include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install build dependencies shell: bash -l {0} @@ -64,15 +65,16 @@ jobs: - name: Build wheels env: - CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} - CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} - CIBW_BUILD_VERBOSITY: "1" - SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include - SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib - DISTUTILS_USE_SDK: "1" - MSSdk: "1" - NUMPY_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Lib\site-packages\numpy\core\include + CIBW_ENVIRONMENT: >- + CONDA_PREFIX: ${{ env.CONDA_PREFIX }} + CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} + CIBW_BUILD_VERBOSITY: "1" + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib + DISTUTILS_USE_SDK: "1" + MSSdk: "1" + NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 9aa99131..a1051871 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -51,13 +51,21 @@ if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) error('SLEEF library not found. Please ensure it is installed in your conda environment.') endif -incdir_numpy = run_command(py, - [ - '-c', - 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' - ], - check: true -).stdout().strip() +# Try to get NumPy include path from environment variable first +numpy_include = get_option('NUMPY_INCLUDE_DIR') +if numpy_include == '' + numpy_include = run_command(py, + [ + '-c', + 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' + ], + check: false + ).stdout().strip() + + if numpy_include == '' + error('NumPy include directory not found. Please set NUMPY_INCLUDE_DIR or ensure NumPy is installed.') + endif +endif includes = include_directories( [ From 10cb69ed616c8619c7269770008f077160791e08 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:35:42 +0530 Subject: [PATCH 153/182] testing win --- .github/workflows/build_windows.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index e8801021..8081bb75 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -65,16 +65,17 @@ jobs: - name: Build wheels env: + CONDA_PREFIX: ${{ env.CONDA_PREFIX }} + CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} + CIBW_BUILD_VERBOSITY: "1" + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib + DISTUTILS_USE_SDK: "1" + MSSdk: "1" + NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} CIBW_ENVIRONMENT: >- - CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} - CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} - CIBW_BUILD_VERBOSITY: "1" - SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include - SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib - DISTUTILS_USE_SDK: "1" - MSSdk: "1" - NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} + NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse From 257a6e598a726aba11b9d6309701c8284388a033 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:40:35 +0530 Subject: [PATCH 154/182] testing win --- quaddtype/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index a1051871..a82a1bfb 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -52,7 +52,7 @@ if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) endif # Try to get NumPy include path from environment variable first -numpy_include = get_option('NUMPY_INCLUDE_DIR') +numpy_include = run_command('cmd', '/c', 'echo %NUMPY_INCLUDE_DIR%', check: true).stdout().strip() if numpy_include == '' numpy_include = run_command(py, [ From 38dfad8b4884fe0dba02a4833132b3dc45e1b167 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 07:44:28 +0530 Subject: [PATCH 155/182] testing win --- quaddtype/meson.build | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quaddtype/meson.build b/quaddtype/meson.build index a82a1bfb..bbc7cb92 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -26,6 +26,7 @@ if is_windows conda_env_dir = run_command('cmd', '/c', 'echo %CONDA_PREFIX%', check: true).stdout().strip() sleef_include_dir = conda_env_dir + '\\Library\\include' sleef_library_dir = conda_env_dir + '\\Library\\lib' + incdir_numpy = run_command('cmd', '/c', 'echo %NUMPY_INCLUDE_DIR%', check: true).stdout().strip() add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) @@ -52,9 +53,8 @@ if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) endif # Try to get NumPy include path from environment variable first -numpy_include = run_command('cmd', '/c', 'echo %NUMPY_INCLUDE_DIR%', check: true).stdout().strip() -if numpy_include == '' - numpy_include = run_command(py, +if incdir_numpy == '' + incdir_numpy = run_command(py, [ '-c', 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' @@ -62,7 +62,7 @@ if numpy_include == '' check: false ).stdout().strip() - if numpy_include == '' + if incdir_numpy == '' error('NumPy include directory not found. Please set NUMPY_INCLUDE_DIR or ensure NumPy is installed.') endif endif From 9646bb897d95ffae5b053f9bee43e4ac8d525e31 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 12:57:15 +0530 Subject: [PATCH 156/182] testing win --- .github/workflows/build_windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 8081bb75..4f3f709a 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -55,7 +55,8 @@ jobs: shell: pwsh run: | echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "NUMPY_INCLUDE_DIR=$env:CONDA_PREFIX\Lib\site-packages\numpy\core\include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" + echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install build dependencies shell: bash -l {0} From 8d1a44a87482d0ff15a1ed888712cb6abb3896d0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 13:05:14 +0530 Subject: [PATCH 157/182] testing win --- .github/workflows/build_windows.yml | 7 +------ quaddtype/meson.build | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 4f3f709a..0c3e62c2 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -58,12 +58,6 @@ jobs: $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Install build dependencies - shell: bash -l {0} - run: | - pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python numpy - - name: Build wheels env: CONDA_PREFIX: ${{ env.CONDA_PREFIX }} @@ -77,6 +71,7 @@ jobs: NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} CIBW_ENVIRONMENT: >- NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" + CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse diff --git a/quaddtype/meson.build b/quaddtype/meson.build index bbc7cb92..5bec1050 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -1,4 +1,4 @@ -project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true']) +project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++20', 'b_pie=true']) py_mod = import('python') py = py_mod.find_installation() @@ -20,6 +20,7 @@ is_windows = build_machine.system() == 'windows' # Add SLEEF lib directory to library path add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) +incdir_numpy = '' if is_windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) From 44781ae9e46b3eba02e1004a3ad3c43aca24f1c0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 13:08:12 +0530 Subject: [PATCH 158/182] testing win --- .github/workflows/build_windows.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 0c3e62c2..eef675cd 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -58,6 +58,12 @@ jobs: $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Install build dependencies + shell: bash -l {0} + run: | + pip install -U pip + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy + - name: Build wheels env: CONDA_PREFIX: ${{ env.CONDA_PREFIX }} From afff7cfa0a48280e07e4b64ba1a5c87ac66b5847 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 13:16:54 +0530 Subject: [PATCH 159/182] testing win --- .github/workflows/build_windows.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index eef675cd..c23c3cea 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -51,7 +51,7 @@ jobs: ls -l "$CONDA_PREFIX/Library/include/sleef.h" ls -l "$CONDA_PREFIX/Library/lib/sleef"* - - name: Set CONDA_PREFIX in GitHub Environment + - name: Set environment variables shell: pwsh run: | echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append @@ -62,12 +62,12 @@ jobs: shell: bash -l {0} run: | pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python numpy + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest - name: Build wheels env: CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} + CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} cp311-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} cp312-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} CIBW_BUILD_VERBOSITY: "1" SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include @@ -77,7 +77,17 @@ jobs: NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} CIBW_ENVIRONMENT: >- NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" + SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include" + SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib" CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy + CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" + CIBW_TEST_COMMAND: | + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse From d4e007e24d5390fdfd05d327ae69254728278bf0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 13:33:16 +0530 Subject: [PATCH 160/182] testing win --- .github/workflows/build_linux.yml | 39 +------------------- .github/workflows/build_macos.yml | 40 --------------------- .github/workflows/build_windows.yml | 42 +--------------------- .github/workflows/release_and_pypi.yml | 50 ++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/release_and_pypi.yml diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index d2b32c33..7f530edf 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -25,7 +25,7 @@ jobs: - name: Build wheels env: - CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" + CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | @@ -63,40 +63,3 @@ jobs: with: path: ./quaddtype/wheelhouse/*.whl name: wheels-linux - - publish_to_testpypi: - name: Publish to TestPyPI - needs: build_wheels - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 - 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 - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - name: Create Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - files: ./artifacts/**/*.whl diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index f7b91987..501940b6 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -78,43 +78,3 @@ jobs: with: path: ./quaddtype/wheelhouse/*.whl name: wheels-${{ matrix.os }} - - publish_to_testpypi: - name: Publish to TestPyPI - needs: build_wheels - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 - 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 - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Create Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - files: ./artifacts/**/*.whl diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index c23c3cea..a6a4ed87 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -67,7 +67,7 @@ jobs: - name: Build wheels env: CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - CIBW_BUILD: cp310-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} cp311-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} cp312-win_${{ matrix.architecture == 'x86' && 'win32' || 'amd64' }} + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} CIBW_BUILD_VERBOSITY: "1" SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include @@ -98,43 +98,3 @@ jobs: with: path: ./quaddtype/wheelhouse/*.whl name: wheels-windows-${{ matrix.architecture }} - - publish_to_testpypi: - name: Publish to TestPyPI - needs: build_wheels - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: dist - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 - 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 - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Create Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - files: ./artifacts/**/*.whl diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml new file mode 100644 index 00000000..a767a423 --- /dev/null +++ b/.github/workflows/release_and_pypi.yml @@ -0,0 +1,50 @@ +name: Release and Publish to TestPyPI + +on: + push: + branches: + - sep-workflows + tags: + - "v*" + workflow_dispatch: + +jobs: + publish_to_testpypi: + name: Publish to TestPyPI + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: dist + + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.8.5 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + packages-dir: dist/* + + create_release: + name: Create Release + runs-on: ubuntu-latest + needs: publish_to_testpypi + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Create Release + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + files: ./artifacts/**/*.whl From d5f5141c92e3c157cec86b340bdcc04de3574633 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 13:46:49 +0530 Subject: [PATCH 161/182] testing win --- .github/workflows/build_windows.yml | 2 +- .github/workflows/release_and_pypi.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index a6a4ed87..778cb9b2 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -86,7 +86,7 @@ jobs: python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] - pytest {project}/tests + pytest {project}\tests CIBW_TEST_EXTRAS: "test" shell: pwsh run: | diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index a767a423..ecc3f3d6 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -12,6 +12,8 @@ jobs: publish_to_testpypi: name: Publish to TestPyPI runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: - name: Checkout code uses: actions/checkout@v3 @@ -33,6 +35,8 @@ jobs: name: Create Release runs-on: ubuntu-latest needs: publish_to_testpypi + if: startsWith(github.ref, 'refs/tags/') + steps: - name: Checkout code uses: actions/checkout@v3 From 911085b59268dbbf9110dd531e7c9c236a36674b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:00:07 +0530 Subject: [PATCH 162/182] testing win --- .github/workflows/build_linux.yml | 2 +- .github/workflows/build_windows.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 7f530edf..96577fbc 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -29,7 +29,7 @@ jobs: CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | - yum install -y wget + yum install -y wget glibc.i686 glibc-devel.i686 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p /root/miniconda export PATH="/root/miniconda/bin:$PATH" diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 778cb9b2..d37e526c 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -86,8 +86,9 @@ jobs: python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] - pytest {project}\tests + pytest {project}\tests -v || (echo "Tests failed" && exit 1) CIBW_TEST_EXTRAS: "test" + CIBW_TEST_FAIL_FAST: 1 shell: pwsh run: | python -m cibuildwheel --output-dir wheelhouse From 9abc75ce792d72733d0ca39f4b3a45974f43ce69 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:05:06 +0530 Subject: [PATCH 163/182] testing win --- .github/workflows/build_linux.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 96577fbc..7aed522e 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -25,11 +25,11 @@ jobs: - name: Build wheels env: - CIBW_SKIP: "*-musllinux* pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | - yum install -y wget glibc.i686 glibc-devel.i686 + yum install -y wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p /root/miniconda export PATH="/root/miniconda/bin:$PATH" @@ -55,6 +55,9 @@ jobs: python -c "import platform; print('Python version:', platform.python_version())" python -c "import sys; print('sys.platform:', sys.platform)" python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" run: | python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype From d7c4b517aeaf67c5e43fd6e4a2dd962360090e2f Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:21:45 +0530 Subject: [PATCH 164/182] testing win --- .github/workflows/build_linux.yml | 2 +- .github/workflows/build_macos.yml | 2 +- .github/workflows/build_windows.yml | 2 +- .github/workflows/release_and_pypi.yml | 28 +++++++++++++++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 7aed522e..c952fca2 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -1,4 +1,4 @@ -name: Build quaddtype wheels for Linux +name: Build linux on: push: diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 501940b6..17859e90 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -1,4 +1,4 @@ -name: Build quaddtype wheels for macOS +name: Build Macos on: push: diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index d37e526c..e14e2bc7 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -1,4 +1,4 @@ -name: Build quaddtype wheels for Windows +name: Build win on: push: diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index ecc3f3d6..ff99c216 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -9,11 +9,26 @@ on: workflow_dispatch: jobs: + wait_for_builds: + name: Wait for build workflows + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Wait for other workflows to complete + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.ref }} + check-name: "Build win,Build Macos,Build linux" + repo-token: ${{ secrets.ACCESS_TOKEN }} + wait-interval: 10 + publish_to_testpypi: name: Publish to TestPyPI + needs: wait_for_builds runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - steps: - name: Checkout code uses: actions/checkout@v3 @@ -23,6 +38,10 @@ jobs: with: path: dist + - name: Display structure of downloaded files + run: ls -R + working-directory: dist + - name: Publish to TestPyPI uses: pypa/gh-action-pypi-publish@v1.8.5 with: @@ -33,10 +52,9 @@ jobs: create_release: name: Create Release - runs-on: ubuntu-latest needs: publish_to_testpypi + runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') - steps: - name: Checkout code uses: actions/checkout@v3 @@ -46,6 +64,10 @@ jobs: with: path: artifacts + - name: Display structure of downloaded files + run: ls -R + working-directory: artifacts + - name: Create Release env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} From 6ce30b8e3342147274d56b2cffb5f5be65282ec1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:24:46 +0530 Subject: [PATCH 165/182] testing win --- .github/workflows/release_and_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index ff99c216..15dfdd0d 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -20,7 +20,7 @@ jobs: uses: lewagon/wait-on-check-action@v1.3.1 with: ref: ${{ github.ref }} - check-name: "Build win,Build Macos,Build linux" + check-name: "Build wheels on macos-14, Build wheels on Windows (x64), Build wheels on macos-13, Build wheels on Linux" repo-token: ${{ secrets.ACCESS_TOKEN }} wait-interval: 10 From eda1a31f6e87a7419c613256456286bd4825a6a2 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:31:20 +0530 Subject: [PATCH 166/182] testing win --- .github/workflows/release_and_pypi.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index 15dfdd0d..2153912e 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -13,15 +13,28 @@ jobs: name: Wait for build workflows runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Wait for Windows build + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.ref }} + check-name: "build_windows.yml" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + + - name: Wait for macOS build + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.ref }} + check-name: "build_macos.yml" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 - - name: Wait for other workflows to complete + - name: Wait for Linux build uses: lewagon/wait-on-check-action@v1.3.1 with: ref: ${{ github.ref }} - check-name: "Build wheels on macos-14, Build wheels on Windows (x64), Build wheels on macos-13, Build wheels on Linux" - repo-token: ${{ secrets.ACCESS_TOKEN }} + check-name: "build_linux.yml" + repo-token: ${{ secrets.GITHUB_TOKEN }} wait-interval: 10 publish_to_testpypi: From f6c37060835b21f786057af2d64db30e337ea0dc Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:35:57 +0530 Subject: [PATCH 167/182] testing win --- .github/workflows/release_and_pypi.yml | 86 +++++++++----------------- 1 file changed, 28 insertions(+), 58 deletions(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index 2153912e..ec70047d 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -1,55 +1,43 @@ name: Release and Publish to TestPyPI on: - push: - branches: - - sep-workflows - tags: - - "v*" - workflow_dispatch: + workflow_run: + workflows: ["Build Macos", "Build linux", "Build win"] + types: + - completed jobs: - wait_for_builds: - name: Wait for build workflows + release_and_publish: + name: Release and Publish runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }} steps: - - name: Wait for Windows build - uses: lewagon/wait-on-check-action@v1.3.1 - with: - ref: ${{ github.ref }} - check-name: "build_windows.yml" - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 10 + - name: Checkout code + uses: actions/checkout@v3 - - name: Wait for macOS build - uses: lewagon/wait-on-check-action@v1.3.1 + - name: Download macOS artifacts + uses: actions/download-artifact@v3 with: - ref: ${{ github.ref }} - check-name: "build_macos.yml" - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 10 + name: wheels-macos-13 + path: dist/macos-13 - - name: Wait for Linux build - uses: lewagon/wait-on-check-action@v1.3.1 + - name: Download macOS artifacts + uses: actions/download-artifact@v3 with: - ref: ${{ github.ref }} - check-name: "build_linux.yml" - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 10 + name: wheels-macos-14 + path: dist/macos-14 - publish_to_testpypi: - name: Publish to TestPyPI - needs: wait_for_builds - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Download Linux artifacts + uses: actions/download-artifact@v3 + with: + name: wheels-linux + path: dist/linux - - name: Download all workflow run artifacts + - name: Download Windows artifacts uses: actions/download-artifact@v3 with: - path: dist + name: wheels-windows-x64 + path: dist/windows - name: Display structure of downloaded files run: ls -R @@ -61,29 +49,11 @@ jobs: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ - packages-dir: dist/* - - create_release: - name: Create Release - needs: publish_to_testpypi - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download all workflow run artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - - name: Display structure of downloaded files - run: ls -R - working-directory: artifacts + packages-dir: dist - name: Create Release env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: softprops/action-gh-release@v1 with: - files: ./artifacts/**/*.whl + files: ./dist/**/*.whl From f85abd76a8808452a9811c9e3edd146ff58c2c69 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:39:15 +0530 Subject: [PATCH 168/182] testing win --- .github/workflows/release_and_pypi.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index ec70047d..86fc0a26 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -5,12 +5,17 @@ on: workflows: ["Build Macos", "Build linux", "Build win"] types: - completed + push: + branches: + - sep-workflows + tags: + - "v*" jobs: release_and_publish: name: Release and Publish runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/') }} + if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -44,6 +49,7 @@ jobs: working-directory: dist - name: Publish to TestPyPI + if: startsWith(github.ref, 'refs/tags/') uses: pypa/gh-action-pypi-publish@v1.8.5 with: user: __token__ @@ -52,6 +58,7 @@ jobs: packages-dir: dist - name: Create Release + if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: softprops/action-gh-release@v1 From 9a086e32f630ca60fb2081291b1269821b9339dd Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 14:41:15 +0530 Subject: [PATCH 169/182] testing win --- .github/workflows/release_and_pypi.yml | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index 86fc0a26..6ce84b23 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -7,38 +7,72 @@ on: - completed push: branches: - - sep-workflows + - sep-workflows # or whatever your default branch name is tags: - "v*" jobs: + debug_job: + name: Debug Job + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Dump job context + env: + JOB_CONTEXT: ${{ toJson(job) }} + run: echo "$JOB_CONTEXT" + - name: Dump steps context + env: + STEPS_CONTEXT: ${{ toJson(steps) }} + run: echo "$STEPS_CONTEXT" + - name: Dump runner context + env: + RUNNER_CONTEXT: ${{ toJson(runner) }} + run: echo "$RUNNER_CONTEXT" + - name: Dump strategy context + env: + STRATEGY_CONTEXT: ${{ toJson(strategy) }} + run: echo "$STRATEGY_CONTEXT" + - name: Dump matrix context + env: + MATRIX_CONTEXT: ${{ toJson(matrix) }} + run: echo "$MATRIX_CONTEXT" + release_and_publish: name: Release and Publish + needs: debug_job runs-on: ubuntu-latest - if: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) }} + if: always() steps: - name: Checkout code uses: actions/checkout@v3 - name: Download macOS artifacts + continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-macos-13 path: dist/macos-13 - name: Download macOS artifacts + continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-macos-14 path: dist/macos-14 - name: Download Linux artifacts + continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-linux path: dist/linux - name: Download Windows artifacts + continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-windows-x64 From 9de162966d5308863120bb8f8374ec7e3ab4e671 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 19:11:44 +0530 Subject: [PATCH 170/182] testing win --- .github/workflows/release_and_pypi.yml | 82 +++++++++++++------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index 6ce84b23..63271838 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -2,77 +2,76 @@ name: Release and Publish to TestPyPI on: workflow_run: - workflows: ["Build Macos", "Build linux", "Build win"] + workflows: [Build linux", "Build win", "Build Macos"] types: - completed - push: - branches: - - sep-workflows # or whatever your default branch name is - tags: - - "v*" jobs: - debug_job: - name: Debug Job + wait_for_workflows: runs-on: ubuntu-latest + if: > + github.event.workflow_run.conclusion == 'success' && + startsWith(github.event.workflow_run.head_branch, 'v') steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Dump job context - env: - JOB_CONTEXT: ${{ toJson(job) }} - run: echo "$JOB_CONTEXT" - - name: Dump steps context - env: - STEPS_CONTEXT: ${{ toJson(steps) }} - run: echo "$STEPS_CONTEXT" - - name: Dump runner context - env: - RUNNER_CONTEXT: ${{ toJson(runner) }} - run: echo "$RUNNER_CONTEXT" - - name: Dump strategy context - env: - STRATEGY_CONTEXT: ${{ toJson(strategy) }} - run: echo "$STRATEGY_CONTEXT" - - name: Dump matrix context - env: - MATRIX_CONTEXT: ${{ toJson(matrix) }} - run: echo "$MATRIX_CONTEXT" + - name: Wait for Linux workflow + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.event.workflow_run.head_sha }} + check-name: "Build wheels on Linux" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + + - name: Wait for Windows workflow + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.event.workflow_run.head_sha }} + check-name: "Build wheels on Windows" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + + - name: Wait for macOS-13 workflow + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.event.workflow_run.head_sha }} + check-name: "Build wheels on macos-13" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + + - name: Wait for macOS-14 workflow + uses: lewagon/wait-on-check-action@v1.3.1 + with: + ref: ${{ github.event.workflow_run.head_sha }} + check-name: "Build wheels on macos-14" + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 release_and_publish: + needs: wait_for_workflows name: Release and Publish - needs: debug_job runs-on: ubuntu-latest - if: always() steps: - name: Checkout code uses: actions/checkout@v3 - - name: Download macOS artifacts - continue-on-error: true + - name: Download macOS artifacts (macos-13) uses: actions/download-artifact@v3 with: name: wheels-macos-13 path: dist/macos-13 - - name: Download macOS artifacts - continue-on-error: true + - name: Download macOS artifacts (macos-14) uses: actions/download-artifact@v3 with: name: wheels-macos-14 path: dist/macos-14 - name: Download Linux artifacts - continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-linux path: dist/linux - name: Download Windows artifacts - continue-on-error: true uses: actions/download-artifact@v3 with: name: wheels-windows-x64 @@ -83,7 +82,6 @@ jobs: working-directory: dist - name: Publish to TestPyPI - if: startsWith(github.ref, 'refs/tags/') uses: pypa/gh-action-pypi-publish@v1.8.5 with: user: __token__ @@ -92,9 +90,9 @@ jobs: packages-dir: dist - name: Create Release - if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: softprops/action-gh-release@v1 with: files: ./dist/**/*.whl + tag_name: ${{ github.event.workflow_run.head_branch }} From 4d3df6f49006b53fa502229d87c470280d304577 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 19:22:34 +0530 Subject: [PATCH 171/182] testing win --- .github/workflows/release_and_pypi.yml | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml index 63271838..1d3c2f83 100644 --- a/.github/workflows/release_and_pypi.yml +++ b/.github/workflows/release_and_pypi.yml @@ -1,15 +1,29 @@ name: Release and Publish to TestPyPI on: + push: + branches: + - sep-workflows + tags: + - "v*" workflow_run: - workflows: [Build linux", "Build win", "Build Macos"] + workflows: ["Build linux", "Build win", "Build Macos"] types: - completed jobs: + check_tag: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + steps: + - name: Check if tag + run: echo "This is a tag push" + wait_for_workflows: + needs: check_tag runs-on: ubuntu-latest if: > + github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') steps: @@ -18,7 +32,7 @@ jobs: with: ref: ${{ github.event.workflow_run.head_sha }} check-name: "Build wheels on Linux" - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.ACCESS_TOKEN }} wait-interval: 10 - name: Wait for Windows workflow @@ -26,7 +40,7 @@ jobs: with: ref: ${{ github.event.workflow_run.head_sha }} check-name: "Build wheels on Windows" - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.ACCESS_TOKEN }} wait-interval: 10 - name: Wait for macOS-13 workflow @@ -34,7 +48,7 @@ jobs: with: ref: ${{ github.event.workflow_run.head_sha }} check-name: "Build wheels on macos-13" - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.ACCESS_TOKEN }} wait-interval: 10 - name: Wait for macOS-14 workflow @@ -42,16 +56,17 @@ jobs: with: ref: ${{ github.event.workflow_run.head_sha }} check-name: "Build wheels on macos-14" - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.ACCESS_TOKEN }} wait-interval: 10 release_and_publish: needs: wait_for_workflows - name: Release and Publish runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Download macOS artifacts (macos-13) uses: actions/download-artifact@v3 @@ -91,8 +106,8 @@ jobs: - name: Create Release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} uses: softprops/action-gh-release@v1 with: files: ./dist/**/*.whl - tag_name: ${{ github.event.workflow_run.head_branch }} + tag_name: ${{ github.ref_name }} From 4f2db1717b4315a0782afeff251f86a7aaaae9ca Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 19:38:27 +0530 Subject: [PATCH 172/182] testing win --- .github/workflows/build_linux.yml | 68 -------- .github/workflows/build_macos.yml | 80 --------- .github/workflows/build_wheel.yml | 229 +++++++++++++++++++++++++ .github/workflows/build_windows.yml | 101 ----------- .github/workflows/release_and_pypi.yml | 113 ------------ 5 files changed, 229 insertions(+), 362 deletions(-) delete mode 100644 .github/workflows/build_linux.yml delete mode 100644 .github/workflows/build_macos.yml create mode 100644 .github/workflows/build_wheel.yml delete mode 100644 .github/workflows/build_windows.yml delete mode 100644 .github/workflows/release_and_pypi.yml diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml deleted file mode 100644 index c952fca2..00000000 --- a/.github/workflows/build_linux.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build linux - -on: - push: - branches: - - sep-workflows - tags: - - "v*" - pull_request: - -jobs: - build_wheels: - name: Build wheels on Linux - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ">=3.10.0" - - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 - - - name: Build wheels - env: - CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" - CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_BUILD_VERBOSITY: "3" - CIBW_BEFORE_ALL: | - yum install -y wget - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p /root/miniconda - export PATH="/root/miniconda/bin:$PATH" - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a - conda config --add channels conda-forge - conda config --set channel_priority strict - conda create -n build_env python=3.10 - source activate build_env - conda install -y sleef - CIBW_ENVIRONMENT: > - LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" - LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" - CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" - CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS" - LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS" - SLEEF_PATH="/root/miniconda/envs/build_env" - CIBW_REPAIR_WHEEL_COMMAND: > - auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} - CIBW_TEST_COMMAND: | - python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" - pip install {package}[test] - pytest {project}/tests - CIBW_TEST_EXTRAS: "test" - run: | - python -m cibuildwheel --output-dir wheelhouse - working-directory: ./quaddtype - - - uses: actions/upload-artifact@v3 - with: - path: ./quaddtype/wheelhouse/*.whl - name: wheels-linux diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml deleted file mode 100644 index 17859e90..00000000 --- a/.github/workflows/build_macos.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Build Macos - -on: - push: - branches: - - sep-workflows - tags: - - "v*" - pull_request: - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-13, macos-14] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ">=3.10.0" - - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.10" - channels: conda-forge - - - name: Install SLEEF - shell: bash -l {0} - run: | - conda install -y -c conda-forge sleef - echo $CONDA_PREFIX - echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV - - - name: Install cibuildwheel - run: pip install cibuildwheel==2.20.0 - - - name: Build wheels - env: - CIBW_BUILD_VERBOSITY: "1" - CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" - CIBW_ENVIRONMENT: > - SLEEF_PATH="${{ env.SLEEF_PATH }}" - DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" - LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" - CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" - CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" - LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" - MACOSX_DEPLOYMENT_TARGET="10.13" - CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" - CIBW_TEST_COMMAND: | - python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" - pip install {package}[test] - pytest {project}/tests - CIBW_TEST_EXTRAS: "test" - run: | - echo "SLEEF_PATH: $SLEEF_PATH" - ls $SLEEF_PATH/include/sleef* - echo "PATH: $PATH" - which python - python --version - which pip - pip --version - cd quaddtype - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v3 - with: - path: ./quaddtype/wheelhouse/*.whl - name: wheels-${{ matrix.os }} diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml new file mode 100644 index 00000000..4f408586 --- /dev/null +++ b/.github/workflows/build_wheel.yml @@ -0,0 +1,229 @@ +name: Build Wheels + +on: + push: + branches: + - uni-workflow + tags: + - "v*" + pull_request: + +jobs: + build_wheels_linux: + name: Build wheels on Linux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ">=3.10.0" + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels + env: + CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_BUILD_VERBOSITY: "3" + CIBW_BEFORE_ALL: | + yum install -y wget + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p /root/miniconda + export PATH="/root/miniconda/bin:$PATH" + conda config --set always_yes yes --set changeps1 no + conda update -q conda + conda info -a + conda config --add channels conda-forge + conda config --set channel_priority strict + conda create -n build_env python=3.10 + source activate build_env + conda install -y sleef + CIBW_ENVIRONMENT: > + LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" + LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" + CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" + CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS" + LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS" + SLEEF_PATH="/root/miniconda/envs/build_env" + CIBW_REPAIR_WHEEL_COMMAND: > + auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} + CIBW_TEST_COMMAND: | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" + run: | + python -m cibuildwheel --output-dir wheelhouse + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-linux + + build_wheels_macos: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13, macos-14] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ">=3.10.0" + + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.10" + channels: conda-forge + + - name: Install SLEEF + shell: bash -l {0} + run: | + conda install -y -c conda-forge sleef + echo $CONDA_PREFIX + echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV + + - name: Install cibuildwheel + run: pip install cibuildwheel==2.20.0 + + - name: Build wheels + env: + CIBW_BUILD_VERBOSITY: "1" + CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_ENVIRONMENT: > + SLEEF_PATH="${{ env.SLEEF_PATH }}" + DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" + LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" + CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" + CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" + LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" + MACOSX_DEPLOYMENT_TARGET="10.13" + CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" + CIBW_TEST_COMMAND: | + python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}/tests + CIBW_TEST_EXTRAS: "test" + run: | + echo "SLEEF_PATH: $SLEEF_PATH" + ls $SLEEF_PATH/include/sleef* + echo "PATH: $PATH" + which python + python --version + which pip + pip --version + cd quaddtype + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-${{ matrix.os }} + + build_wheels_windows: + name: Build wheels on Windows + runs-on: windows-latest + strategy: + matrix: + architecture: [x64] + + steps: + - uses: actions/checkout@v3 + + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.architecture }} + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + architecture: ${{ matrix.architecture }} + + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.10" + architecture: ${{ matrix.architecture }} + + - name: Install SLEEF and other dependencies + shell: bash -l {0} + run: | + conda config --add channels conda-forge + conda config --set channel_priority strict + conda install -y sleef numpy + conda list + if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then + echo "sleef.h not found. Installation may have failed." + exit 1 + fi + ls -l "$CONDA_PREFIX/Library/include/sleef.h" + ls -l "$CONDA_PREFIX/Library/lib/sleef"* + + - name: Set environment variables + shell: pwsh + run: | + echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" + echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - name: Install build dependencies + shell: bash -l {0} + run: | + pip install -U pip + pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest + + - name: Build wheels + env: + CONDA_PREFIX: ${{ env.CONDA_PREFIX }} + CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} + CIBW_BUILD_VERBOSITY: "1" + SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include + SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib + DISTUTILS_USE_SDK: "1" + MSSdk: "1" + NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} + CIBW_ENVIRONMENT: >- + NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" + SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include" + SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib" + CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy + CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" + CIBW_TEST_COMMAND: | + python -c "import platform; print('Python version:', platform.python_version())" + python -c "import sys; print('sys.platform:', sys.platform)" + python -c "import quaddtype; print('quaddtype imported successfully')" + pip install {package}[test] + pytest {project}\tests -v || (echo "Tests failed" && exit 1) + CIBW_TEST_EXTRAS: "test" + CIBW_TEST_FAIL_FAST: 1 + shell: pwsh + run: | + python -m cibuildwheel --output-dir wheelhouse + if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } + working-directory: ./quaddtype + + - uses: actions/upload-artifact@v3 + with: + path: ./quaddtype/wheelhouse/*.whl + name: wheels-windows-${{ matrix.architecture }} diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml deleted file mode 100644 index e14e2bc7..00000000 --- a/.github/workflows/build_windows.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: Build win - -on: - push: - branches: - - sep-workflows - tags: - - "v*" - pull_request: - -jobs: - build_wheels: - name: Build wheels on Windows - runs-on: windows-latest - strategy: - matrix: - architecture: [x64] - - steps: - - uses: actions/checkout@v3 - - - name: Setup MSVC - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ matrix.architecture }} - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - architecture: ${{ matrix.architecture }} - - - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.10" - architecture: ${{ matrix.architecture }} - - - name: Install SLEEF and other dependencies - shell: bash -l {0} - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef numpy - conda list - if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l "$CONDA_PREFIX/Library/include/sleef.h" - ls -l "$CONDA_PREFIX/Library/lib/sleef"* - - - name: Set environment variables - shell: pwsh - run: | - echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" - echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - - name: Install build dependencies - shell: bash -l {0} - run: | - pip install -U pip - pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest - - - name: Build wheels - env: - CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" - CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} - CIBW_BUILD_VERBOSITY: "1" - SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include - SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib - DISTUTILS_USE_SDK: "1" - MSSdk: "1" - NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} - CIBW_ENVIRONMENT: >- - NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" - SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include" - SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib" - CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy - CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" - CIBW_TEST_COMMAND: | - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" - pip install {package}[test] - pytest {project}\tests -v || (echo "Tests failed" && exit 1) - CIBW_TEST_EXTRAS: "test" - CIBW_TEST_FAIL_FAST: 1 - shell: pwsh - run: | - python -m cibuildwheel --output-dir wheelhouse - if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } - working-directory: ./quaddtype - - - uses: actions/upload-artifact@v3 - with: - path: ./quaddtype/wheelhouse/*.whl - name: wheels-windows-${{ matrix.architecture }} diff --git a/.github/workflows/release_and_pypi.yml b/.github/workflows/release_and_pypi.yml deleted file mode 100644 index 1d3c2f83..00000000 --- a/.github/workflows/release_and_pypi.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Release and Publish to TestPyPI - -on: - push: - branches: - - sep-workflows - tags: - - "v*" - workflow_run: - workflows: ["Build linux", "Build win", "Build Macos"] - types: - - completed - -jobs: - check_tag: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') - steps: - - name: Check if tag - run: echo "This is a tag push" - - wait_for_workflows: - needs: check_tag - runs-on: ubuntu-latest - if: > - github.event_name == 'workflow_run' && - github.event.workflow_run.conclusion == 'success' && - startsWith(github.event.workflow_run.head_branch, 'v') - steps: - - name: Wait for Linux workflow - uses: lewagon/wait-on-check-action@v1.3.1 - with: - ref: ${{ github.event.workflow_run.head_sha }} - check-name: "Build wheels on Linux" - repo-token: ${{ secrets.ACCESS_TOKEN }} - wait-interval: 10 - - - name: Wait for Windows workflow - uses: lewagon/wait-on-check-action@v1.3.1 - with: - ref: ${{ github.event.workflow_run.head_sha }} - check-name: "Build wheels on Windows" - repo-token: ${{ secrets.ACCESS_TOKEN }} - wait-interval: 10 - - - name: Wait for macOS-13 workflow - uses: lewagon/wait-on-check-action@v1.3.1 - with: - ref: ${{ github.event.workflow_run.head_sha }} - check-name: "Build wheels on macos-13" - repo-token: ${{ secrets.ACCESS_TOKEN }} - wait-interval: 10 - - - name: Wait for macOS-14 workflow - uses: lewagon/wait-on-check-action@v1.3.1 - with: - ref: ${{ github.event.workflow_run.head_sha }} - check-name: "Build wheels on macos-14" - repo-token: ${{ secrets.ACCESS_TOKEN }} - wait-interval: 10 - - release_and_publish: - needs: wait_for_workflows - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Download macOS artifacts (macos-13) - uses: actions/download-artifact@v3 - with: - name: wheels-macos-13 - path: dist/macos-13 - - - name: Download macOS artifacts (macos-14) - uses: actions/download-artifact@v3 - with: - name: wheels-macos-14 - path: dist/macos-14 - - - name: Download Linux artifacts - uses: actions/download-artifact@v3 - with: - name: wheels-linux - path: dist/linux - - - name: Download Windows artifacts - uses: actions/download-artifact@v3 - with: - name: wheels-windows-x64 - path: dist/windows - - - name: Display structure of downloaded files - run: ls -R - working-directory: dist - - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@v1.8.5 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - repository-url: https://test.pypi.org/legacy/ - packages-dir: dist - - - name: Create Release - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - uses: softprops/action-gh-release@v1 - with: - files: ./dist/**/*.whl - tag_name: ${{ github.ref_name }} From 5b4fe75c9a968d35bffafd1efe6e56c26cd5e9c0 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 19:48:58 +0530 Subject: [PATCH 173/182] testing win --- .github/workflows/build_wheel.yml | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index 4f408586..1d825fea 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -227,3 +227,55 @@ jobs: with: path: ./quaddtype/wheelhouse/*.whl name: wheels-windows-${{ matrix.architecture }} + + publish_to_testpypi: + name: Publish to TestPyPI + needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 + with: + path: dist + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.9.0 + 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/') + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download all workflow run artifacts + uses: actions/download-artifact@v2 + 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 }} From ca9f75ae34d0c0c12c915d235ec3c2764ba8b189 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 20:04:50 +0530 Subject: [PATCH 174/182] final test --- quaddtype/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index c477fe36..c262e37e 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "mesonpy" [project] name = "quaddtype" description = "Quad (128-bit) float dtype for numpy" -version = "0.0.1" +version = "0.0.2" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" From f29095ee5e978faa5366e5fb6ae181ced5edd1f1 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Mon, 26 Aug 2024 23:39:21 +0530 Subject: [PATCH 175/182] fixing local CI --- .github/workflows/ci.yml | 3 ++- h | 1 - quaddtype/meson.build | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) delete mode 100644 h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0d32495..5253a1ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Numpy User DTypes CI on: push: branches: - - main + - uni-workflow pull_request: workflow_dispatch: @@ -66,6 +66,7 @@ jobs: 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 sudo cmake --install build --prefix /usr + export SLEEF_PATH=/usr - name: Install quaddtype working-directory: quaddtype run: | diff --git a/h b/h deleted file mode 100644 index a661abaa..00000000 --- a/h +++ /dev/null @@ -1 +0,0 @@ -/Users/swayam diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 5bec1050..e9ae44fd 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -5,21 +5,8 @@ py = py_mod.find_installation() c = meson.get_compiler('c') -# Get the SLEEF path -sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() -if sleef_path == '' - sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() -endif - -if sleef_path == '' - error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') -endif - is_windows = build_machine.system() == 'windows' -# Add SLEEF lib directory to library path -add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) - incdir_numpy = '' if is_windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) @@ -39,6 +26,16 @@ if is_windows dependencies: [sleef_lib, sleefquad_lib]) else # Linux and macOS configuration + sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() + if sleef_path == '' + sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() + endif + if sleef_path == '' + error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') + endif + + add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) + sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' From b8132d29f211637c4b38eebab897c4f8649b325b Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Tue, 27 Aug 2024 00:06:16 +0530 Subject: [PATCH 176/182] fixing CI --- .github/workflows/ci.yml | 3 +-- quaddtype/meson.build | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5253a1ba..2269d0f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,11 +66,10 @@ jobs: 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 sudo cmake --install build --prefix /usr - export SLEEF_PATH=/usr - name: Install quaddtype working-directory: quaddtype run: | - LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug" + LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug -Dsleef_path=/usr" - name: Run quaddtype tests working-directory: quaddtype run: | diff --git a/quaddtype/meson.build b/quaddtype/meson.build index e9ae44fd..740febcb 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -25,16 +25,18 @@ if is_windows sleef_dep = declare_dependency(include_directories: include_directories(sleef_include_dir), dependencies: [sleef_lib, sleefquad_lib]) else - # Linux and macOS configuration - sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() + sleef_path = get_option('sleef_path') + if sleef_path == '' + sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() + endif if sleef_path == '' sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() endif if sleef_path == '' - error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') + error('SLEEF_PATH or CONDA_PREFIX environment variable is not set, and sleef_path option is not provided') endif - add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) + message('Using SLEEF path: ' + sleef_path) sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' @@ -47,9 +49,10 @@ else endif if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) - error('SLEEF library not found. Please ensure it is installed in your conda environment.') + error('SLEEF library not found. Please ensure it is installed in your conda environment or specify the correct path.') endif + # Try to get NumPy include path from environment variable first if incdir_numpy == '' incdir_numpy = run_command(py, From fe8b5405694c22626d5868b882a17a1b709b5873 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Tue, 27 Aug 2024 00:10:37 +0530 Subject: [PATCH 177/182] fixing CI --- .github/workflows/ci.yml | 2 +- quaddtype/meson.build | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2269d0f4..d0eb1cd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - name: Install quaddtype working-directory: quaddtype run: | - LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug -Dsleef_path=/usr" + export SLEEF_PATH=/usr && LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug" - name: Run quaddtype tests working-directory: quaddtype run: | diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 740febcb..06be7ce8 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -25,18 +25,19 @@ if is_windows sleef_dep = declare_dependency(include_directories: include_directories(sleef_include_dir), dependencies: [sleef_lib, sleefquad_lib]) else - sleef_path = get_option('sleef_path') - if sleef_path == '' - sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() - endif + # Linux and macOS configuration + + # Get the SLEEF path + sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() if sleef_path == '' sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() endif + if sleef_path == '' - error('SLEEF_PATH or CONDA_PREFIX environment variable is not set, and sleef_path option is not provided') + error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') endif - message('Using SLEEF path: ' + sleef_path) + add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) sleef_include_dir = sleef_path + '/include' sleef_library_dir = sleef_path + '/lib' @@ -49,10 +50,9 @@ else endif if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) - error('SLEEF library not found. Please ensure it is installed in your conda environment or specify the correct path.') + error('SLEEF library not found. Please ensure it is installed in your conda environment.') endif - # Try to get NumPy include path from environment variable first if incdir_numpy == '' incdir_numpy = run_command(py, From ac510158f7df32957a6183cf074376050ce6fb17 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Tue, 27 Aug 2024 00:31:41 +0530 Subject: [PATCH 178/182] setting trigger branch to main --- .github/workflows/build_wheel.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheel.yml index 1d825fea..aeb5784d 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheel.yml @@ -3,7 +3,7 @@ name: Build Wheels on: push: branches: - - uni-workflow + - main tags: - "v*" pull_request: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0eb1cd2..efb281b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Numpy User DTypes CI on: push: branches: - - uni-workflow + - main pull_request: workflow_dispatch: From 1493a9bb5c8b3b9185da067e8714b7599c3d4514 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Wed, 25 Sep 2024 23:05:09 +0530 Subject: [PATCH 179/182] Squashed commit of the following: commit 1a6618a47decb932d360470018511bb7dd9c10ff Author: swayaminsync Date: Sun Sep 22 02:19:59 2024 +0530 missed the comma :) commit 87a789184f961c71645ceaec1e0600562d8e9fe3 Author: swayaminsync Date: Sun Sep 22 02:16:24 2024 +0530 updated meson.build commit 77e25b6aeaafbe8a4354466c1e384c46cfe37777 Author: swayaminsync Date: Sun Sep 22 00:53:57 2024 +0530 made ufunc return actual value instead of 0 commit 600b2c8d96836ec3719fe9242ae9171f5067b182 Author: swayaminsync Date: Sat Sep 21 03:06:36 2024 +0530 fixed inter-backend cast segment fault commit 672be17ab0c9d84f37dac190eada407cdd687525 Author: swayaminsync Date: Sat Sep 21 00:01:39 2024 +0530 added aligned and unaligned casting loops commit 2fd9cad004d6bf48749c016555469c5ff4c3b53c Author: swayaminsync Date: Fri Sep 20 21:00:45 2024 +0530 refactoring commit 41ca3f981c4081ddfa246640862f28a5e12bea18 Author: swayaminsync Date: Fri Sep 20 20:58:08 2024 +0530 added 128-bit common constants commit 012e90fdb1cdf17dc8473e46f8a3fc5475d21a93 Merge: 082b64b bbc99a6 Author: swayaminsync Date: Fri Sep 20 19:30:53 2024 +0530 Merge branch 'dragon4' into constants commit bbc99a61d105a0177130552f8ac8427985751baa Author: swayaminsync Date: Fri Sep 20 19:27:55 2024 +0530 fixing constant error commit e53edbadb1baf4972259028d2e10a059d2fc1d01 Author: swayaminsync Date: Fri Sep 20 17:03:24 2024 +0530 resolved reviews commit 082b64b1a25baa5a2e36c244459f2016819b3e5d Author: swayaminsync Date: Thu Sep 19 21:43:48 2024 +0530 exposing constants commit 0052e160b42dfb2f02728d2d1df91d901ac4f7d7 Author: swayaminsync Date: Thu Sep 19 13:17:01 2024 +0530 Creating Quad with Quad commit 0a75b9123e2e884fb7b150264088b08f122c7688 Author: swayaminsync Date: Wed Sep 18 15:39:46 2024 +0530 aligned and unaligned comparison loops commit 707d5d6123e59d3c2a1631998e8cdb447ec06724 Author: swayaminsync Date: Wed Sep 18 13:47:32 2024 +0530 fixed longdouble comparison casting issue commit 4f0a6044619a80ab8e5ff0b140d7b7dc91cdf273 Author: swayaminsync Date: Tue Sep 17 21:51:17 2024 +0530 WIP commit 0fba040ebd5d62c1afad9d8856b637363298d354 Author: swayaminsync Date: Tue Sep 17 18:01:14 2024 +0530 added separate aligned and unaligned ufunc support commit fe6cabc031789dad74019f06c17b1d08febdbe64 Author: swayaminsync Date: Mon Sep 16 18:40:47 2024 +0530 removed unnecessary prints commit b719ba46e0bcee70459402d11a483f1ce9b4991e Author: swayaminsync Date: Mon Sep 16 18:35:54 2024 +0530 fixing import statements commit 25dd6b3a5d2cdeb51bbc32650b240daa13a8ea76 Author: swayaminsync Date: Mon Sep 16 18:02:42 2024 +0530 removing testing files commit 0ac54649088cfb08dbd461287132f839aac91b1d Author: swayaminsync Date: Mon Sep 16 15:16:12 2024 +0530 added more unary func commit 755e2cdc141531378e4aae3feb78a5c23ee4c9ae Author: swayaminsync Date: Tue Sep 10 08:30:15 2024 +0530 fixing base commit 04480ce60aed5480dbde68df3e36e856e6b53f4e Author: swayaminsync Date: Sat Sep 7 18:23:20 2024 +0530 np.dot WIP commit 7b43f3ba1c4cddf27d94b2b02c2951484bcb60d2 Author: swayaminsync Date: Sat Sep 7 12:58:45 2024 +0530 fixing reduction redorderable issue commit 22982a43f361e6513c7f0e6fd2b81a2250ce58a0 Author: swayaminsync Date: Fri Sep 6 19:09:12 2024 +0530 adding dragon4 commit 01e9b7ee9864cea1e80796b5cd7414372473590f Author: swayaminsync Date: Fri Sep 6 12:04:01 2024 +0530 post-cleaning commit e8cba6a3f0d108ae015253a9164fa0763d0870ca Author: swayaminsync Date: Thu Sep 5 14:58:47 2024 +0530 temporary solution to handle both backends commit 7a85fbf154d778787fa04725d3c7bd5005d1e1d8 Author: swayaminsync Date: Mon Sep 2 00:24:29 2024 +0530 removed todo comment: umath.cpp commit d664a598858032a54ba2fa1c66724f22bafefec2 Author: swayaminsync Date: Mon Sep 2 00:23:12 2024 +0530 added backend parameter in default descriptor commit 7fd8da6627a9be5be350128529e2678188e285cd Author: swayaminsync Date: Sun Sep 1 21:14:11 2024 +0530 failing: londouble with different dtype commit a652985a16316cf6f56154c4af345133a4239140 Author: swayaminsync Date: Sun Sep 1 12:34:59 2024 +0530 added multi backend support to scalar operations commit 8408227b4fe44c309c330fcafd349c1e209a8176 Author: swayaminsync Date: Sun Sep 1 04:17:31 2024 +0530 added ld backend support to casting commit d56e59278b3dceabb6cc9bd373872d9f392f52ed Author: swayaminsync Date: Sat Aug 31 22:37:00 2024 +0530 renaming module and adding initial longdouble backend support commit 0a36a9d70d9e79f5ad07dddb68ebffaadcb616d1 Author: swayaminsync Date: Sun Aug 25 12:02:33 2024 +0530 added readme --- quaddtype/README.md | 22 + quaddtype/meson.build | 50 +- quaddtype/numpy_quaddtype/__init__.py | 34 + quaddtype/numpy_quaddtype/src/casts.cpp | 798 +++++++ .../src/casts.h | 0 quaddtype/numpy_quaddtype/src/dragon4.c | 2024 +++++++++++++++++ quaddtype/numpy_quaddtype/src/dragon4.h | 70 + quaddtype/numpy_quaddtype/src/dtype.c | 266 +++ quaddtype/numpy_quaddtype/src/dtype.h | 30 + quaddtype/numpy_quaddtype/src/ops.hpp | 453 ++++ quaddtype/numpy_quaddtype/src/quad_common.h | 18 + .../numpy_quaddtype/src/quaddtype_main.c | 116 + quaddtype/numpy_quaddtype/src/scalar.c | 254 +++ quaddtype/numpy_quaddtype/src/scalar.h | 41 + quaddtype/numpy_quaddtype/src/scalar_ops.cpp | 243 ++ .../src/scalar_ops.h | 0 quaddtype/numpy_quaddtype/src/umath.cpp | 806 +++++++ .../src/umath.h | 0 quaddtype/pyproject.toml | 62 +- quaddtype/quaddtype/__init__.py | 1 - quaddtype/quaddtype/src/casts.cpp | 468 ---- quaddtype/quaddtype/src/dtype.c | 216 -- quaddtype/quaddtype/src/dtype.h | 30 - quaddtype/quaddtype/src/ops.hpp | 207 -- quaddtype/quaddtype/src/quaddtype_main.c | 55 - quaddtype/quaddtype/src/scalar.c | 126 - quaddtype/quaddtype/src/scalar.h | 35 - quaddtype/quaddtype/src/scalar_ops.cpp | 171 -- quaddtype/quaddtype/src/umath.cpp | 576 ----- quaddtype/reinstall.sh | 6 +- quaddtype/tests/test_quaddtype.py | 8 +- 31 files changed, 5206 insertions(+), 1980 deletions(-) create mode 100644 quaddtype/numpy_quaddtype/__init__.py create mode 100644 quaddtype/numpy_quaddtype/src/casts.cpp rename quaddtype/{quaddtype => numpy_quaddtype}/src/casts.h (100%) create mode 100644 quaddtype/numpy_quaddtype/src/dragon4.c create mode 100644 quaddtype/numpy_quaddtype/src/dragon4.h create mode 100644 quaddtype/numpy_quaddtype/src/dtype.c create mode 100644 quaddtype/numpy_quaddtype/src/dtype.h create mode 100644 quaddtype/numpy_quaddtype/src/ops.hpp create mode 100644 quaddtype/numpy_quaddtype/src/quad_common.h create mode 100644 quaddtype/numpy_quaddtype/src/quaddtype_main.c create mode 100644 quaddtype/numpy_quaddtype/src/scalar.c create mode 100644 quaddtype/numpy_quaddtype/src/scalar.h create mode 100644 quaddtype/numpy_quaddtype/src/scalar_ops.cpp rename quaddtype/{quaddtype => numpy_quaddtype}/src/scalar_ops.h (100%) create mode 100644 quaddtype/numpy_quaddtype/src/umath.cpp rename quaddtype/{quaddtype => numpy_quaddtype}/src/umath.h (100%) delete mode 100644 quaddtype/quaddtype/__init__.py delete mode 100644 quaddtype/quaddtype/src/casts.cpp delete mode 100644 quaddtype/quaddtype/src/dtype.c delete mode 100644 quaddtype/quaddtype/src/dtype.h delete mode 100644 quaddtype/quaddtype/src/ops.hpp delete mode 100644 quaddtype/quaddtype/src/quaddtype_main.c delete mode 100644 quaddtype/quaddtype/src/scalar.c delete mode 100644 quaddtype/quaddtype/src/scalar.h delete mode 100644 quaddtype/quaddtype/src/scalar_ops.cpp delete mode 100644 quaddtype/quaddtype/src/umath.cpp diff --git a/quaddtype/README.md b/quaddtype/README.md index e69de29b..60693cb9 100644 --- a/quaddtype/README.md +++ b/quaddtype/README.md @@ -0,0 +1,22 @@ +# Numpy-QuadDType + +## Installation + +``` +pip install numpy==2.1.0 +pip install -i https://test.pypi.org/simple/ quaddtype +``` + +## Usage + +```python +import numpy as np +from numpy_quaddtype import QuadPrecDType, QuadPrecision + +# using sleef backend (default) +np.array([1,2,3], dtype=QuadPrecDType()) +np.array([1,2,3], dtype=QuadPrecDType("sleef")) + +# using longdouble backend +np.array([1,2,3], dtype=QuadPrecDType("longdouble")) +``` diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 06be7ce8..21f68a7d 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -1,4 +1,4 @@ -project('quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++20', 'b_pie=true']) +project('numpy_quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true']) py_mod = import('python') py = py_mod.find_installation() @@ -71,41 +71,41 @@ endif includes = include_directories( [ incdir_numpy, - 'quaddtype/src', + 'numpy_quaddtype/src', ] ) srcs = [ - 'quaddtype/src/casts.h', - 'quaddtype/src/casts.cpp', - 'quaddtype/src/scalar.h', - 'quaddtype/src/scalar.c', - 'quaddtype/src/dtype.h', - 'quaddtype/src/dtype.c', - 'quaddtype/src/quaddtype_main.c', - 'quaddtype/src/scalar_ops.h', - 'quaddtype/src/scalar_ops.cpp', - 'quaddtype/src/ops.hpp', - 'quaddtype/src/umath.h', - 'quaddtype/src/umath.cpp' + 'numpy_quaddtype/src/quad_common.h', + 'numpy_quaddtype/src/casts.h', + 'numpy_quaddtype/src/casts.cpp', + 'numpy_quaddtype/src/scalar.h', + 'numpy_quaddtype/src/scalar.c', + 'numpy_quaddtype/src/dtype.h', + 'numpy_quaddtype/src/dtype.c', + 'numpy_quaddtype/src/quaddtype_main.c', + 'numpy_quaddtype/src/scalar_ops.h', + 'numpy_quaddtype/src/scalar_ops.cpp', + 'numpy_quaddtype/src/ops.hpp', + 'numpy_quaddtype/src/umath.h', + 'numpy_quaddtype/src/umath.cpp', + 'numpy_quaddtype/src/dragon4.h', + 'numpy_quaddtype/src/dragon4.c' ] py.install_sources( [ - 'quaddtype/__init__.py', + 'numpy_quaddtype/__init__.py', ], - subdir: 'quaddtype', + subdir: 'numpy_quaddtype', pure: false ) py.extension_module('_quaddtype_main', - srcs, - c_args: is_windows ? ['/DWIN32', '/D_WINDOWS'] : ['-g', '-O0'], - cpp_args: is_windows ? ['/DWIN32', '/D_WINDOWS', '/EHsc'] : ['-g', '-O0'], - link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'], - dependencies: [sleef_dep] + (is_windows ? [] : [sleefquad_dep]), - link_language: 'cpp', - install: true, - subdir: 'quaddtype', - include_directories: includes +srcs, +c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], +dependencies: [sleef_dep, sleefquad_dep], +install: true, +subdir: 'numpy_quaddtype', +include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/__init__.py b/quaddtype/numpy_quaddtype/__init__.py new file mode 100644 index 00000000..e469a4c1 --- /dev/null +++ b/quaddtype/numpy_quaddtype/__init__.py @@ -0,0 +1,34 @@ +from ._quaddtype_main import ( + QuadPrecision, + QuadPrecDType, + is_longdouble_128, + get_sleef_constant +) + +__all__ = [ + 'QuadPrecision', 'QuadPrecDType', 'SleefQuadPrecision', 'LongDoubleQuadPrecision', + 'SleefQuadPrecDType', 'LongDoubleQuadPrecDType', 'is_longdouble_128', 'pi', 'e', + 'log2e', 'log10e', 'ln2', 'ln10', 'max_value', 'min_value', 'epsilon' +] + +def SleefQuadPrecision(value): + return QuadPrecision(value, backend='sleef') + +def LongDoubleQuadPrecision(value): + return QuadPrecision(value, backend='longdouble') + +def SleefQuadPrecDType(): + return QuadPrecDType(backend='sleef') + +def LongDoubleQuadPrecDType(): + return QuadPrecDType(backend='longdouble') + +pi = get_sleef_constant("pi") +e = get_sleef_constant("e") +log2e = get_sleef_constant("log2e") +log10e = get_sleef_constant("log10e") +ln2 = get_sleef_constant("ln2") +ln10 = get_sleef_constant("ln10") +max_value = get_sleef_constant("quad_max") +min_value = get_sleef_constant("quad_min") +epsilon = get_sleef_constant("epsilon") \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/casts.cpp b/quaddtype/numpy_quaddtype/src/casts.cpp new file mode 100644 index 00000000..c662b4d5 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/casts.cpp @@ -0,0 +1,798 @@ +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY +#define NO_IMPORT_UFUNC + +extern "C" { +#include + +#include "numpy/arrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/dtype_api.h" +} +#include "sleef.h" +#include "sleefquad.h" + +#include "quad_common.h" +#include "scalar.h" +#include "casts.h" +#include "dtype.h" + +#define NUM_CASTS 29 // 14 to_casts + 14 from_casts + 1 quad_to_quad + +static NPY_CASTING +quad_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self), + PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]), + QuadPrecDTypeObject *given_descrs[2], + QuadPrecDTypeObject *loop_descrs[2], npy_intp *view_offset) +{ + NPY_CASTING casting = NPY_NO_CASTING; + + if (given_descrs[0]->backend != given_descrs[1]->backend) + casting = NPY_UNSAFE_CASTING; + + Py_INCREF(given_descrs[0]); + loop_descrs[0] = given_descrs[0]; + + if (given_descrs[1] == NULL) { + Py_INCREF(given_descrs[0]); + loop_descrs[1] = given_descrs[0]; + } + else { + Py_INCREF(given_descrs[1]); + loop_descrs[1] = given_descrs[1]; + } + + *view_offset = 0; + return casting; +} + +static int +quad_to_quad_strided_loop_unaligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + npy_intp in_stride = strides[0]; + npy_intp out_stride = strides[1]; + + QuadPrecDTypeObject *descr_in = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)context->descriptors[1]; + + // inter-backend casting + if (descr_in->backend != descr_out->backend) { + while (N--) { + quad_value in_val, out_val; + if (descr_in->backend == BACKEND_SLEEF) { + memcpy(&in_val.sleef_value, in_ptr, sizeof(Sleef_quad)); + out_val.longdouble_value = Sleef_cast_to_doubleq1(in_val.sleef_value); + } + else { + memcpy(&in_val.longdouble_value, in_ptr, sizeof(long double)); + out_val.sleef_value = Sleef_cast_from_doubleq1(in_val.longdouble_value); + } + memcpy(out_ptr, &out_val, + (descr_out->backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) + : sizeof(long double)); + in_ptr += in_stride; + out_ptr += out_stride; + } + + return 0; + } + + size_t elem_size = + (descr_in->backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + while (N--) { + memcpy(out_ptr, in_ptr, elem_size); + in_ptr += in_stride; + out_ptr += out_stride; + } + return 0; +} + +static int +quad_to_quad_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + npy_intp in_stride = strides[0]; + npy_intp out_stride = strides[1]; + + QuadPrecDTypeObject *descr_in = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)context->descriptors[1]; + + // inter-backend casting + if (descr_in->backend != descr_out->backend) { + if (descr_in->backend == BACKEND_SLEEF) { + while (N--) { + Sleef_quad in_val = *(Sleef_quad *)in_ptr; + *(long double *)out_ptr = Sleef_cast_to_doubleq1(in_val); + in_ptr += in_stride; + out_ptr += out_stride; + } + } + else { + while (N--) { + long double in_val = *(long double *)in_ptr; + *(Sleef_quad *)out_ptr = Sleef_cast_from_doubleq1(in_val); + in_ptr += in_stride; + out_ptr += out_stride; + } + } + + return 0; + } + + if (descr_in->backend == BACKEND_SLEEF) { + while (N--) { + *(Sleef_quad *)out_ptr = *(Sleef_quad *)in_ptr; + in_ptr += in_stride; + out_ptr += out_stride; + } + } + else { + while (N--) { + *(long double *)out_ptr = *(long double *)in_ptr; + in_ptr += in_stride; + out_ptr += out_stride; + } + } + + return 0; +} + +// Casting from other types to QuadDType + +template +static inline quad_value +to_quad(T x, QuadBackendType backend); + +template <> +inline quad_value +to_quad(npy_bool x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = x ? Sleef_cast_from_doubleq1(1.0) : Sleef_cast_from_doubleq1(0.0); + } + else { + result.longdouble_value = x ? 1.0L : 0.0L; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_byte x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_int64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_short x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_int64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_ushort x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_uint64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_int x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_int64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_uint x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_uint64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_long x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_int64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_ulong x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_uint64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_longlong x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_int64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(npy_ulonglong x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_uint64q1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} +template <> +inline quad_value +to_quad(float x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_doubleq1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(double x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_doubleq1(x); + } + else { + result.longdouble_value = (long double)x; + } + return result; +} + +template <> +inline quad_value +to_quad(long double x, QuadBackendType backend) +{ + quad_value result; + if (backend == BACKEND_SLEEF) { + result.sleef_value = Sleef_cast_from_doubleq1(x); + } + else { + result.longdouble_value = x; + } + return result; +} + +template +static NPY_CASTING +numpy_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self), PyArray_DTypeMeta *dtypes[2], + PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2], + npy_intp *view_offset) +{ + // todo: here it is converting this to SLEEF, losing data and getting 0 + if (given_descrs[1] == NULL) { + loop_descrs[1] = (PyArray_Descr *)new_quaddtype_instance(BACKEND_SLEEF); + if (loop_descrs[1] == nullptr) { + return (NPY_CASTING)-1; + } + } + else { + Py_INCREF(given_descrs[1]); + loop_descrs[1] = given_descrs[1]; + } + + loop_descrs[0] = PyArray_GetDefaultDescr(dtypes[0]); + return NPY_SAFE_CASTING; +} + +template +static int +numpy_to_quad_strided_loop_unaligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)context->descriptors[1]; + QuadBackendType backend = descr_out->backend; + size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + while (N--) { + T in_val; + quad_value out_val; + + memcpy(&in_val, in_ptr, sizeof(T)); + out_val = to_quad(in_val, backend); + memcpy(out_ptr, &out_val, elem_size); + + in_ptr += strides[0]; + out_ptr += strides[1]; + } + return 0; +} + +template +static int +numpy_to_quad_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)context->descriptors[1]; + QuadBackendType backend = descr_out->backend; + + while (N--) { + T in_val = *(T *)in_ptr; + quad_value out_val = to_quad(in_val, backend); + + if (backend == BACKEND_SLEEF) { + *(Sleef_quad *)(out_ptr) = out_val.sleef_value; + } + else { + *(long double *)(out_ptr) = out_val.longdouble_value; + } + + in_ptr += strides[0]; + out_ptr += strides[1]; + } + return 0; +} + +// Casting from QuadDType to other types + +template +static inline T +from_quad(quad_value x, QuadBackendType backend); + +template <> +inline npy_bool +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return Sleef_cast_to_int64q1(x.sleef_value) != 0; + } + else { + return x.longdouble_value != 0; + } +} + +template <> +inline npy_byte +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_byte)Sleef_cast_to_int64q1(x.sleef_value); + } + else { + return (npy_byte)x.longdouble_value; + } +} + +template <> +inline npy_short +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_short)Sleef_cast_to_int64q1(x.sleef_value); + } + else { + return (npy_short)x.longdouble_value; + } +} + +template <> +inline npy_ushort +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_ushort)Sleef_cast_to_uint64q1(x.sleef_value); + } + else { + return (npy_ushort)x.longdouble_value; + } +} + +template <> +inline npy_int +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_int)Sleef_cast_to_int64q1(x.sleef_value); + } + else { + return (npy_int)x.longdouble_value; + } +} + +template <> +inline npy_uint +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_uint)Sleef_cast_to_uint64q1(x.sleef_value); + } + else { + return (npy_uint)x.longdouble_value; + } +} + +template <> +inline npy_long +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_long)Sleef_cast_to_int64q1(x.sleef_value); + } + else { + return (npy_long)x.longdouble_value; + } +} + +template <> +inline npy_ulong +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (npy_ulong)Sleef_cast_to_uint64q1(x.sleef_value); + } + else { + return (npy_ulong)x.longdouble_value; + } +} + +template <> +inline npy_longlong +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return Sleef_cast_to_int64q1(x.sleef_value); + } + else { + return (npy_longlong)x.longdouble_value; + } +} + +template <> +inline npy_ulonglong +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return Sleef_cast_to_uint64q1(x.sleef_value); + } + else { + return (npy_ulonglong)x.longdouble_value; + } +} + +template <> +inline float +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (float)Sleef_cast_to_doubleq1(x.sleef_value); + } + else { + return (float)x.longdouble_value; + } +} + +template <> +inline double +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return Sleef_cast_to_doubleq1(x.sleef_value); + } + else { + return (double)x.longdouble_value; + } +} + +template <> +inline long double +from_quad(quad_value x, QuadBackendType backend) +{ + if (backend == BACKEND_SLEEF) { + return (long double)Sleef_cast_to_doubleq1(x.sleef_value); + } + else { + return x.longdouble_value; + } +} + +template +static NPY_CASTING +quad_to_numpy_resolve_descriptors(PyObject *NPY_UNUSED(self), PyArray_DTypeMeta *dtypes[2], + PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2], + npy_intp *view_offset) +{ + Py_INCREF(given_descrs[0]); + loop_descrs[0] = given_descrs[0]; + + loop_descrs[1] = PyArray_GetDefaultDescr(dtypes[1]); + return NPY_UNSAFE_CASTING; +} + +template +static int +quad_to_numpy_strided_loop_unaligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + + QuadPrecDTypeObject *quad_descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = quad_descr->backend; + + size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + while (N--) { + quad_value in_val; + memcpy(&in_val, in_ptr, elem_size); + + T out_val = from_quad(in_val, backend); + memcpy(out_ptr, &out_val, sizeof(T)); + + in_ptr += strides[0]; + out_ptr += strides[1]; + } + return 0; +} + +template +static int +quad_to_numpy_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + void *NPY_UNUSED(auxdata)) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + + QuadPrecDTypeObject *quad_descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = quad_descr->backend; + + while (N--) { + quad_value in_val; + if (backend == BACKEND_SLEEF) { + in_val.sleef_value = *(Sleef_quad *)in_ptr; + } + else { + in_val.longdouble_value = *(long double *)in_ptr; + } + + T out_val = from_quad(in_val, backend); + *(T *)(out_ptr) = out_val; + + in_ptr += strides[0]; + out_ptr += strides[1]; + } + return 0; +} + +static PyArrayMethod_Spec *specs[NUM_CASTS + 1]; // +1 for NULL terminator +static size_t spec_count = 0; + +void +add_spec(PyArrayMethod_Spec *spec) +{ + if (spec_count < NUM_CASTS) { + specs[spec_count++] = spec; + } + else { + delete[] spec->dtypes; + delete[] spec->slots; + delete spec; + } +} + +// functions to add casts +template +void +add_cast_from(PyArray_DTypeMeta *to) +{ + PyArray_DTypeMeta **dtypes = new PyArray_DTypeMeta *[2]{&QuadPrecDType, to}; + + PyType_Slot *slots = new PyType_Slot[]{ + {NPY_METH_resolve_descriptors, (void *)&quad_to_numpy_resolve_descriptors}, + {NPY_METH_strided_loop, (void *)&quad_to_numpy_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, (void *)&quad_to_numpy_strided_loop_unaligned}, + {0, nullptr}}; + + PyArrayMethod_Spec *spec = new PyArrayMethod_Spec{ + .name = "cast_QuadPrec_to_NumPy", + .nin = 1, + .nout = 1, + .casting = NPY_UNSAFE_CASTING, + .flags = NPY_METH_SUPPORTS_UNALIGNED, + .dtypes = dtypes, + .slots = slots, + }; + add_spec(spec); +} + +template +void +add_cast_to(PyArray_DTypeMeta *from) +{ + PyArray_DTypeMeta **dtypes = new PyArray_DTypeMeta *[2]{from, &QuadPrecDType}; + + PyType_Slot *slots = new PyType_Slot[]{ + {NPY_METH_resolve_descriptors, (void *)&numpy_to_quad_resolve_descriptors}, + {NPY_METH_strided_loop, (void *)&numpy_to_quad_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, (void *)&numpy_to_quad_strided_loop_unaligned}, + {0, nullptr}}; + + PyArrayMethod_Spec *spec = new PyArrayMethod_Spec{ + .name = "cast_NumPy_to_QuadPrec", + .nin = 1, + .nout = 1, + .casting = NPY_SAFE_CASTING, + .flags = NPY_METH_SUPPORTS_UNALIGNED, + .dtypes = dtypes, + .slots = slots, + }; + + add_spec(spec); +} + +PyArrayMethod_Spec ** +init_casts_internal(void) +{ + PyArray_DTypeMeta **quad2quad_dtypes = new PyArray_DTypeMeta *[2]{nullptr, nullptr}; + PyType_Slot *quad2quad_slots = new PyType_Slot[4]{ + {NPY_METH_resolve_descriptors, (void *)&quad_to_quad_resolve_descriptors}, + {NPY_METH_strided_loop, (void *)&quad_to_quad_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, (void *)&quad_to_quad_strided_loop_unaligned}, + {0, nullptr}}; + + PyArrayMethod_Spec *quad2quad_spec = new PyArrayMethod_Spec{ + .name = "cast_QuadPrec_to_QuadPrec", + .nin = 1, + .nout = 1, + .casting = NPY_UNSAFE_CASTING, // since SLEEF -> ld might lose precision + .flags = NPY_METH_SUPPORTS_UNALIGNED, + .dtypes = quad2quad_dtypes, + .slots = quad2quad_slots, + }; + + add_spec(quad2quad_spec); + + add_cast_to(&PyArray_BoolDType); + add_cast_to(&PyArray_ByteDType); + add_cast_to(&PyArray_ShortDType); + add_cast_to(&PyArray_UShortDType); + add_cast_to(&PyArray_IntDType); + add_cast_to(&PyArray_UIntDType); + add_cast_to(&PyArray_LongDType); + add_cast_to(&PyArray_ULongDType); + add_cast_to(&PyArray_LongLongDType); + add_cast_to(&PyArray_ULongLongDType); + add_cast_to(&PyArray_FloatDType); + add_cast_to(&PyArray_DoubleDType); + add_cast_to(&PyArray_LongDoubleDType); + + add_cast_from(&PyArray_BoolDType); + add_cast_from(&PyArray_ByteDType); + add_cast_from(&PyArray_ShortDType); + add_cast_from(&PyArray_UShortDType); + add_cast_from(&PyArray_IntDType); + add_cast_from(&PyArray_UIntDType); + add_cast_from(&PyArray_LongDType); + add_cast_from(&PyArray_ULongDType); + add_cast_from(&PyArray_LongLongDType); + add_cast_from(&PyArray_ULongLongDType); + add_cast_from(&PyArray_FloatDType); + add_cast_from(&PyArray_DoubleDType); + add_cast_from(&PyArray_LongDoubleDType); + + specs[spec_count] = nullptr; + return specs; +} + +PyArrayMethod_Spec ** +init_casts(void) +{ + try { + return init_casts_internal(); + } + catch (int e) { + PyErr_NoMemory(); + return nullptr; + } +} + +void +free_casts(void) +{ + for (size_t i = 0; i < spec_count; i++) { + if (specs[i]) { + delete[] specs[i]->dtypes; + delete[] specs[i]->slots; + delete specs[i]; + specs[i] = nullptr; + } + } + spec_count = 0; +} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/casts.h b/quaddtype/numpy_quaddtype/src/casts.h similarity index 100% rename from quaddtype/quaddtype/src/casts.h rename to quaddtype/numpy_quaddtype/src/casts.h diff --git a/quaddtype/numpy_quaddtype/src/dragon4.c b/quaddtype/numpy_quaddtype/src/dragon4.c new file mode 100644 index 00000000..34ad4cbb --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/dragon4.c @@ -0,0 +1,2024 @@ +/* +This code was extracted from NumPy and the original author was Allan Haldane(@ahaldane) +Modifications are specific to support the SLEEF_QUAD +*/ + +#include +#include +#include +#include +#include +#include +#include + +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY +#define NO_IMPORT_UFUNC + +#include "dragon4.h" +#include "dtype.h" +#include "scalar.h" + +#if 0 +#define DEBUG_ASSERT(stmnt) assert(stmnt) +#else +#define DEBUG_ASSERT(stmnt) \ + do { \ + } while (0) +#endif + +#define c_BigInt_MaxBlocks 1023 +#define BIGINT_DRAGON4_GROUPSIZE 7 + +typedef struct BigInt { + npy_uint32 length; + npy_uint32 blocks[c_BigInt_MaxBlocks]; +} BigInt; + +typedef struct { + BigInt bigints[BIGINT_DRAGON4_GROUPSIZE]; + char repr[16384]; +} Dragon4_Scratch; + +static NPY_TLS Dragon4_Scratch _bigint_static; + +static inline npy_uint64 +bitmask_u64(npy_uint32 n) +{ + return ~(~((npy_uint64)0) << n); +} + +static inline npy_uint32 +bitmask_u32(npy_uint32 n) +{ + return ~(~((npy_uint32)0) << n); +} + +/* result = result * 10 */ +static void +BigInt_Multiply10(BigInt *result) +{ + /* multiply all the blocks */ + npy_uint64 carry = 0; + + npy_uint32 *cur = result->blocks; + npy_uint32 *end = result->blocks + result->length; + for (; cur != end; ++cur) { + npy_uint64 product = (npy_uint64)(*cur) * 10ull + carry; + (*cur) = (npy_uint32)(product & bitmask_u64(32)); + carry = product >> 32; + } + + if (carry != 0) { + /* grow the array */ + DEBUG_ASSERT(result->length + 1 <= c_BigInt_MaxBlocks); + *cur = (npy_uint32)carry; + ++result->length; + } +} + +static npy_uint32 g_PowerOf10_U32[] = { + 1, /* 10 ^ 0 */ + 10, /* 10 ^ 1 */ + 100, /* 10 ^ 2 */ + 1000, /* 10 ^ 3 */ + 10000, /* 10 ^ 4 */ + 100000, /* 10 ^ 5 */ + 1000000, /* 10 ^ 6 */ + 10000000, /* 10 ^ 7 */ +}; + +/* + * Note: This has a lot of wasted space in the big integer structures of the + * early table entries. It wouldn't be terribly hard to make the multiply + * function work on integer pointers with an array length instead of + * the BigInt struct which would allow us to store a minimal amount of + * data here. + */ +static BigInt g_PowerOf10_Big[] = { + /* 10 ^ 8 */ + {1, {100000000}}, + /* 10 ^ 16 */ + {2, {0x6fc10000, 0x002386f2}}, + /* 10 ^ 32 */ + {4, + { + 0x00000000, + 0x85acef81, + 0x2d6d415b, + 0x000004ee, + }}, + /* 10 ^ 64 */ + {7, + { + 0x00000000, + 0x00000000, + 0xbf6a1f01, + 0x6e38ed64, + 0xdaa797ed, + 0xe93ff9f4, + 0x00184f03, + }}, + /* 10 ^ 128 */ + {14, + { + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x2e953e01, + 0x03df9909, + 0x0f1538fd, + 0x2374e42f, + 0xd3cff5ec, + 0xc404dc08, + 0xbccdb0da, + 0xa6337f19, + 0xe91f2603, + 0x0000024e, + }}, + /* 10 ^ 256 */ + {27, + { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x982e7c01, 0xbed3875b, 0xd8d99f72, 0x12152f87, 0x6bde50c6, 0xcf4a6e70, + 0xd595d80f, 0x26b2716e, 0xadc666b0, 0x1d153624, 0x3c42d35a, 0x63ff540e, 0xcc5573c0, + 0x65f9ef17, 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x000553f7, + }}, + /* 10 ^ 512 */ + {54, + { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0xfc6cf801, 0x77f27267, 0x8f9546dc, 0x5d96976f, 0xb83a8a97, + 0xc31e1ad9, 0x46c40513, 0x94e65747, 0xc88976c1, 0x4475b579, 0x28f8733b, 0xaa1da1bf, + 0x703ed321, 0x1e25cfea, 0xb21a2f22, 0xbc51fb2e, 0x96e14f5d, 0xbfa3edac, 0x329c57ae, + 0xe7fc7153, 0xc3fc0695, 0x85a91924, 0xf95f635e, 0xb2908ee0, 0x93abade4, 0x1366732a, + 0x9449775c, 0x69be5b0e, 0x7343afac, 0xb099bc81, 0x45a71d46, 0xa2699748, 0x8cb07303, + 0x8a0b1f13, 0x8cab8a97, 0xc1d238d9, 0x633415d4, 0x0000001c, + }}, + /* 10 ^ 1024 */ + {107, + { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2919f001, 0xf55b2b72, 0x6e7c215b, + 0x1ec29f86, 0x991c4e87, 0x15c51a88, 0x140ac535, 0x4c7d1e1a, 0xcc2cd819, 0x0ed1440e, + 0x896634ee, 0x7de16cfb, 0x1e43f61f, 0x9fce837d, 0x231d2b9c, 0x233e55c7, 0x65dc60d7, + 0xf451218b, 0x1c5cd134, 0xc9635986, 0x922bbb9f, 0xa7e89431, 0x9f9f2a07, 0x62be695a, + 0x8e1042c4, 0x045b7a74, 0x1abe1de3, 0x8ad822a5, 0xba34c411, 0xd814b505, 0xbf3fdeb3, + 0x8fc51a16, 0xb1b896bc, 0xf56deeec, 0x31fb6bfd, 0xb6f4654b, 0x101a3616, 0x6b7595fb, + 0xdc1a47fe, 0x80d98089, 0x80bda5a5, 0x9a202882, 0x31eb0f66, 0xfc8f1f90, 0x976a3310, + 0xe26a7b7e, 0xdf68368a, 0x3ce3a0b8, 0x8e4262ce, 0x75a351a2, 0x6cb0b6c9, 0x44597583, + 0x31b5653f, 0xc356e38a, 0x35faaba6, 0x0190fba0, 0x9fc4ed52, 0x88bc491b, 0x1640114a, + 0x005b8041, 0xf4f3235e, 0x1e8d4649, 0x36a8de06, 0x73c55349, 0xa7e6bd2a, 0xc1a6970c, + 0x47187094, 0xd2db49ef, 0x926c3f5b, 0xae6209d4, 0x2d433949, 0x34f4a3c6, 0xd4305d94, + 0xd9d61a05, 0x00000325, + }}, + /* 10 ^ 2048 */ + {213, + { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x1333e001, 0xe3096865, 0xb27d4d3f, 0x49e28dcf, 0xec2e4721, 0xee87e354, + 0xb6067584, 0x368b8abb, 0xa5e5a191, 0x2ed56d55, 0xfd827773, 0xea50d142, 0x51b78db2, + 0x98342c9e, 0xc850dabc, 0x866ed6f1, 0x19342c12, 0x92794987, 0xd2f869c2, 0x66912e4a, + 0x71c7fd8f, 0x57a7842d, 0x235552eb, 0xfb7fedcc, 0xf3861ce0, 0x38209ce1, 0x9713b449, + 0x34c10134, 0x8c6c54de, 0xa7a8289c, 0x2dbb6643, 0xe3cb64f3, 0x8074ff01, 0xe3892ee9, + 0x10c17f94, 0xa8f16f92, 0xa8281ed6, 0x967abbb3, 0x5a151440, 0x9952fbed, 0x13b41e44, + 0xafe609c3, 0xa2bca416, 0xf111821f, 0xfb1264b4, 0x91bac974, 0xd6c7d6ab, 0x8e48ff35, + 0x4419bd43, 0xc4a65665, 0x685e5510, 0x33554c36, 0xab498697, 0x0dbd21fe, 0x3cfe491d, + 0x982da466, 0xcbea4ca7, 0x9e110c7b, 0x79c56b8a, 0x5fc5a047, 0x84d80e2e, 0x1aa9f444, + 0x730f203c, 0x6a57b1ab, 0xd752f7a6, 0x87a7dc62, 0x944545ff, 0x40660460, 0x77c1a42f, + 0xc9ac375d, 0xe866d7ef, 0x744695f0, 0x81428c85, 0xa1fc6b96, 0xd7917c7b, 0x7bf03c19, + 0x5b33eb41, 0x5715f791, 0x8f6cae5f, 0xdb0708fd, 0xb125ac8e, 0x785ce6b7, 0x56c6815b, + 0x6f46eadb, 0x4eeebeee, 0x195355d8, 0xa244de3c, 0x9d7389c0, 0x53761abd, 0xcf99d019, + 0xde9ec24b, 0x0d76ce39, 0x70beb181, 0x2e55ecee, 0xd5f86079, 0xf56d9d4b, 0xfb8886fb, + 0x13ef5a83, 0x408f43c5, 0x3f3389a4, 0xfad37943, 0x58ccf45c, 0xf82df846, 0x415c7f3e, + 0x2915e818, 0x8b3d5cf4, 0x6a445f27, 0xf8dbb57a, 0xca8f0070, 0x8ad803ec, 0xb2e87c34, + 0x038f9245, 0xbedd8a6c, 0xc7c9dee0, 0x0eac7d56, 0x2ad3fa14, 0xe0de0840, 0xf775677c, + 0xf1bd0ad5, 0x92be221e, 0x87fa1fb9, 0xce9d04a4, 0xd2c36fa9, 0x3f6f7024, 0xb028af62, + 0x907855ee, 0xd83e49d6, 0x4efac5dc, 0xe7151aab, 0x77cd8c6b, 0x0a753b7d, 0x0af908b4, + 0x8c983623, 0xe50f3027, 0x94222771, 0x1d08e2d6, 0xf7e928e6, 0xf2ee5ca6, 0x1b61b93c, + 0x11eb962b, 0x9648b21c, 0xce2bcba1, 0x34f77154, 0x7bbebe30, 0xe526a319, 0x8ce329ac, + 0xde4a74d2, 0xb5dc53d5, 0x0009e8b3, + }}, + /* 10 ^ 4096 */ + {426, + { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x2a67c001, 0xd4724e8d, 0x8efe7ae7, 0xf89a1e90, 0xef084117, + 0x54e05154, 0x13b1bb51, 0x506be829, 0xfb29b172, 0xe599574e, 0xf0da6146, 0x806c0ed3, + 0xb86ae5be, 0x45155e93, 0xc0591cc2, 0x7e1e7c34, 0x7c4823da, 0x1d1f4cce, 0x9b8ba1e8, + 0xd6bfdf75, 0xe341be10, 0xc2dfae78, 0x016b67b2, 0x0f237f1a, 0x3dbeabcd, 0xaf6a2574, + 0xcab3e6d7, 0x142e0e80, 0x61959127, 0x2c234811, 0x87009701, 0xcb4bf982, 0xf8169c84, + 0x88052f8c, 0x68dde6d4, 0xbc131761, 0xff0b0905, 0x54ab9c41, 0x7613b224, 0x1a1c304e, + 0x3bfe167b, 0x441c2d47, 0x4f6cea9c, 0x78f06181, 0xeb659fb8, 0x30c7ae41, 0x947e0d0e, + 0xa1ebcad7, 0xd97d9556, 0x2130504d, 0x1a8309cb, 0xf2acd507, 0x3f8ec72a, 0xfd82373a, + 0x95a842bc, 0x280f4d32, 0xf3618ac0, 0x811a4f04, 0x6dc3a5b4, 0xd3967a1b, 0x15b8c898, + 0xdcfe388f, 0x454eb2a0, 0x8738b909, 0x10c4e996, 0x2bd9cc11, 0x3297cd0c, 0x655fec30, + 0xae0725b1, 0xf4090ee8, 0x037d19ee, 0x398c6fed, 0x3b9af26b, 0xc994a450, 0xb5341743, + 0x75a697b2, 0xac50b9c1, 0x3ccb5b92, 0xffe06205, 0xa8329761, 0xdfea5242, 0xeb83cadb, + 0xe79dadf7, 0x3c20ee69, 0x1e0a6817, 0x7021b97a, 0x743074fa, 0x176ca776, 0x77fb8af6, + 0xeca19beb, 0x92baf1de, 0xaf63b712, 0xde35c88b, 0xa4eb8f8c, 0xe137d5e9, 0x40b464a0, + 0x87d1cde8, 0x42923bbd, 0xcd8f62ff, 0x2e2690f3, 0x095edc16, 0x59c89f1b, 0x1fa8fd5d, + 0x5138753d, 0x390a2b29, 0x80152f18, 0x2dd8d925, 0xf984d83e, 0x7a872e74, 0xc19e1faf, + 0xed4d542d, 0xecf9b5d0, 0x9462ea75, 0xc53c0adf, 0x0caea134, 0x37a2d439, 0xc8fa2e8a, + 0x2181327e, 0x6e7bb827, 0x2d240820, 0x50be10e0, 0x5893d4b8, 0xab312bb9, 0x1f2b2322, + 0x440b3f25, 0xbf627ede, 0x72dac789, 0xb608b895, 0x78787e2a, 0x86deb3f0, 0x6fee7aab, + 0xbb9373f4, 0x27ecf57b, 0xf7d8b57e, 0xfca26a9f, 0x3d04e8d2, 0xc9df13cb, 0x3172826a, + 0xcd9e8d7c, 0xa8fcd8e0, 0xb2c39497, 0x307641d9, 0x1cc939c1, 0x2608c4cf, 0xb6d1c7bf, + 0x3d326a7e, 0xeeaf19e6, 0x8e13e25f, 0xee63302b, 0x2dfe6d97, 0x25971d58, 0xe41d3cc4, + 0x0a80627c, 0xab8db59a, 0x9eea37c8, 0xe90afb77, 0x90ca19cf, 0x9ee3352c, 0x3613c850, + 0xfe78d682, 0x788f6e50, 0x5b060904, 0xb71bd1a4, 0x3fecb534, 0xb32c450c, 0x20c33857, + 0xa6e9cfda, 0x0239f4ce, 0x48497187, 0xa19adb95, 0xb492ed8a, 0x95aca6a8, 0x4dcd6cd9, + 0xcf1b2350, 0xfbe8b12a, 0x1a67778c, 0x38eb3acc, 0xc32da383, 0xfb126ab1, 0xa03f40a8, + 0xed5bf546, 0xe9ce4724, 0x4c4a74fd, 0x73a130d8, 0xd9960e2d, 0xa2ebd6c1, 0x94ab6feb, + 0x6f233b7c, 0x49126080, 0x8e7b9a73, 0x4b8c9091, 0xd298f999, 0x35e836b5, 0xa96ddeff, + 0x96119b31, 0x6b0dd9bc, 0xc6cc3f8d, 0x282566fb, 0x72b882e7, 0xd6769f3b, 0xa674343d, + 0x00fc509b, 0xdcbf7789, 0xd6266a3f, 0xae9641fd, 0x4e89541b, 0x11953407, 0x53400d03, + 0x8e0dd75a, 0xe5b53345, 0x108f19ad, 0x108b89bc, 0x41a4c954, 0xe03b2b63, 0x437b3d7f, + 0x97aced8e, 0xcbd66670, 0x2c5508c2, 0x650ebc69, 0x5c4f2ef0, 0x904ff6bf, 0x9985a2df, + 0x9faddd9e, 0x5ed8d239, 0x25585832, 0xe3e51cb9, 0x0ff4f1d4, 0x56c02d9a, 0x8c4ef804, + 0xc1a08a13, 0x13fd01c8, 0xe6d27671, 0xa7c234f4, 0x9d0176cc, 0xd0d73df2, 0x4d8bfa89, + 0x544f10cd, 0x2b17e0b2, 0xb70a5c7d, 0xfd86fe49, 0xdf373f41, 0x214495bb, 0x84e857fd, + 0x00d313d5, 0x0496fcbe, 0xa4ba4744, 0xe8cac982, 0xaec29e6e, 0x87ec7038, 0x7000a519, + 0xaeee333b, 0xff66e42c, 0x8afd6b25, 0x03b4f63b, 0xbd7991dc, 0x5ab8d9c7, 0x2ed4684e, + 0x48741a6c, 0xaf06940d, 0x2fdc6349, 0xb03d7ecd, 0xe974996f, 0xac7867f9, 0x52ec8721, + 0xbcdd9d4a, 0x8edd2d00, 0x3557de06, 0x41c759f8, 0x3956d4b9, 0xa75409f2, 0x123cd8a1, + 0xb6100fab, 0x3e7b21e2, 0x2e8d623b, 0x92959da2, 0xbca35f77, 0x200c03a5, 0x35fcb457, + 0x1bb6c6e4, 0xf74eb928, 0x3d5d0b54, 0x87cc1d21, 0x4964046f, 0x18ae4240, 0xd868b275, + 0x8bd2b496, 0x1c5563f4, 0xc234d8f5, 0xf868e970, 0xf9151fff, 0xae7be4a2, 0x271133ee, + 0xbb0fd922, 0x25254932, 0xa60a9fc0, 0x104bcd64, 0x30290145, 0x00000062, + }}, +}; + +static int +BigInt_IsZero(const BigInt *i) +{ + return i->length == 0; +} + +/* + * Returns 1 if the value is even + */ +static int +BigInt_IsEven(const BigInt *i) +{ + return (i->length == 0) || ((i->blocks[0] % 2) == 0); +} + +static void +BigInt_Copy(BigInt *dst, const BigInt *src) +{ + npy_uint32 length = src->length; + npy_uint32 *dstp = dst->blocks; + const npy_uint32 *srcp; + for (srcp = src->blocks; srcp != src->blocks + length; ++dstp, ++srcp) { + *dstp = *srcp; + } + dst->length = length; +} + +/* result = result << shift */ +static void +BigInt_ShiftLeft(BigInt *result, npy_uint32 shift) +{ + npy_uint32 shiftBlocks = shift / 32; + npy_uint32 shiftBits = shift % 32; + + /* process blocks high to low so that we can safely process in place */ + const npy_uint32 *pInBlocks = result->blocks; + npy_int32 inLength = result->length; + npy_uint32 *pInCur, *pOutCur; + + DEBUG_ASSERT(inLength + shiftBlocks < c_BigInt_MaxBlocks); + DEBUG_ASSERT(shift != 0); + + /* check if the shift is block aligned */ + if (shiftBits == 0) { + npy_uint32 i; + + /* copy blocks from high to low */ + for (pInCur = result->blocks + result->length, pOutCur = pInCur + shiftBlocks; + pInCur >= pInBlocks; --pInCur, --pOutCur) { + *pOutCur = *pInCur; + } + + /* zero the remaining low blocks */ + for (i = 0; i < shiftBlocks; ++i) { + result->blocks[i] = 0; + } + + result->length += shiftBlocks; + } + /* else we need to shift partial blocks */ + else { + npy_uint32 i; + npy_int32 inBlockIdx = inLength - 1; + npy_uint32 outBlockIdx = inLength + shiftBlocks; + + /* output the initial blocks */ + const npy_uint32 lowBitsShift = (32 - shiftBits); + npy_uint32 highBits = 0; + npy_uint32 block = result->blocks[inBlockIdx]; + npy_uint32 lowBits = block >> lowBitsShift; + + /* set the length to hold the shifted blocks */ + DEBUG_ASSERT(outBlockIdx < c_BigInt_MaxBlocks); + result->length = outBlockIdx + 1; + + while (inBlockIdx > 0) { + result->blocks[outBlockIdx] = highBits | lowBits; + highBits = block << shiftBits; + + --inBlockIdx; + --outBlockIdx; + + block = result->blocks[inBlockIdx]; + lowBits = block >> lowBitsShift; + } + + /* output the final blocks */ + DEBUG_ASSERT(outBlockIdx == shiftBlocks + 1); + result->blocks[outBlockIdx] = highBits | lowBits; + result->blocks[outBlockIdx - 1] = block << shiftBits; + + /* zero the remaining low blocks */ + for (i = 0; i < shiftBlocks; ++i) { + result->blocks[i] = 0; + } + + /* check if the terminating block has no set bits */ + if (result->blocks[result->length - 1] == 0) { + --result->length; + } + } +} + +static void +BigInt_Set_uint32(BigInt *i, npy_uint32 val) +{ + if (val != 0) { + i->blocks[0] = val; + i->length = 1; + } + else { + i->length = 0; + } +} + +/* result = 2^exponent */ +static inline void +BigInt_Pow2(BigInt *result, npy_uint32 exponent) +{ + npy_uint32 bitIdx; + npy_uint32 blockIdx = exponent / 32; + npy_uint32 i; + + DEBUG_ASSERT(blockIdx < c_BigInt_MaxBlocks); + + for (i = 0; i <= blockIdx; ++i) { + result->blocks[i] = 0; + } + + result->length = blockIdx + 1; + + bitIdx = (exponent % 32); + result->blocks[blockIdx] |= ((npy_uint32)1 << bitIdx); +} + +static void +BigInt_Set_2x_uint64(BigInt *i, npy_uint64 hi, npy_uint64 lo) +{ + if (hi > bitmask_u64(32)) { + i->length = 4; + } + else if (hi != 0) { + i->length = 3; + } + else if (lo > bitmask_u64(32)) { + i->length = 2; + } + else if (lo != 0) { + i->length = 1; + } + else { + i->length = 0; + } + + /* Note deliberate fallthrough in this switch */ + switch (i->length) { + case 4: + i->blocks[3] = (hi >> 32) & bitmask_u64(32); + case 3: + i->blocks[2] = hi & bitmask_u64(32); + case 2: + i->blocks[1] = (lo >> 32) & bitmask_u64(32); + case 1: + i->blocks[0] = lo & bitmask_u64(32); + } +} + +/* result = lhs * rhs */ +static void +BigInt_Multiply_int(BigInt *result, const BigInt *lhs, npy_uint32 rhs) +{ + /* perform long multiplication */ + npy_uint32 carry = 0; + npy_uint32 *resultCur = result->blocks; + const npy_uint32 *pLhsCur = lhs->blocks; + const npy_uint32 *pLhsEnd = lhs->blocks + lhs->length; + for (; pLhsCur != pLhsEnd; ++pLhsCur, ++resultCur) { + npy_uint64 product = (npy_uint64)(*pLhsCur) * rhs + carry; + *resultCur = (npy_uint32)(product & bitmask_u64(32)); + carry = product >> 32; + } + + /* if there is a remaining carry, grow the array */ + if (carry != 0) { + /* grow the array */ + DEBUG_ASSERT(lhs->length + 1 <= c_BigInt_MaxBlocks); + *resultCur = (npy_uint32)carry; + result->length = lhs->length + 1; + } + else { + result->length = lhs->length; + } +} + +/* + * result = lhs * rhs + */ +static void +BigInt_Multiply(BigInt *result, const BigInt *lhs, const BigInt *rhs) +{ + const BigInt *large; + const BigInt *small; + npy_uint32 maxResultLen; + npy_uint32 *cur, *end, *resultStart; + const npy_uint32 *smallCur; + + DEBUG_ASSERT(result != lhs && result != rhs); + + /* determine which operand has the smaller length */ + if (lhs->length < rhs->length) { + small = lhs; + large = rhs; + } + else { + small = rhs; + large = lhs; + } + + /* set the maximum possible result length */ + maxResultLen = large->length + small->length; + DEBUG_ASSERT(maxResultLen <= c_BigInt_MaxBlocks); + + /* clear the result data */ + for (cur = result->blocks, end = cur + maxResultLen; cur != end; ++cur) { + *cur = 0; + } + + /* perform standard long multiplication for each small block */ + resultStart = result->blocks; + for (smallCur = small->blocks; smallCur != small->blocks + small->length; + ++smallCur, ++resultStart) { + /* + * if non-zero, multiply against all the large blocks and add into the + * result + */ + const npy_uint32 multiplier = *smallCur; + if (multiplier != 0) { + const npy_uint32 *largeCur = large->blocks; + npy_uint32 *resultCur = resultStart; + npy_uint64 carry = 0; + do { + npy_uint64 product = (*resultCur) + (*largeCur) * (npy_uint64)multiplier + carry; + carry = product >> 32; + *resultCur = product & bitmask_u64(32); + ++largeCur; + ++resultCur; + } while (largeCur != large->blocks + large->length); + + DEBUG_ASSERT(resultCur < result->blocks + maxResultLen); + *resultCur = (npy_uint32)(carry & bitmask_u64(32)); + } + } + + /* check if the terminating block has no set bits */ + if (maxResultLen > 0 && result->blocks[maxResultLen - 1] == 0) { + result->length = maxResultLen - 1; + } + else { + result->length = maxResultLen; + } +} + +/* in = in * 10^exponent */ +static void +BigInt_MultiplyPow10(BigInt *in, npy_uint32 exponent, BigInt *temp) +{ + /* use two temporary values to reduce large integer copy operations */ + BigInt *curTemp, *pNextTemp; + npy_uint32 smallExponent; + npy_uint32 tableIdx = 0; + + /* make sure the exponent is within the bounds of the lookup table data */ + DEBUG_ASSERT(exponent < 8192); + + /* + * initialize the result by looking up a 32-bit power of 10 corresponding to + * the first 3 bits + */ + smallExponent = exponent & bitmask_u32(3); + if (smallExponent != 0) { + BigInt_Multiply_int(temp, in, g_PowerOf10_U32[smallExponent]); + curTemp = temp; + pNextTemp = in; + } + else { + curTemp = in; + pNextTemp = temp; + } + + /* remove the low bits that we used for the 32-bit lookup table */ + exponent >>= 3; + + /* while there are remaining bits in the exponent to be processed */ + while (exponent != 0) { + /* if the current bit is set, multiply by this power of 10 */ + if (exponent & 1) { + BigInt *pSwap; + + /* multiply into the next temporary */ + BigInt_Multiply(pNextTemp, curTemp, &g_PowerOf10_Big[tableIdx]); + + /* swap to the next temporary */ + pSwap = curTemp; + curTemp = pNextTemp; + pNextTemp = pSwap; + } + + /* advance to the next bit */ + ++tableIdx; + exponent >>= 1; + } + + /* output the result */ + if (curTemp != in) { + BigInt_Copy(in, curTemp); + } +} + +/* result = 10^exponent */ +static void +BigInt_Pow10(BigInt *result, npy_uint32 exponent, BigInt *temp) +{ + /* use two temporary values to reduce large integer copy operations */ + BigInt *curTemp = result; + BigInt *pNextTemp = temp; + npy_uint32 smallExponent; + npy_uint32 tableIdx = 0; + + /* make sure the exponent is within the bounds of the lookup table data */ + DEBUG_ASSERT(exponent < 8192); + + /* + * initialize the result by looking up a 32-bit power of 10 corresponding to + * the first 3 bits + */ + smallExponent = exponent & bitmask_u32(3); + BigInt_Set_uint32(curTemp, g_PowerOf10_U32[smallExponent]); + + /* remove the low bits that we used for the 32-bit lookup table */ + exponent >>= 3; + + /* while there are remaining bits in the exponent to be processed */ + while (exponent != 0) { + /* if the current bit is set, multiply by this power of 10 */ + if (exponent & 1) { + BigInt *pSwap; + + /* multiply into the next temporary */ + BigInt_Multiply(pNextTemp, curTemp, &g_PowerOf10_Big[tableIdx]); + + /* swap to the next temporary */ + pSwap = curTemp; + curTemp = pNextTemp; + pNextTemp = pSwap; + } + + /* advance to the next bit */ + ++tableIdx; + exponent >>= 1; + } + + /* output the result */ + if (curTemp != result) { + BigInt_Copy(result, curTemp); + } +} + +/* result = lhs + rhs */ +static void +BigInt_Add(BigInt *result, const BigInt *lhs, const BigInt *rhs) +{ + /* determine which operand has the smaller length */ + const BigInt *large, *small; + npy_uint64 carry = 0; + const npy_uint32 *largeCur, *smallCur, *largeEnd, *smallEnd; + npy_uint32 *resultCur; + + if (lhs->length < rhs->length) { + small = lhs; + large = rhs; + } + else { + small = rhs; + large = lhs; + } + + /* The output will be at least as long as the largest input */ + result->length = large->length; + + /* Add each block and add carry the overflow to the next block */ + largeCur = large->blocks; + largeEnd = largeCur + large->length; + smallCur = small->blocks; + smallEnd = smallCur + small->length; + resultCur = result->blocks; + while (smallCur != smallEnd) { + npy_uint64 sum = carry + (npy_uint64)(*largeCur) + (npy_uint64)(*smallCur); + carry = sum >> 32; + *resultCur = sum & bitmask_u64(32); + ++largeCur; + ++smallCur; + ++resultCur; + } + + /* Add the carry to any blocks that only exist in the large operand */ + while (largeCur != largeEnd) { + npy_uint64 sum = carry + (npy_uint64)(*largeCur); + carry = sum >> 32; + (*resultCur) = sum & bitmask_u64(32); + ++largeCur; + ++resultCur; + } + + /* If there's still a carry, append a new block */ + if (carry != 0) { + DEBUG_ASSERT(carry == 1); + DEBUG_ASSERT((npy_uint32)(resultCur - result->blocks) == large->length && + (large->length < c_BigInt_MaxBlocks)); + *resultCur = 1; + result->length = large->length + 1; + } + else { + result->length = large->length; + } +} + +/* result = in * 2 */ +static void +BigInt_Multiply2(BigInt *result, const BigInt *in) +{ + /* shift all the blocks by one */ + npy_uint32 carry = 0; + + npy_uint32 *resultCur = result->blocks; + const npy_uint32 *pLhsCur = in->blocks; + const npy_uint32 *pLhsEnd = in->blocks + in->length; + for (; pLhsCur != pLhsEnd; ++pLhsCur, ++resultCur) { + npy_uint32 cur = *pLhsCur; + *resultCur = (cur << 1) | carry; + carry = cur >> 31; + } + + if (carry != 0) { + /* grow the array */ + DEBUG_ASSERT(in->length + 1 <= c_BigInt_MaxBlocks); + *resultCur = carry; + result->length = in->length + 1; + } + else { + result->length = in->length; + } +} + +/* result = result * 2 */ +static void +BigInt_Multiply2_inplace(BigInt *result) +{ + /* shift all the blocks by one */ + npy_uint32 carry = 0; + + npy_uint32 *cur = result->blocks; + npy_uint32 *end = result->blocks + result->length; + for (; cur != end; ++cur) { + npy_uint32 tmpcur = *cur; + *cur = (tmpcur << 1) | carry; + carry = tmpcur >> 31; + } + + if (carry != 0) { + /* grow the array */ + DEBUG_ASSERT(result->length + 1 <= c_BigInt_MaxBlocks); + *cur = carry; + ++result->length; + } +} + +static npy_int32 +BigInt_Compare(const BigInt *lhs, const BigInt *rhs) +{ + int i; + + /* A bigger length implies a bigger number. */ + npy_int32 lengthDiff = lhs->length - rhs->length; + if (lengthDiff != 0) { + return lengthDiff; + } + + /* Compare blocks one by one from high to low. */ + for (i = lhs->length - 1; i >= 0; --i) { + if (lhs->blocks[i] == rhs->blocks[i]) { + continue; + } + else if (lhs->blocks[i] > rhs->blocks[i]) { + return 1; + } + else { + return -1; + } + } + + /* no blocks differed */ + return 0; +} + +static npy_uint32 +BigInt_DivideWithRemainder_MaxQuotient9(BigInt *dividend, const BigInt *divisor) +{ + npy_uint32 length, quotient; + const npy_uint32 *finalDivisorBlock; + npy_uint32 *finalDividendBlock; + + /* + * Check that the divisor has been correctly shifted into range and that it + * is not smaller than the dividend in length. + */ + DEBUG_ASSERT(!divisor->length == 0 && divisor->blocks[divisor->length - 1] >= 8 && + divisor->blocks[divisor->length - 1] < bitmask_u64(32) && + dividend->length <= divisor->length); + + /* + * If the dividend is smaller than the divisor, the quotient is zero and the + * divisor is already the remainder. + */ + length = divisor->length; + if (dividend->length < divisor->length) { + return 0; + } + + finalDivisorBlock = divisor->blocks + length - 1; + finalDividendBlock = dividend->blocks + length - 1; + + /* + * Compute an estimated quotient based on the high block value. This will + * either match the actual quotient or undershoot by one. + */ + quotient = *finalDividendBlock / (*finalDivisorBlock + 1); + DEBUG_ASSERT(quotient <= 9); + + /* Divide out the estimated quotient */ + if (quotient != 0) { + /* dividend = dividend - divisor*quotient */ + const npy_uint32 *divisorCur = divisor->blocks; + npy_uint32 *dividendCur = dividend->blocks; + + npy_uint64 borrow = 0; + npy_uint64 carry = 0; + do { + npy_uint64 difference, product; + + product = (npy_uint64)*divisorCur * (npy_uint64)quotient + carry; + carry = product >> 32; + + difference = (npy_uint64)*dividendCur - (product & bitmask_u64(32)) - borrow; + borrow = (difference >> 32) & 1; + + *dividendCur = difference & bitmask_u64(32); + + ++divisorCur; + ++dividendCur; + } while (divisorCur <= finalDivisorBlock); + + /* remove all leading zero blocks from dividend */ + while (length > 0 && dividend->blocks[length - 1] == 0) { + --length; + } + + dividend->length = length; + } + + /* + * If the dividend is still larger than the divisor, we overshot our + * estimate quotient. To correct, we increment the quotient and subtract one + * more divisor from the dividend. + */ + if (BigInt_Compare(dividend, divisor) >= 0) { + /* dividend = dividend - divisor */ + const npy_uint32 *divisorCur = divisor->blocks; + npy_uint32 *dividendCur = dividend->blocks; + npy_uint64 borrow = 0; + + ++quotient; + + do { + npy_uint64 difference = (npy_uint64)*dividendCur - (npy_uint64)*divisorCur - borrow; + borrow = (difference >> 32) & 1; + + *dividendCur = difference & bitmask_u64(32); + + ++divisorCur; + ++dividendCur; + } while (divisorCur <= finalDivisorBlock); + + /* remove all leading zero blocks from dividend */ + while (length > 0 && dividend->blocks[length - 1] == 0) { + --length; + } + + dividend->length = length; + } + + return quotient; +} + +static npy_uint32 +LogBase2_32(npy_uint32 val) +{ + static const npy_uint8 logTable[256] = { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; + + npy_uint32 temp; + + temp = val >> 24; + if (temp) { + return 24 + logTable[temp]; + } + + temp = val >> 16; + if (temp) { + return 16 + logTable[temp]; + } + + temp = val >> 8; + if (temp) { + return 8 + logTable[temp]; + } + + return logTable[val]; +} + +static npy_uint32 +LogBase2_64(npy_uint64 val) +{ + npy_uint64 temp; + + temp = val >> 32; + if (temp) { + return 32 + LogBase2_32((npy_uint32)temp); + } + + return LogBase2_32((npy_uint32)val); +} + +static npy_uint32 +LogBase2_128(npy_uint64 hi, npy_uint64 lo) +{ + if (hi) { + return 64 + LogBase2_64(hi); + } + + return LogBase2_64(lo); +} + +static npy_uint32 +PrintInfNan(char *buffer, npy_uint32 bufferSize, npy_uint64 mantissa, npy_uint32 mantissaHexWidth, + char signbit) +{ + npy_uint32 maxPrintLen = bufferSize - 1; + npy_uint32 pos = 0; + + DEBUG_ASSERT(bufferSize > 0); + + /* Check for infinity */ + if (mantissa == 0) { + npy_uint32 printLen; + + /* only print sign for inf values (though nan can have a sign set) */ + if (signbit == '+') { + if (pos < maxPrintLen - 1) { + buffer[pos++] = '+'; + } + } + else if (signbit == '-') { + if (pos < maxPrintLen - 1) { + buffer[pos++] = '-'; + } + } + + /* copy and make sure the buffer is terminated */ + printLen = (3 < maxPrintLen - pos) ? 3 : maxPrintLen - pos; + memcpy(buffer + pos, "inf", printLen); + buffer[pos + printLen] = '\0'; + return pos + printLen; + } + else { + /* copy and make sure the buffer is terminated */ + npy_uint32 printLen = (3 < maxPrintLen - pos) ? 3 : maxPrintLen - pos; + memcpy(buffer + pos, "nan", printLen); + buffer[pos + printLen] = '\0'; + + /* + * For numpy we ignore unusual mantissa values for nan, but keep this + * code in case we change our mind later. + * + * // append HEX value + * if (maxPrintLen > 3) { + * printLen += PrintHex(buffer+3, bufferSize-3, mantissa, + * mantissaHexWidth); + * } + */ + + return pos + printLen; + } +} + +static npy_uint32 +Dragon4(BigInt *bigints, const npy_int32 exponent, const npy_uint32 mantissaBit, + const npy_bool hasUnequalMargins, const DigitMode digitMode, const CutoffMode cutoffMode, + npy_int32 cutoff_max, npy_int32 cutoff_min, char *pOutBuffer, npy_uint32 bufferSize, + npy_int32 *pOutExponent) +{ + char *curDigit = pOutBuffer; + + /* + * We compute values in integer format by rescaling as + * mantissa = scaledValue / scale + * marginLow = scaledMarginLow / scale + * marginHigh = scaledMarginHigh / scale + * Here, marginLow and marginHigh represent 1/2 of the distance to the next + * floating point value above/below the mantissa. + * + * scaledMarginHigh will point to scaledMarginLow in the case they must be + * equal to each other, otherwise it will point to optionalMarginHigh. + */ + BigInt *mantissa = &bigints[0]; /* the only initialized bigint */ + BigInt *scale = &bigints[1]; + BigInt *scaledValue = &bigints[2]; + BigInt *scaledMarginLow = &bigints[3]; + BigInt *scaledMarginHigh; + BigInt *optionalMarginHigh = &bigints[4]; + + BigInt *temp1 = &bigints[5]; + BigInt *temp2 = &bigints[6]; + + const npy_float64 log10_2 = 0.30102999566398119521373889472449; + npy_int32 digitExponent, hiBlock; + npy_int32 cutoff_max_Exponent, cutoff_min_Exponent; + npy_uint32 outputDigit; /* current digit being output */ + npy_uint32 outputLen; + npy_bool isEven = BigInt_IsEven(mantissa); + npy_int32 cmp; + + /* values used to determine how to round */ + npy_bool low, high, roundDown; + + DEBUG_ASSERT(bufferSize > 0); + + /* if the mantissa is zero, the value is zero regardless of the exponent */ + if (BigInt_IsZero(mantissa)) { + *curDigit = '0'; + *pOutExponent = 0; + return 1; + } + + BigInt_Copy(scaledValue, mantissa); + + if (hasUnequalMargins) { + /* if we have no fractional component */ + if (exponent > 0) { + /* + * 1) Expand the input value by multiplying out the mantissa and + * exponent. This represents the input value in its whole number + * representation. + * 2) Apply an additional scale of 2 such that later comparisons + * against the margin values are simplified. + * 3) Set the margin value to the lowest mantissa bit's scale. + */ + + /* scaledValue = 2 * 2 * mantissa*2^exponent */ + BigInt_ShiftLeft(scaledValue, exponent + 2); + /* scale = 2 * 2 * 1 */ + BigInt_Set_uint32(scale, 4); + /* scaledMarginLow = 2 * 2^(exponent-1) */ + BigInt_Pow2(scaledMarginLow, exponent); + /* scaledMarginHigh = 2 * 2 * 2^(exponent-1) */ + BigInt_Pow2(optionalMarginHigh, exponent + 1); + } + /* else we have a fractional exponent */ + else { + /* + * In order to track the mantissa data as an integer, we store it as + * is with a large scale + */ + + /* scaledValue = 2 * 2 * mantissa */ + BigInt_ShiftLeft(scaledValue, 2); + /* scale = 2 * 2 * 2^(-exponent) */ + BigInt_Pow2(scale, -exponent + 2); + /* scaledMarginLow = 2 * 2^(-1) */ + BigInt_Set_uint32(scaledMarginLow, 1); + /* scaledMarginHigh = 2 * 2 * 2^(-1) */ + BigInt_Set_uint32(optionalMarginHigh, 2); + } + + /* the high and low margins are different */ + scaledMarginHigh = optionalMarginHigh; + } + else { + /* if we have no fractional component */ + if (exponent > 0) { + /* scaledValue = 2 * mantissa*2^exponent */ + BigInt_ShiftLeft(scaledValue, exponent + 1); + /* scale = 2 * 1 */ + BigInt_Set_uint32(scale, 2); + /* scaledMarginLow = 2 * 2^(exponent-1) */ + BigInt_Pow2(scaledMarginLow, exponent); + } + /* else we have a fractional exponent */ + else { + /* + * In order to track the mantissa data as an integer, we store it as + * is with a large scale + */ + + /* scaledValue = 2 * mantissa */ + BigInt_ShiftLeft(scaledValue, 1); + /* scale = 2 * 2^(-exponent) */ + BigInt_Pow2(scale, -exponent + 1); + /* scaledMarginLow = 2 * 2^(-1) */ + BigInt_Set_uint32(scaledMarginLow, 1); + } + + /* the high and low margins are equal */ + scaledMarginHigh = scaledMarginLow; + } + + /* + * Compute an estimate for digitExponent that will be correct or undershoot + * by one. This optimization is based on the paper "Printing Floating-Point + * Numbers Quickly and Accurately" by Burger and Dybvig + * https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.4656 + * We perform an additional subtraction of 0.69 to increase the frequency of + * a failed estimate because that lets us take a faster branch in the code. + * 0.69 is chosen because 0.69 + log10(2) is less than one by a reasonable + * epsilon that will account for any floating point error. + * + * We want to set digitExponent to floor(log10(v)) + 1 + * v = mantissa*2^exponent + * log2(v) = log2(mantissa) + exponent; + * log10(v) = log2(v) * log10(2) + * floor(log2(v)) = mantissaBit + exponent; + * log10(v) - log10(2) < (mantissaBit + exponent) * log10(2) <= log10(v) + * log10(v) < (mantissaBit + exponent) * log10(2) + log10(2) + * <= log10(v) + log10(2) + * floor(log10(v)) < ceil((mantissaBit + exponent) * log10(2)) + * <= floor(log10(v)) + 1 + * + * Warning: This calculation assumes npy_float64 is an IEEE-binary64 + * float. This line may need to be updated if this is not the case. + */ + digitExponent = + (npy_int32)(ceil((npy_float64)((npy_int32)mantissaBit + exponent) * log10_2 - 0.69)); + + /* + * if the digit exponent is smaller than the smallest desired digit for + * fractional cutoff, pull the digit back into legal range at which point we + * will round to the appropriate value. Note that while our value for + * digitExponent is still an estimate, this is safe because it only + * increases the number. This will either correct digitExponent to an + * accurate value or it will clamp it above the accurate value. + */ + if (cutoff_max >= 0 && cutoffMode == CutoffMode_FractionLength && + digitExponent <= -cutoff_max) { + digitExponent = -cutoff_max + 1; + } + + /* Divide value by 10^digitExponent. */ + if (digitExponent > 0) { + /* A positive exponent creates a division so we multiply the scale. */ + BigInt_MultiplyPow10(scale, digitExponent, temp1); + } + else if (digitExponent < 0) { + /* + * A negative exponent creates a multiplication so we multiply up the + * scaledValue, scaledMarginLow and scaledMarginHigh. + */ + BigInt *temp = temp1, *pow10 = temp2; + BigInt_Pow10(pow10, -digitExponent, temp); + + BigInt_Multiply(temp, scaledValue, pow10); + BigInt_Copy(scaledValue, temp); + + BigInt_Multiply(temp, scaledMarginLow, pow10); + BigInt_Copy(scaledMarginLow, temp); + + if (scaledMarginHigh != scaledMarginLow) { + BigInt_Multiply2(scaledMarginHigh, scaledMarginLow); + } + } + + /* If (value >= 1), our estimate for digitExponent was too low */ + if (BigInt_Compare(scaledValue, scale) >= 0) { + /* + * The exponent estimate was incorrect. + * Increment the exponent and don't perform the premultiply needed + * for the first loop iteration. + */ + digitExponent = digitExponent + 1; + } + else { + /* + * The exponent estimate was correct. + * Multiply larger by the output base to prepare for the first loop + * iteration. + */ + BigInt_Multiply10(scaledValue); + BigInt_Multiply10(scaledMarginLow); + if (scaledMarginHigh != scaledMarginLow) { + BigInt_Multiply2(scaledMarginHigh, scaledMarginLow); + } + } + + /* + * Compute the cutoff_max exponent (the exponent of the final digit to + * print). Default to the maximum size of the output buffer. + */ + cutoff_max_Exponent = digitExponent - bufferSize; + if (cutoff_max >= 0) { + npy_int32 desiredCutoffExponent; + + if (cutoffMode == CutoffMode_TotalLength) { + desiredCutoffExponent = digitExponent - cutoff_max; + if (desiredCutoffExponent > cutoff_max_Exponent) { + cutoff_max_Exponent = desiredCutoffExponent; + } + } + /* Otherwise it's CutoffMode_FractionLength. Print cutoff_max digits + * past the decimal point or until we reach the buffer size + */ + else { + desiredCutoffExponent = -cutoff_max; + if (desiredCutoffExponent > cutoff_max_Exponent) { + cutoff_max_Exponent = desiredCutoffExponent; + } + } + } + /* Also compute the cutoff_min exponent. */ + cutoff_min_Exponent = digitExponent; + if (cutoff_min >= 0) { + npy_int32 desiredCutoffExponent; + + if (cutoffMode == CutoffMode_TotalLength) { + desiredCutoffExponent = digitExponent - cutoff_min; + if (desiredCutoffExponent < cutoff_min_Exponent) { + cutoff_min_Exponent = desiredCutoffExponent; + } + } + else { + desiredCutoffExponent = -cutoff_min; + if (desiredCutoffExponent < cutoff_min_Exponent) { + cutoff_min_Exponent = desiredCutoffExponent; + } + } + } + + /* Output the exponent of the first digit we will print */ + *pOutExponent = digitExponent - 1; + + /* + * In preparation for calling BigInt_DivideWithRemainder_MaxQuotient9(), we + * need to scale up our values such that the highest block of the + * denominator is greater than or equal to 8. We also need to guarantee that + * the numerator can never have a length greater than the denominator after + * each loop iteration. This requires the highest block of the denominator + * to be less than or equal to 429496729 which is the highest number that + * can be multiplied by 10 without overflowing to a new block. + */ + DEBUG_ASSERT(scale->length > 0); + hiBlock = scale->blocks[scale->length - 1]; + if (hiBlock < 8 || hiBlock > 429496729) { + npy_uint32 hiBlockLog2, shift; + + /* + * Perform a bit shift on all values to get the highest block of the + * denominator into the range [8,429496729]. We are more likely to make + * accurate quotient estimations in + * BigInt_DivideWithRemainder_MaxQuotient9() with higher denominator + * values so we shift the denominator to place the highest bit at index + * 27 of the highest block. This is safe because (2^28 - 1) = 268435455 + * which is less than 429496729. This means that all values with a + * highest bit at index 27 are within range. + */ + hiBlockLog2 = LogBase2_32(hiBlock); + DEBUG_ASSERT(hiBlockLog2 < 3 || hiBlockLog2 > 27); + shift = (32 + 27 - hiBlockLog2) % 32; + + BigInt_ShiftLeft(scale, shift); + BigInt_ShiftLeft(scaledValue, shift); + BigInt_ShiftLeft(scaledMarginLow, shift); + if (scaledMarginHigh != scaledMarginLow) { + BigInt_Multiply2(scaledMarginHigh, scaledMarginLow); + } + } + + if (digitMode == DigitMode_Unique) { + /* + * For the unique cutoff mode, we will try to print until we have + * reached a level of precision that uniquely distinguishes this value + * from its neighbors. If we run out of space in the output buffer, we + * terminate early. + */ + for (;;) { + BigInt *scaledValueHigh = temp1; + + digitExponent = digitExponent - 1; + + /* divide out the scale to extract the digit */ + outputDigit = BigInt_DivideWithRemainder_MaxQuotient9(scaledValue, scale); + DEBUG_ASSERT(outputDigit < 10); + + /* update the high end of the value */ + BigInt_Add(scaledValueHigh, scaledValue, scaledMarginHigh); + + /* + * stop looping if we are far enough away from our neighboring + * values (and we have printed at least the requested minimum + * digits) or if we have reached the cutoff digit + */ + cmp = BigInt_Compare(scaledValue, scaledMarginLow); + low = isEven ? (cmp <= 0) : (cmp < 0); + cmp = BigInt_Compare(scaledValueHigh, scale); + high = isEven ? (cmp >= 0) : (cmp > 0); + if (((low | high) & (digitExponent <= cutoff_min_Exponent)) | + (digitExponent == cutoff_max_Exponent)) { + break; + } + + /* store the output digit */ + *curDigit = (char)('0' + outputDigit); + ++curDigit; + + /* multiply larger by the output base */ + BigInt_Multiply10(scaledValue); + BigInt_Multiply10(scaledMarginLow); + if (scaledMarginHigh != scaledMarginLow) { + BigInt_Multiply2(scaledMarginHigh, scaledMarginLow); + } + } + } + else { + /* + * For exact digit mode, we will try to print until we + * have exhausted all precision (i.e. all remaining digits are zeros) or + * until we reach the desired cutoff digit. + */ + low = NPY_FALSE; + high = NPY_FALSE; + + for (;;) { + digitExponent = digitExponent - 1; + + /* divide out the scale to extract the digit */ + outputDigit = BigInt_DivideWithRemainder_MaxQuotient9(scaledValue, scale); + DEBUG_ASSERT(outputDigit < 10); + + if ((scaledValue->length == 0) | (digitExponent == cutoff_max_Exponent)) { + break; + } + + /* store the output digit */ + *curDigit = (char)('0' + outputDigit); + ++curDigit; + + /* multiply larger by the output base */ + BigInt_Multiply10(scaledValue); + } + } + + /* default to rounding down the final digit if value got too close to 0 */ + roundDown = low; + + /* if it is legal to round up and down */ + if (low == high) { + npy_int32 compare; + + /* + * round to the closest digit by comparing value with 0.5. To do this we + * need to convert the inequality to large integer values. + * compare( value, 0.5 ) + * compare( scale * value, scale * 0.5 ) + * compare( 2 * scale * value, scale ) + */ + BigInt_Multiply2_inplace(scaledValue); + compare = BigInt_Compare(scaledValue, scale); + roundDown = compare < 0; + + /* + * if we are directly in the middle, round towards the even digit (i.e. + * IEEE rounding rules) + */ + if (compare == 0) { + roundDown = (outputDigit & 1) == 0; + } + } + + /* print the rounded digit */ + if (roundDown) { + *curDigit = (char)('0' + outputDigit); + ++curDigit; + } + else { + /* handle rounding up */ + if (outputDigit == 9) { + /* find the first non-nine prior digit */ + for (;;) { + /* if we are at the first digit */ + if (curDigit == pOutBuffer) { + /* output 1 at the next highest exponent */ + *curDigit = '1'; + ++curDigit; + *pOutExponent += 1; + break; + } + + --curDigit; + if (*curDigit != '9') { + /* increment the digit */ + *curDigit += 1; + ++curDigit; + break; + } + } + } + else { + /* values in the range [0,8] can perform a simple round up */ + *curDigit = (char)('0' + outputDigit + 1); + ++curDigit; + } + } + + /* return the number of digits output */ + outputLen = (npy_uint32)(curDigit - pOutBuffer); + DEBUG_ASSERT(outputLen <= bufferSize); + return outputLen; +} + +static npy_uint32 +FormatPositional(char *buffer, npy_uint32 bufferSize, BigInt *mantissa, npy_int32 exponent, + char signbit, npy_uint32 mantissaBit, npy_bool hasUnequalMargins, + DigitMode digit_mode, CutoffMode cutoff_mode, npy_int32 precision, + npy_int32 min_digits, TrimMode trim_mode, npy_int32 digits_left, + npy_int32 digits_right) +{ + npy_int32 printExponent; + npy_int32 numDigits, numWholeDigits = 0, has_sign = 0; + npy_int32 add_digits; + + npy_int32 maxPrintLen = (npy_int32)bufferSize - 1, pos = 0; + + /* track the # of digits past the decimal point that have been printed */ + npy_int32 numFractionDigits = 0, desiredFractionalDigits; + + DEBUG_ASSERT(bufferSize > 0); + + if (digit_mode != DigitMode_Unique) { + DEBUG_ASSERT(precision >= 0); + } + + if (signbit == '+' && pos < maxPrintLen) { + buffer[pos++] = '+'; + has_sign = 1; + } + else if (signbit == '-' && pos < maxPrintLen) { + buffer[pos++] = '-'; + has_sign = 1; + } + + numDigits = Dragon4(mantissa, exponent, mantissaBit, hasUnequalMargins, digit_mode, cutoff_mode, + precision, min_digits, buffer + has_sign, maxPrintLen - has_sign, + &printExponent); + + DEBUG_ASSERT(numDigits > 0); + DEBUG_ASSERT(numDigits <= bufferSize); + + /* if output has a whole number */ + if (printExponent >= 0) { + /* leave the whole number at the start of the buffer */ + numWholeDigits = printExponent + 1; + if (numDigits <= numWholeDigits) { + npy_int32 count = numWholeDigits - numDigits; + pos += numDigits; + + /* don't overflow the buffer */ + if (pos + count > maxPrintLen) { + count = maxPrintLen - pos; + } + + /* add trailing zeros up to the decimal point */ + numDigits += count; + for (; count > 0; count--) { + buffer[pos++] = '0'; + } + } + /* insert the decimal point prior to the fraction */ + else if (numDigits > numWholeDigits) { + npy_int32 maxFractionDigits; + + numFractionDigits = numDigits - numWholeDigits; + maxFractionDigits = maxPrintLen - numWholeDigits - 1 - pos; + if (numFractionDigits > maxFractionDigits) { + numFractionDigits = maxFractionDigits; + } + + memmove(buffer + pos + numWholeDigits + 1, buffer + pos + numWholeDigits, + numFractionDigits); + pos += numWholeDigits; + buffer[pos] = '.'; + numDigits = numWholeDigits + 1 + numFractionDigits; + pos += 1 + numFractionDigits; + } + } + else { + /* shift out the fraction to make room for the leading zeros */ + npy_int32 numFractionZeros = 0; + if (pos + 2 < maxPrintLen) { + npy_int32 maxFractionZeros, digitsStartIdx, maxFractionDigits, i; + + maxFractionZeros = maxPrintLen - 2 - pos; + numFractionZeros = -(printExponent + 1); + if (numFractionZeros > maxFractionZeros) { + numFractionZeros = maxFractionZeros; + } + + digitsStartIdx = 2 + numFractionZeros; + + /* + * shift the significant digits right such that there is room for + * leading zeros + */ + numFractionDigits = numDigits; + maxFractionDigits = maxPrintLen - digitsStartIdx - pos; + if (numFractionDigits > maxFractionDigits) { + numFractionDigits = maxFractionDigits; + } + + memmove(buffer + pos + digitsStartIdx, buffer + pos, numFractionDigits); + + /* insert the leading zeros */ + for (i = 2; i < digitsStartIdx; ++i) { + buffer[pos + i] = '0'; + } + + /* update the counts */ + numFractionDigits += numFractionZeros; + numDigits = numFractionDigits; + } + + /* add the decimal point */ + if (pos + 1 < maxPrintLen) { + buffer[pos + 1] = '.'; + } + + /* add the initial zero */ + if (pos < maxPrintLen) { + buffer[pos] = '0'; + numDigits += 1; + } + numWholeDigits = 1; + pos += 2 + numFractionDigits; + } + + /* always add decimal point, except for DprZeros mode */ + if (trim_mode != TrimMode_DptZeros && numFractionDigits == 0 && pos < maxPrintLen) { + buffer[pos++] = '.'; + } + + add_digits = digit_mode == DigitMode_Unique ? min_digits : precision; + desiredFractionalDigits = add_digits < 0 ? 0 : add_digits; + if (cutoff_mode == CutoffMode_TotalLength) { + desiredFractionalDigits = add_digits - numWholeDigits; + } + + if (trim_mode == TrimMode_LeaveOneZero) { + /* if we didn't print any fractional digits, add a trailing 0 */ + if (numFractionDigits == 0 && pos < maxPrintLen) { + buffer[pos++] = '0'; + numFractionDigits++; + } + } + else if (trim_mode == TrimMode_None && desiredFractionalDigits > numFractionDigits && + pos < maxPrintLen) { + /* add trailing zeros up to add_digits length */ + /* compute the number of trailing zeros needed */ + npy_int32 count = desiredFractionalDigits - numFractionDigits; + if (pos + count > maxPrintLen) { + count = maxPrintLen - pos; + } + numFractionDigits += count; + + for (; count > 0; count--) { + buffer[pos++] = '0'; + } + } + /* else, for trim_mode Zeros or DptZeros, there is nothing more to add */ + + /* + * when rounding, we may still end up with trailing zeros. Remove them + * depending on trim settings. + */ + if (trim_mode != TrimMode_None && numFractionDigits > 0) { + while (buffer[pos - 1] == '0') { + pos--; + numFractionDigits--; + } + if (buffer[pos - 1] == '.') { + /* in TrimMode_LeaveOneZero, add trailing 0 back */ + if (trim_mode == TrimMode_LeaveOneZero) { + buffer[pos++] = '0'; + numFractionDigits++; + } + /* in TrimMode_DptZeros, remove trailing decimal point */ + else if (trim_mode == TrimMode_DptZeros) { + pos--; + } + } + } + + /* add any whitespace padding to right side */ + if (digits_right >= numFractionDigits) { + npy_int32 count = digits_right - numFractionDigits; + + /* in trim_mode DptZeros, if right padding, add a space for the . */ + if (trim_mode == TrimMode_DptZeros && numFractionDigits == 0 && pos < maxPrintLen) { + buffer[pos++] = ' '; + } + + if (pos + count > maxPrintLen) { + count = maxPrintLen - pos; + } + + for (; count > 0; count--) { + buffer[pos++] = ' '; + } + } + /* add any whitespace padding to left side */ + if (digits_left > numWholeDigits + has_sign) { + npy_int32 shift = digits_left - (numWholeDigits + has_sign); + npy_int32 count = pos; + + if (count + shift > maxPrintLen) { + count = maxPrintLen - shift; + } + + if (count > 0) { + memmove(buffer + shift, buffer, count); + } + pos = shift + count; + for (; shift > 0; shift--) { + buffer[shift - 1] = ' '; + } + } + + /* terminate the buffer */ + DEBUG_ASSERT(pos <= maxPrintLen); + buffer[pos] = '\0'; + + return pos; +} + +static npy_uint32 +FormatScientific(char *buffer, npy_uint32 bufferSize, BigInt *mantissa, npy_int32 exponent, + char signbit, npy_uint32 mantissaBit, npy_bool hasUnequalMargins, + DigitMode digit_mode, npy_int32 precision, npy_int32 min_digits, + TrimMode trim_mode, npy_int32 digits_left, npy_int32 exp_digits) +{ + npy_int32 printExponent; + npy_int32 numDigits; + char *pCurOut; + npy_int32 numFractionDigits; + npy_int32 leftchars; + npy_int32 add_digits; + + if (digit_mode != DigitMode_Unique) { + DEBUG_ASSERT(precision >= 0); + } + + DEBUG_ASSERT(bufferSize > 0); + + pCurOut = buffer; + + /* add any whitespace padding to left side */ + leftchars = 1 + (signbit == '-' || signbit == '+'); + if (digits_left > leftchars) { + int i; + for (i = 0; i < digits_left - leftchars && bufferSize > 1; i++) { + *pCurOut = ' '; + pCurOut++; + --bufferSize; + } + } + + if (signbit == '+' && bufferSize > 1) { + *pCurOut = '+'; + pCurOut++; + --bufferSize; + } + else if (signbit == '-' && bufferSize > 1) { + *pCurOut = '-'; + pCurOut++; + --bufferSize; + } + + numDigits = Dragon4(mantissa, exponent, mantissaBit, hasUnequalMargins, digit_mode, + CutoffMode_TotalLength, precision < 0 ? -1 : precision + 1, + min_digits < 0 ? -1 : min_digits + 1, pCurOut, bufferSize, &printExponent); + + DEBUG_ASSERT(numDigits > 0); + DEBUG_ASSERT(numDigits <= bufferSize); + + /* keep the whole number as the first digit */ + if (bufferSize > 1) { + pCurOut += 1; + bufferSize -= 1; + } + + /* insert the decimal point prior to the fractional number */ + numFractionDigits = numDigits - 1; + if (numFractionDigits > 0 && bufferSize > 1) { + npy_int32 maxFractionDigits = (npy_int32)bufferSize - 2; + + if (numFractionDigits > maxFractionDigits) { + numFractionDigits = maxFractionDigits; + } + + memmove(pCurOut + 1, pCurOut, numFractionDigits); + pCurOut[0] = '.'; + pCurOut += (1 + numFractionDigits); + bufferSize -= (1 + numFractionDigits); + } + + /* always add decimal point, except for DprZeros mode */ + if (trim_mode != TrimMode_DptZeros && numFractionDigits == 0 && bufferSize > 1) { + *pCurOut = '.'; + ++pCurOut; + --bufferSize; + } + + add_digits = digit_mode == DigitMode_Unique ? min_digits : precision; + add_digits = add_digits < 0 ? 0 : add_digits; + if (trim_mode == TrimMode_LeaveOneZero) { + /* if we didn't print any fractional digits, add the 0 */ + if (numFractionDigits == 0 && bufferSize > 1) { + *pCurOut = '0'; + ++pCurOut; + --bufferSize; + ++numFractionDigits; + } + } + else if (trim_mode == TrimMode_None) { + /* add trailing zeros up to add_digits length */ + if (add_digits > (npy_int32)numFractionDigits) { + char *pEnd; + /* compute the number of trailing zeros needed */ + npy_int32 numZeros = (add_digits - numFractionDigits); + + if (numZeros > (npy_int32)bufferSize - 1) { + numZeros = (npy_int32)bufferSize - 1; + } + + for (pEnd = pCurOut + numZeros; pCurOut < pEnd; ++pCurOut) { + *pCurOut = '0'; + ++numFractionDigits; + } + } + } + /* else, for trim_mode Zeros or DptZeros, there is nothing more to add */ + + /* + * when rounding, we may still end up with trailing zeros. Remove them + * depending on trim settings. + */ + if (trim_mode != TrimMode_None && numFractionDigits > 0) { + --pCurOut; + while (*pCurOut == '0') { + --pCurOut; + ++bufferSize; + --numFractionDigits; + } + if (trim_mode == TrimMode_LeaveOneZero && *pCurOut == '.') { + ++pCurOut; + *pCurOut = '0'; + --bufferSize; + ++numFractionDigits; + } + ++pCurOut; + } + + /* print the exponent into a local buffer and copy into output buffer */ + if (bufferSize > 1) { + char exponentBuffer[7]; + npy_int32 digits[5]; + npy_int32 i, exp_size, count; + + if (exp_digits > 5) { + exp_digits = 5; + } + if (exp_digits < 0) { + exp_digits = 2; + } + + exponentBuffer[0] = 'e'; + if (printExponent >= 0) { + exponentBuffer[1] = '+'; + } + else { + exponentBuffer[1] = '-'; + printExponent = -printExponent; + } + + DEBUG_ASSERT(printExponent < 100000); + + /* get exp digits */ + for (i = 0; i < 5; i++) { + digits[i] = printExponent % 10; + printExponent /= 10; + } + /* count back over leading zeros */ + for (i = 5; i > exp_digits && digits[i - 1] == 0; i--) { + } + exp_size = i; + /* write remaining digits to tmp buf */ + for (i = exp_size; i > 0; i--) { + exponentBuffer[2 + (exp_size - i)] = (char)('0' + digits[i - 1]); + } + + /* copy the exponent buffer into the output */ + count = exp_size + 2; + if (count > (npy_int32)bufferSize - 1) { + count = (npy_int32)bufferSize - 1; + } + memcpy(pCurOut, exponentBuffer, count); + pCurOut += count; + bufferSize -= count; + } + + DEBUG_ASSERT(bufferSize > 0); + pCurOut[0] = '\0'; + + return pCurOut - buffer; +} + +static npy_uint32 +Format_floatbits(char *buffer, npy_uint32 bufferSize, BigInt *mantissa, npy_int32 exponent, + char signbit, npy_uint32 mantissaBit, npy_bool hasUnequalMargins, + Dragon4_Options *opt) +{ + /* format the value */ + if (opt->scientific) { + return FormatScientific(buffer, bufferSize, mantissa, exponent, signbit, mantissaBit, + hasUnequalMargins, opt->digit_mode, opt->precision, opt->min_digits, + opt->trim_mode, opt->digits_left, opt->exp_digits); + } + else { + return FormatPositional(buffer, bufferSize, mantissa, exponent, signbit, mantissaBit, + hasUnequalMargins, opt->digit_mode, opt->cutoff_mode, + opt->precision, opt->min_digits, opt->trim_mode, opt->digits_left, + opt->digits_right); + } +} + +static npy_uint32 +Dragon4_PrintFloat_Sleef_quad(Sleef_quad *value, Dragon4_Options *opt) +{ + char *buffer = _bigint_static.repr; + const npy_uint32 bufferSize = sizeof(_bigint_static.repr); + BigInt *bigints = _bigint_static.bigints; + + npy_uint32 floatExponent, floatSign; + npy_uint64 mantissa_hi, mantissa_lo; + npy_int32 exponent; + npy_uint32 mantissaBit; + npy_bool hasUnequalMargins; + char signbit = '\0'; + + // Extract the bits from the SLEEF quad value + union { + Sleef_quad q; + struct { + npy_uint64 lo; + npy_uint64 hi; + } i; + } u; + u.q = *value; + + // Extract mantissa, exponent, and sign + mantissa_hi = u.i.hi & bitmask_u64(48); + mantissa_lo = u.i.lo; + floatExponent = (u.i.hi >> 48) & bitmask_u32(15); + floatSign = u.i.hi >> 63; + + /* output the sign */ + if (floatSign != 0) { + signbit = '-'; + } + // else if (opt->sign) { + // signbit = '+'; + // } + + /* if this is a special value */ + if (floatExponent == bitmask_u32(15)) { + npy_uint64 mantissa_zero = mantissa_hi == 0 && mantissa_lo == 0; + return PrintInfNan(buffer, bufferSize, !mantissa_zero, 16, signbit); + } + /* else this is a number */ + + /* factor the value into its parts */ + if (floatExponent != 0) { + /* normal */ + mantissa_hi = (1ull << 48) | mantissa_hi; + /* mantissa_lo is unchanged */ + exponent = floatExponent - 16383 - 112; + mantissaBit = 112; + hasUnequalMargins = (floatExponent != 1) && (mantissa_hi == 0 && mantissa_lo == 0); + } + else { + /* subnormal */ + exponent = 1 - 16383 - 112; + mantissaBit = LogBase2_128(mantissa_hi, mantissa_lo); + hasUnequalMargins = NPY_FALSE; + } + + BigInt_Set_2x_uint64(&bigints[0], mantissa_hi, mantissa_lo); + return Format_floatbits(buffer, bufferSize, bigints, exponent, signbit, mantissaBit, + hasUnequalMargins, opt); +} + +PyObject * +Dragon4_Positional_QuadDType_opt(Sleef_quad *val, Dragon4_Options *opt) +{ + PyObject *ret; + if (Dragon4_PrintFloat_Sleef_quad(val, opt) < 0) { + return NULL; + } + ret = PyUnicode_FromString(_bigint_static.repr); + return ret; +} + +PyObject * +Dragon4_Positional_QuadDType(Sleef_quad *val, DigitMode digit_mode, CutoffMode cutoff_mode, + int precision, int min_digits, int sign, TrimMode trim, int pad_left, + int pad_right) +{ + Dragon4_Options opt; + + opt.scientific = 0; + opt.digit_mode = digit_mode; + opt.cutoff_mode = cutoff_mode; + opt.precision = precision; + opt.min_digits = min_digits; + opt.sign = sign; + opt.trim_mode = trim; + opt.digits_left = pad_left; + opt.digits_right = pad_right; + opt.exp_digits = -1; + + return Dragon4_Positional_QuadDType_opt(val, &opt); +} + +PyObject * +Dragon4_Scientific_QuadDType_opt(Sleef_quad *val, Dragon4_Options *opt) +{ + PyObject *ret; + if (Dragon4_PrintFloat_Sleef_quad(val, opt) < 0) { + return NULL; + } + ret = PyUnicode_FromString(_bigint_static.repr); + return ret; +} + +PyObject * +Dragon4_Scientific_QuadDType(Sleef_quad *val, DigitMode digit_mode, int precision, int min_digits, + int sign, TrimMode trim, int pad_left, int exp_digits) +{ + Dragon4_Options opt; + + opt.scientific = 1; + opt.digit_mode = digit_mode; + opt.cutoff_mode = CutoffMode_TotalLength; + opt.precision = precision; + opt.min_digits = min_digits; + opt.sign = sign; + opt.trim_mode = trim; + opt.digits_left = pad_left; + opt.digits_right = -1; + opt.exp_digits = exp_digits; + + return Dragon4_Scientific_QuadDType_opt(val, &opt); +} + +PyObject * +Dragon4_Positional(PyObject *obj, DigitMode digit_mode, CutoffMode cutoff_mode, int precision, + int min_digits, int sign, TrimMode trim, int pad_left, int pad_right) +{ + npy_double v; + + if (PyArray_IsScalar(obj, QuadPrecDType)) { + QuadPrecisionObject *quad_obj = (QuadPrecisionObject *)obj; + if (quad_obj->backend == BACKEND_SLEEF) { + return Dragon4_Positional_QuadDType(&quad_obj->value.sleef_value, digit_mode, + cutoff_mode, precision, min_digits, sign, trim, + pad_left, pad_right); + } + else { + Sleef_quad sleef_val = Sleef_cast_from_doubleq1(quad_obj->value.longdouble_value); + return Dragon4_Positional_QuadDType(&sleef_val, digit_mode, cutoff_mode, precision, + min_digits, sign, trim, pad_left, pad_right); + } + } + + return NULL; +} + +PyObject * +Dragon4_Scientific(PyObject *obj, DigitMode digit_mode, int precision, int min_digits, int sign, + TrimMode trim, int pad_left, int exp_digits) +{ + npy_double val; + + if (PyArray_IsScalar(obj, QuadPrecDType)) { + QuadPrecisionObject *quad_obj = (QuadPrecisionObject *)obj; + if (quad_obj->backend == BACKEND_SLEEF) { + return Dragon4_Scientific_QuadDType(&quad_obj->value.sleef_value, digit_mode, precision, + min_digits, sign, trim, pad_left, exp_digits); + } + else { + Sleef_quad sleef_val = Sleef_cast_from_doubleq1(quad_obj->value.longdouble_value); + return Dragon4_Scientific_QuadDType(&sleef_val, digit_mode, precision, min_digits, sign, + trim, pad_left, exp_digits); + } + } + + return NULL; +} \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/dragon4.h b/quaddtype/numpy_quaddtype/src/dragon4.h new file mode 100644 index 00000000..1977595e --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/dragon4.h @@ -0,0 +1,70 @@ +#ifndef _QUADDTYPE_DRAGON4_H +#define _QUADDTYPE_DRAGON4_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "numpy/arrayobject.h" +#include +#include "quad_common.h" + +typedef enum DigitMode +{ + /* Round digits to print shortest uniquely identifiable number. */ + DigitMode_Unique, + /* Output the digits of the number as if with infinite precision */ + DigitMode_Exact, +} DigitMode; + +typedef enum CutoffMode +{ + /* up to cutoffNumber significant digits */ + CutoffMode_TotalLength, + /* up to cutoffNumber significant digits past the decimal point */ + CutoffMode_FractionLength, +} CutoffMode; + +typedef enum TrimMode +{ + TrimMode_None, /* don't trim zeros, always leave a decimal point */ + TrimMode_LeaveOneZero, /* trim all but the zero before the decimal point */ + TrimMode_Zeros, /* trim all trailing zeros, leave decimal point */ + TrimMode_DptZeros, /* trim trailing zeros & trailing decimal point */ +} TrimMode; + +typedef struct { + int scientific; + DigitMode digit_mode; + CutoffMode cutoff_mode; + int precision; + int min_digits; + int sign; + TrimMode trim_mode; + int digits_left; + int digits_right; + int exp_digits; +} Dragon4_Options; + +PyObject *Dragon4_Positional_QuadDType(Sleef_quad *val, DigitMode digit_mode, + CutoffMode cutoff_mode, int precision, int min_digits, + int sign, TrimMode trim, int pad_left, int pad_right); + +PyObject *Dragon4_Scientific_QuadDType(Sleef_quad *val, DigitMode digit_mode, + int precision, int min_digits, int sign, TrimMode trim, + int pad_left, int exp_digits); + +PyObject *Dragon4_Positional(PyObject *obj, DigitMode digit_mode, + CutoffMode cutoff_mode, int precision, int min_digits, + int sign, TrimMode trim, int pad_left, int pad_right); + +PyObject *Dragon4_Scientific(PyObject *obj, DigitMode digit_mode, int precision, + int min_digits, int sign, TrimMode trim, int pad_left, + int exp_digits); + +#ifdef __cplusplus +} +#endif + +#endif /* _QUADDTYPE_DRAGON4_H */ \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/dtype.c b/quaddtype/numpy_quaddtype/src/dtype.c new file mode 100644 index 00000000..7d0fad37 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/dtype.c @@ -0,0 +1,266 @@ +#include +#include +#include + +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY +#define NO_IMPORT_UFUNC +#include "numpy/arrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/dtype_api.h" + +#include "scalar.h" +#include "casts.h" +#include "dtype.h" +#include "dragon4.h" + +static inline int +quad_load(void *x, char *data_ptr, QuadBackendType backend) +{ + if (data_ptr == NULL || x == NULL) { + return -1; + } + if (backend == BACKEND_SLEEF) { + *(Sleef_quad *)x = *(Sleef_quad *)data_ptr; + } + else { + *(long double *)x = *(long double *)data_ptr; + } + return 0; +} + +static inline int +quad_store(char *data_ptr, void *x, QuadBackendType backend) +{ + if (data_ptr == NULL || x == NULL) { + return -1; + } + if (backend == BACKEND_SLEEF) { + *(Sleef_quad *)data_ptr = *(Sleef_quad *)x; + } + else { + *(long double *)data_ptr = *(long double *)x; + } + return 0; +} + +QuadPrecDTypeObject * +new_quaddtype_instance(QuadBackendType backend) +{ + QuadBackendType target_backend = backend; + if (backend != BACKEND_SLEEF && backend != BACKEND_LONGDOUBLE) { + PyErr_SetString(PyExc_TypeError, "Backend must be sleef or longdouble"); + return NULL; + // target_backend = BACKEND_SLEEF; + } + + QuadPrecDTypeObject *new = (QuadPrecDTypeObject *)PyArrayDescr_Type.tp_new( + (PyTypeObject *)&QuadPrecDType, NULL, NULL); + if (new == NULL) { + return NULL; + } + new->base.elsize = (target_backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + new->base.alignment = + (target_backend == BACKEND_SLEEF) ? _Alignof(Sleef_quad) : _Alignof(long double); + new->backend = target_backend; + return new; +} + +static QuadPrecDTypeObject * +ensure_canonical(QuadPrecDTypeObject *self) +{ + Py_INCREF(self); + return self; +} + +static QuadPrecDTypeObject * +common_instance(QuadPrecDTypeObject *dtype1, QuadPrecDTypeObject *dtype2) +{ + // if backend mismatch then return SLEEF one (safe to cast ld to quad) + if (dtype1->backend != dtype2->backend) { + if (dtype1->backend == BACKEND_SLEEF) { + Py_INCREF(dtype1); + return dtype1; + } + + Py_INCREF(dtype2); + return dtype2; + } + Py_INCREF(dtype1); + return dtype1; +} + +static PyArray_DTypeMeta * +common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other) +{ + // Promote integer and floating-point types to QuadPrecDType + if (other->type_num >= 0 && + (PyTypeNum_ISINTEGER(other->type_num) || PyTypeNum_ISFLOAT(other->type_num))) { + Py_INCREF(cls); + return cls; + } + // Don't promote complex types + if (PyTypeNum_ISCOMPLEX(other->type_num)) { + Py_INCREF(Py_NotImplemented); + return (PyArray_DTypeMeta *)Py_NotImplemented; + } + + Py_INCREF(Py_NotImplemented); + return (PyArray_DTypeMeta *)Py_NotImplemented; +} + +static PyArray_Descr * +quadprec_discover_descriptor_from_pyobject(PyArray_DTypeMeta *NPY_UNUSED(cls), PyObject *obj) +{ + if (Py_TYPE(obj) != &QuadPrecision_Type) { + PyErr_SetString(PyExc_TypeError, "Can only store QuadPrecision in a QuadPrecDType array."); + return NULL; + } + + QuadPrecisionObject *quad_obj = (QuadPrecisionObject *)obj; + + return (PyArray_Descr *)new_quaddtype_instance(quad_obj->backend); +} + +static int +quadprec_setitem(QuadPrecDTypeObject *descr, PyObject *obj, char *dataptr) +{ + QuadPrecisionObject *value; + if (PyObject_TypeCheck(obj, &QuadPrecision_Type)) { + Py_INCREF(obj); + value = (QuadPrecisionObject *)obj; + } + else { + value = QuadPrecision_from_object(obj, descr->backend); + if (value == NULL) { + return -1; + } + } + + if (quad_store(dataptr, &value->value, descr->backend) < 0) { + Py_DECREF(value); + char error_msg[100]; + snprintf(error_msg, sizeof(error_msg), "Invalid memory location %p", (void *)dataptr); + PyErr_SetString(PyExc_ValueError, error_msg); + return -1; + } + + Py_DECREF(value); + return 0; +} + +static PyObject * +quadprec_getitem(QuadPrecDTypeObject *descr, char *dataptr) +{ + QuadPrecisionObject *new = QuadPrecision_raw_new(descr->backend); + if (!new) { + return NULL; + } + if (quad_load(&new->value, dataptr, descr->backend) < 0) { + Py_DECREF(new); + char error_msg[100]; + snprintf(error_msg, sizeof(error_msg), "Invalid memory location %p", (void *)dataptr); + PyErr_SetString(PyExc_ValueError, error_msg); + return NULL; + } + return (PyObject *)new; +} + +static PyArray_Descr * +quadprec_default_descr(PyArray_DTypeMeta *cls) +{ + QuadPrecDTypeObject *temp = new_quaddtype_instance(BACKEND_SLEEF); + return (PyArray_Descr *)temp; +} + +static PyType_Slot QuadPrecDType_Slots[] = { + {NPY_DT_ensure_canonical, &ensure_canonical}, + {NPY_DT_common_instance, &common_instance}, + {NPY_DT_common_dtype, &common_dtype}, + {NPY_DT_discover_descr_from_pyobject, &quadprec_discover_descriptor_from_pyobject}, + {NPY_DT_setitem, &quadprec_setitem}, + {NPY_DT_getitem, &quadprec_getitem}, + {NPY_DT_default_descr, &quadprec_default_descr}, + {NPY_DT_PyArray_ArrFuncs_dotfunc, NULL}, + {0, NULL}}; + +static PyObject * +QuadPrecDType_new(PyTypeObject *NPY_UNUSED(cls), PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"backend", NULL}; + const char *backend_str = "sleef"; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist, &backend_str)) { + return NULL; + } + + QuadBackendType backend = BACKEND_SLEEF; + if (strcmp(backend_str, "longdouble") == 0) { + backend = BACKEND_LONGDOUBLE; + } + else if (strcmp(backend_str, "sleef") != 0) { + PyErr_SetString(PyExc_ValueError, "Invalid backend. Use 'sleef' or 'longdouble'."); + return NULL; + } + + return (PyObject *)quadprec_discover_descriptor_from_pyobject( + &QuadPrecDType, (PyObject *)QuadPrecision_raw_new(backend)); +} + +static PyObject * +QuadPrecDType_repr(QuadPrecDTypeObject *self) +{ + const char *backend_str = (self->backend == BACKEND_SLEEF) ? "sleef" : "longdouble"; + return PyUnicode_FromFormat("QuadPrecDType(backend='%s')", backend_str); +} + +static PyObject * +QuadPrecDType_str(QuadPrecDTypeObject *self) +{ + const char *backend_str = (self->backend == BACKEND_SLEEF) ? "sleef" : "longdouble"; + return PyUnicode_FromFormat("QuadPrecDType(backend='%s')", backend_str); +} + +PyArray_DTypeMeta QuadPrecDType = { + {{ + PyVarObject_HEAD_INIT(NULL, 0).tp_name = "numpy_quaddtype.QuadPrecDType", + .tp_basicsize = sizeof(QuadPrecDTypeObject), + .tp_new = QuadPrecDType_new, + .tp_repr = (reprfunc)QuadPrecDType_repr, + .tp_str = (reprfunc)QuadPrecDType_str, + }}, +}; + +int +init_quadprec_dtype(void) +{ + PyArrayMethod_Spec **casts = init_casts(); + if (!casts) + return -1; + + PyArrayDTypeMeta_Spec QuadPrecDType_DTypeSpec = { + .flags = NPY_DT_PARAMETRIC | NPY_DT_NUMERIC, + .casts = casts, + .typeobj = &QuadPrecision_Type, + .slots = QuadPrecDType_Slots, + }; + + ((PyObject *)&QuadPrecDType)->ob_type = &PyArrayDTypeMeta_Type; + + ((PyTypeObject *)&QuadPrecDType)->tp_base = &PyArrayDescr_Type; + + if (PyType_Ready((PyTypeObject *)&QuadPrecDType) < 0) { + return -1; + } + + if (PyArrayInitDTypeMeta_FromSpec(&QuadPrecDType, &QuadPrecDType_DTypeSpec) < 0) { + return -1; + } + + free_casts(); + + return 0; +} \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/dtype.h b/quaddtype/numpy_quaddtype/src/dtype.h new file mode 100644 index 00000000..77a65449 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/dtype.h @@ -0,0 +1,30 @@ +#ifndef _QUADDTYPE_DTYPE_H +#define _QUADDTYPE_DTYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "quad_common.h" + +typedef struct { + PyArray_Descr base; + QuadBackendType backend; +} QuadPrecDTypeObject; + +extern PyArray_DTypeMeta QuadPrecDType; + +QuadPrecDTypeObject * +new_quaddtype_instance(QuadBackendType backend); + +int +init_quadprec_dtype(void); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/ops.hpp b/quaddtype/numpy_quaddtype/src/ops.hpp new file mode 100644 index 00000000..b32ae386 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/ops.hpp @@ -0,0 +1,453 @@ +#include +#include +#include + +// Unary Quad Operations +typedef Sleef_quad (*unary_op_quad_def)(Sleef_quad *); + +static Sleef_quad +quad_negative(Sleef_quad *op) +{ + return Sleef_negq1(*op); +} + +static Sleef_quad +quad_positive(Sleef_quad *op) +{ + return *op; +} + +static inline Sleef_quad +quad_absolute(Sleef_quad *op) +{ + return Sleef_fabsq1(*op); +} + +static inline Sleef_quad +quad_rint(Sleef_quad *op) +{ + return Sleef_rintq1(*op); +} + +static inline Sleef_quad +quad_trunc(Sleef_quad *op) +{ + return Sleef_truncq1(*op); +} + +static inline Sleef_quad +quad_floor(Sleef_quad *op) +{ + return Sleef_floorq1(*op); +} + +static inline Sleef_quad +quad_ceil(Sleef_quad *op) +{ + return Sleef_ceilq1(*op); +} + +static inline Sleef_quad +quad_sqrt(Sleef_quad *op) +{ + return Sleef_sqrtq1_u05(*op); +} + +static inline Sleef_quad +quad_square(Sleef_quad *op) +{ + return Sleef_mulq1_u05(*op, *op); +} + +static inline Sleef_quad +quad_log(Sleef_quad *op) +{ + return Sleef_logq1_u10(*op); +} + +static inline Sleef_quad +quad_log2(Sleef_quad *op) +{ + return Sleef_log2q1_u10(*op); +} + +static inline Sleef_quad +quad_log10(Sleef_quad *op) +{ + return Sleef_log10q1_u10(*op); +} + +static inline Sleef_quad +quad_log1p(Sleef_quad *op) +{ + return Sleef_log1pq1_u10(*op); +} + +static inline Sleef_quad +quad_exp(Sleef_quad *op) +{ + return Sleef_expq1_u10(*op); +} + +static inline Sleef_quad +quad_exp2(Sleef_quad *op) +{ + return Sleef_exp2q1_u10(*op); +} + +static inline Sleef_quad +quad_sin(Sleef_quad *op) +{ + return Sleef_sinq1_u10(*op); +} + +static inline Sleef_quad +quad_cos(Sleef_quad *op) +{ + return Sleef_cosq1_u10(*op); +} + +static inline Sleef_quad +quad_tan(Sleef_quad *op) +{ + return Sleef_tanq1_u10(*op); +} + +static inline Sleef_quad +quad_asin(Sleef_quad *op) +{ + return Sleef_asinq1_u10(*op); +} + +static inline Sleef_quad +quad_acos(Sleef_quad *op) +{ + return Sleef_acosq1_u10(*op); +} + +static inline Sleef_quad +quad_atan(Sleef_quad *op) +{ + return Sleef_atanq1_u10(*op); +} + +// Unary long double operations +typedef long double (*unary_op_longdouble_def)(long double *); + +static inline long double +ld_negative(long double *op) +{ + return -(*op); +} + +static inline long double +ld_positive(long double *op) +{ + return *op; +} + +static inline long double +ld_absolute(long double *op) +{ + return fabsl(*op); +} + +static inline long double +ld_rint(long double *op) +{ + return rintl(*op); +} + +static inline long double +ld_trunc(long double *op) +{ + return truncl(*op); +} + +static inline long double +ld_floor(long double *op) +{ + return floorl(*op); +} + +static inline long double +ld_ceil(long double *op) +{ + return ceill(*op); +} + +static inline long double +ld_sqrt(long double *op) +{ + return sqrtl(*op); +} + +static inline long double +ld_square(long double *op) +{ + return (*op) * (*op); +} + +static inline long double +ld_log(long double *op) +{ + return logl(*op); +} + +static inline long double +ld_log2(long double *op) +{ + return log2l(*op); +} + +static inline long double +ld_log10(long double *op) +{ + return log10l(*op); +} + +static inline long double +ld_log1p(long double *op) +{ + return log1pl(*op); +} + +static inline long double +ld_exp(long double *op) +{ + return expl(*op); +} + +static inline long double +ld_exp2(long double *op) +{ + return exp2l(*op); +} + +static inline long double +ld_sin(long double *op) +{ + return sinl(*op); +} + +static inline long double +ld_cos(long double *op) +{ + return cosl(*op); +} + +static inline long double +ld_tan(long double *op) +{ + return tanl(*op); +} + +static inline long double +ld_asin(long double *op) +{ + return asinl(*op); +} + +static inline long double +ld_acos(long double *op) +{ + return acosl(*op); +} + +static inline long double +ld_atan(long double *op) +{ + return atanl(*op); +} + +// Binary Quad operations +typedef Sleef_quad (*binary_op_quad_def)(Sleef_quad *, Sleef_quad *); + +static inline Sleef_quad +quad_add(Sleef_quad *in1, Sleef_quad *in2) +{ + return Sleef_addq1_u05(*in1, *in2); +} + +static inline Sleef_quad +quad_sub(Sleef_quad *in1, Sleef_quad *in2) +{ + return Sleef_subq1_u05(*in1, *in2); +} + +static inline Sleef_quad +quad_mul(Sleef_quad *a, Sleef_quad *b) +{ + return Sleef_mulq1_u05(*a, *b); +} + +static inline Sleef_quad +quad_div(Sleef_quad *a, Sleef_quad *b) +{ + return Sleef_divq1_u05(*a, *b); +} + +static inline Sleef_quad +quad_pow(Sleef_quad *a, Sleef_quad *b) +{ + return Sleef_powq1_u10(*a, *b); +} + +static inline Sleef_quad +quad_mod(Sleef_quad *a, Sleef_quad *b) +{ + return Sleef_fmodq1(*a, *b); +} + +static inline Sleef_quad +quad_minimum(Sleef_quad *in1, Sleef_quad *in2) +{ + return Sleef_icmpleq1(*in1, *in2) ? *in1 : *in2; +} + +static inline Sleef_quad +quad_maximum(Sleef_quad *in1, Sleef_quad *in2) +{ + return Sleef_icmpgeq1(*in1, *in2) ? *in1 : *in2; +} + +static inline Sleef_quad +quad_atan2(Sleef_quad *in1, Sleef_quad *in2) +{ + return Sleef_atan2q1_u10(*in1, *in2); +} + +// Binary long double operations +typedef long double (*binary_op_longdouble_def)(long double *, long double *); + +static inline long double +ld_add(long double *in1, long double *in2) +{ + return (*in1) + (*in2); +} + +static inline long double +ld_sub(long double *in1, long double *in2) +{ + return (*in1) - (*in2); +} + +static inline long double +ld_mul(long double *a, long double *b) +{ + return (*a) * (*b); +} + +static inline long double +ld_div(long double *a, long double *b) +{ + return (*a) / (*b); +} + +static inline long double +ld_pow(long double *a, long double *b) +{ + return powl(*a, *b); +} + +static inline long double +ld_mod(long double *a, long double *b) +{ + return fmodl(*a, *b); +} + +static inline long double +ld_minimum(long double *in1, long double *in2) +{ + return (*in1 < *in2) ? *in1 : *in2; +} + +static inline long double +ld_maximum(long double *in1, long double *in2) +{ + return (*in1 > *in2) ? *in1 : *in2; +} + +static inline long double +ld_atan2(long double *in1, long double *in2) +{ + return atan2l(*in1, *in2); +} + +// comparison quad functions +typedef npy_bool (*cmp_quad_def)(const Sleef_quad *, const Sleef_quad *); + +static inline npy_bool +quad_equal(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpeqq1(*a, *b); +} + +static inline npy_bool +quad_notequal(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpneq1(*a, *b); +} + +static inline npy_bool +quad_less(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpltq1(*a, *b); +} + +static inline npy_bool +quad_lessequal(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpleq1(*a, *b); +} + +static inline npy_bool +quad_greater(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpgtq1(*a, *b); +} + +static inline npy_bool +quad_greaterequal(const Sleef_quad *a, const Sleef_quad *b) +{ + return Sleef_icmpgeq1(*a, *b); +} + +// comparison quad functions +typedef npy_bool (*cmp_londouble_def)(const long double *, const long double *); + +static inline npy_bool +ld_equal(const long double *a, const long double *b) +{ + return *a == *b; +} + +static inline npy_bool +ld_notequal(const long double *a, const long double *b) +{ + return *a != *b; +} + +static inline npy_bool +ld_less(const long double *a, const long double *b) +{ + return *a < *b; +} + +static inline npy_bool +ld_lessequal(const long double *a, const long double *b) +{ + return *a <= *b; +} + +static inline npy_bool +ld_greater(const long double *a, const long double *b) +{ + return *a > *b; +} + +static inline npy_bool +ld_greaterequal(const long double *a, const long double *b) +{ + return *a >= *b; +} \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/quad_common.h b/quaddtype/numpy_quaddtype/src/quad_common.h new file mode 100644 index 00000000..bc578a29 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/quad_common.h @@ -0,0 +1,18 @@ +#ifndef _QUADDTYPE_COMMON_H +#define _QUADDTYPE_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BACKEND_INVALID = -1, + BACKEND_SLEEF, + BACKEND_LONGDOUBLE +} QuadBackendType; + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/quaddtype_main.c b/quaddtype/numpy_quaddtype/src/quaddtype_main.c new file mode 100644 index 00000000..f2935299 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/quaddtype_main.c @@ -0,0 +1,116 @@ +#include +#include +#include +#include + +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION + +#include "numpy/arrayobject.h" +#include "numpy/dtype_api.h" +#include "numpy/ufuncobject.h" + +#include "scalar.h" +#include "dtype.h" +#include "umath.h" +#include "quad_common.h" +#include "float.h" + + +static PyObject* py_is_longdouble_128(PyObject* self, PyObject* args) { + if(sizeof(long double) == 16 && + LDBL_MANT_DIG == 113 && + LDBL_MAX_EXP == 16384) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +} + +static PyObject* get_sleef_constant(PyObject* self, PyObject* args) { + const char* constant_name; + if (!PyArg_ParseTuple(args, "s", &constant_name)) { + return NULL; + } + + QuadPrecisionObject* result = QuadPrecision_raw_new(BACKEND_SLEEF); + if (result == NULL) { + return NULL; + } + + if (strcmp(constant_name, "pi") == 0) { + result->value.sleef_value = SLEEF_M_PIq; + } else if (strcmp(constant_name, "e") == 0) { + result->value.sleef_value = SLEEF_M_Eq; + } else if (strcmp(constant_name, "log2e") == 0) { + result->value.sleef_value = SLEEF_M_LOG2Eq; + } else if (strcmp(constant_name, "log10e") == 0) { + result->value.sleef_value = SLEEF_M_LOG10Eq; + } else if (strcmp(constant_name, "ln2") == 0) { + result->value.sleef_value = SLEEF_M_LN2q; + } else if (strcmp(constant_name, "ln10") == 0) { + result->value.sleef_value = SLEEF_M_LN10q; + } else if (strcmp(constant_name, "quad_max") == 0) { + result->value.sleef_value = SLEEF_QUAD_MAX; + } else if (strcmp(constant_name, "quad_min") == 0) { + result->value.sleef_value = SLEEF_QUAD_MIN; + } else if (strcmp(constant_name, "epsilon") == 0) { + result->value.sleef_value = SLEEF_QUAD_EPSILON; + } + else { + PyErr_SetString(PyExc_ValueError, "Unknown constant name"); + Py_DECREF(result); + return NULL; + } + + return (PyObject*)result; +} + +static PyMethodDef module_methods[] = { + {"is_longdouble_128", py_is_longdouble_128, METH_NOARGS, "Check if long double is 128-bit"}, + {"get_sleef_constant", get_sleef_constant, METH_VARARGS, "Get Sleef constant by name"}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + .m_name = "_quaddtype_main", + .m_doc = "Quad (128-bit) floating point Data Type for NumPy with multiple backends", + .m_size = -1, + .m_methods = module_methods +}; + +PyMODINIT_FUNC +PyInit__quaddtype_main(void) +{ + import_array(); + import_umath(); + PyObject *m = PyModule_Create(&moduledef); + if (!m) { + return NULL; + } + + if (init_quadprecision_scalar() < 0) + goto error; + + if (PyModule_AddObject(m, "QuadPrecision", (PyObject *)&QuadPrecision_Type) < 0) + goto error; + + if (init_quadprec_dtype() < 0) + goto error; + + if (PyModule_AddObject(m, "QuadPrecDType", (PyObject *)&QuadPrecDType) < 0) + goto error; + + if (init_quad_umath() < 0) { + goto error; + } + + return m; + +error: + Py_XDECREF(m); + return NULL; +} \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/scalar.c b/quaddtype/numpy_quaddtype/src/scalar.c new file mode 100644 index 00000000..9bec08a6 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/scalar.c @@ -0,0 +1,254 @@ +#include +#include +#include +#include + +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY + +#include "numpy/arrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/dtype_api.h" + +#include "scalar.h" +#include "scalar_ops.h" +#include "dragon4.h" + +QuadPrecisionObject * +QuadPrecision_raw_new(QuadBackendType backend) +{ + QuadPrecisionObject *new = PyObject_New(QuadPrecisionObject, &QuadPrecision_Type); + if (!new) + return NULL; + new->backend = backend; + if (backend == BACKEND_SLEEF) { + new->value.sleef_value = Sleef_cast_from_doubleq1(0.0); + } + else { + new->value.longdouble_value = 0.0L; + } + return new; +} + +QuadPrecisionObject * +QuadPrecision_from_object(PyObject *value, QuadBackendType backend) +{ + QuadPrecisionObject *self = QuadPrecision_raw_new(backend); + if (!self) + return NULL; + + if (PyFloat_Check(value)) { + double dval = PyFloat_AsDouble(value); + if (backend == BACKEND_SLEEF) { + self->value.sleef_value = Sleef_cast_from_doubleq1(dval); + } + else { + self->value.longdouble_value = (long double)dval; + } + } + else if (PyUnicode_CheckExact(value)) { + const char *s = PyUnicode_AsUTF8(value); + char *endptr = NULL; + if (backend == BACKEND_SLEEF) { + self->value.sleef_value = Sleef_strtoq(s, &endptr); + } + else { + self->value.longdouble_value = strtold(s, &endptr); + } + if (*endptr != '\0' || endptr == s) { + PyErr_SetString(PyExc_ValueError, "Unable to parse string to QuadPrecision"); + Py_DECREF(self); + return NULL; + } + } + else if (PyLong_Check(value)) { + long long val = PyLong_AsLongLong(value); + if (val == -1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_OverflowError, "Overflow Error, value out of range"); + Py_DECREF(self); + return NULL; + } + if (backend == BACKEND_SLEEF) { + self->value.sleef_value = Sleef_cast_from_int64q1(val); + } + else { + self->value.longdouble_value = (long double)val; + } + } + else if (Py_TYPE(value) == &QuadPrecision_Type) { + Py_DECREF(self); // discard the default one + QuadPrecisionObject *quad_obj = (QuadPrecisionObject *)value; + // create a new one with the same backend + QuadPrecisionObject *self = QuadPrecision_raw_new(quad_obj->backend); + if (quad_obj->backend == BACKEND_SLEEF) { + self->value.sleef_value = quad_obj->value.sleef_value; + } + else { + self->value.longdouble_value = quad_obj->value.longdouble_value; + } + + return self; + } + else { + PyObject *type_str = PyObject_Str((PyObject *)Py_TYPE(value)); + if (type_str != NULL) { + const char *type_cstr = PyUnicode_AsUTF8(type_str); + if (type_cstr != NULL) { + PyErr_Format(PyExc_TypeError, + "QuadPrecision value must be a quad, float, int or string, but got %s " + "instead", + type_cstr); + } + else { + PyErr_SetString( + PyExc_TypeError, + "QuadPrecision value must be a quad, float, int or string, but got an " + "unknown type instead"); + } + Py_DECREF(type_str); + } + else { + PyErr_SetString(PyExc_TypeError, + "QuadPrecision value must be a quad, float, int or string, but got an " + "unknown type instead"); + } + Py_DECREF(self); + return NULL; + } + + return self; +} + +static PyObject * +QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) +{ + PyObject *value; + const char *backend_str = "sleef"; + static char *kwlist[] = {"value", "backend", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|s", kwlist, &value, &backend_str)) { + return NULL; + } + + QuadBackendType backend = BACKEND_SLEEF; + if (strcmp(backend_str, "longdouble") == 0) { + backend = BACKEND_LONGDOUBLE; + } + else if (strcmp(backend_str, "sleef") != 0) { + PyErr_SetString(PyExc_ValueError, "Invalid backend. Use 'sleef' or 'longdouble'."); + return NULL; + } + + return (PyObject *)QuadPrecision_from_object(value, backend); +} + +static PyObject * +QuadPrecision_str_dragon4(QuadPrecisionObject *self) +{ + Dragon4_Options opt = {.scientific = 0, + .digit_mode = DigitMode_Unique, + .cutoff_mode = CutoffMode_TotalLength, + .precision = SLEEF_QUAD_DIG, + .sign = 1, + .trim_mode = TrimMode_LeaveOneZero, + .digits_left = 1, + .digits_right = SLEEF_QUAD_DIG}; + + if (self->backend == BACKEND_SLEEF) { + return Dragon4_Positional_QuadDType( + &self->value.sleef_value, opt.digit_mode, opt.cutoff_mode, opt.precision, + opt.min_digits, opt.sign, opt.trim_mode, opt.digits_left, opt.digits_right); + } + else { + Sleef_quad sleef_val = Sleef_cast_from_doubleq1(self->value.longdouble_value); + return Dragon4_Positional_QuadDType(&sleef_val, opt.digit_mode, opt.cutoff_mode, + opt.precision, opt.min_digits, opt.sign, opt.trim_mode, + opt.digits_left, opt.digits_right); + } +} + +static PyObject * +QuadPrecision_str(QuadPrecisionObject *self) +{ + char buffer[128]; + if (self->backend == BACKEND_SLEEF) { + Sleef_snprintf(buffer, sizeof(buffer), "%.*Qe", SLEEF_QUAD_DIG, self->value.sleef_value); + } + else { + snprintf(buffer, sizeof(buffer), "%.35Le", self->value.longdouble_value); + } + return PyUnicode_FromString(buffer); +} + +static PyObject * +QuadPrecision_repr(QuadPrecisionObject *self) +{ + PyObject *str = QuadPrecision_str(self); + if (str == NULL) { + return NULL; + } + const char *backend_str = (self->backend == BACKEND_SLEEF) ? "sleef" : "longdouble"; + PyObject *res = PyUnicode_FromFormat("QuadPrecision('%S', backend='%s')", str, backend_str); + Py_DECREF(str); + return res; +} + +static PyObject * +QuadPrecision_repr_dragon4(QuadPrecisionObject *self) +{ + Dragon4_Options opt = {.scientific = 1, + .digit_mode = DigitMode_Unique, + .cutoff_mode = CutoffMode_TotalLength, + .precision = SLEEF_QUAD_DIG, + .sign = 1, + .trim_mode = TrimMode_LeaveOneZero, + .digits_left = 1, + .exp_digits = 3}; + + PyObject *str; + if (self->backend == BACKEND_SLEEF) { + str = Dragon4_Scientific_QuadDType(&self->value.sleef_value, opt.digit_mode, opt.precision, + opt.min_digits, opt.sign, opt.trim_mode, opt.digits_left, + opt.exp_digits); + } + else { + Sleef_quad sleef_val = Sleef_cast_from_doubleq1(self->value.longdouble_value); + str = Dragon4_Scientific_QuadDType(&sleef_val, opt.digit_mode, opt.precision, + opt.min_digits, opt.sign, opt.trim_mode, opt.digits_left, + opt.exp_digits); + } + + if (str == NULL) { + return NULL; + } + + const char *backend_str = (self->backend == BACKEND_SLEEF) ? "sleef" : "longdouble"; + PyObject *res = PyUnicode_FromFormat("QuadPrecision('%S', backend='%s')", str, backend_str); + Py_DECREF(str); + return res; +} + +static void +QuadPrecision_dealloc(QuadPrecisionObject *self) +{ + Py_TYPE(self)->tp_free((PyObject *)self); +} + +PyTypeObject QuadPrecision_Type = { + PyVarObject_HEAD_INIT(NULL, 0).tp_name = "numpy_quaddtype.QuadPrecision", + .tp_basicsize = sizeof(QuadPrecisionObject), + .tp_itemsize = 0, + .tp_new = QuadPrecision_new, + .tp_dealloc = (destructor)QuadPrecision_dealloc, + .tp_repr = (reprfunc)QuadPrecision_repr_dragon4, + .tp_str = (reprfunc)QuadPrecision_str_dragon4, + .tp_as_number = &quad_as_scalar, + .tp_richcompare = (richcmpfunc)quad_richcompare, +}; + +int +init_quadprecision_scalar(void) +{ + return PyType_Ready(&QuadPrecision_Type); +} \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/scalar.h b/quaddtype/numpy_quaddtype/src/scalar.h new file mode 100644 index 00000000..4fac1adf --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/scalar.h @@ -0,0 +1,41 @@ +#ifndef _QUADDTYPE_SCALAR_H +#define _QUADDTYPE_SCALAR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "quad_common.h" + +typedef union { + Sleef_quad sleef_value; + long double longdouble_value; +} quad_value; + +typedef struct { + PyObject_HEAD + quad_value value; + QuadBackendType backend; +} QuadPrecisionObject; + +extern PyTypeObject QuadPrecision_Type; + +QuadPrecisionObject * +QuadPrecision_raw_new(QuadBackendType backend); + +QuadPrecisionObject * +QuadPrecision_from_object(PyObject *value, QuadBackendType backend); + +int +init_quadprecision_scalar(void); + +#define PyArray_IsScalar(obj, QuadPrecDType) PyObject_TypeCheck(obj, &QuadPrecision_Type) +#define PyArrayScalar_VAL(obj, QuadPrecDType) (((QuadPrecisionObject *)obj)->value) + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/quaddtype/numpy_quaddtype/src/scalar_ops.cpp b/quaddtype/numpy_quaddtype/src/scalar_ops.cpp new file mode 100644 index 00000000..5888ad60 --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/scalar_ops.cpp @@ -0,0 +1,243 @@ +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY + +extern "C" { +#include + +#include "numpy/arrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/ufuncobject.h" + +#include "numpy/dtype_api.h" +} + +#include "scalar.h" +#include "ops.hpp" +#include "scalar_ops.h" +#include "quad_common.h" + +template +static PyObject * +quad_unary_func(QuadPrecisionObject *self) +{ + QuadPrecisionObject *res = QuadPrecision_raw_new(self->backend); + if (!res) { + return NULL; + } + + if (self->backend == BACKEND_SLEEF) { + res->value.sleef_value = sleef_op(&self->value.sleef_value); + } + else { + res->value.longdouble_value = longdouble_op(&self->value.longdouble_value); + } + return (PyObject *)res; +} + +PyObject * +quad_nonzero(QuadPrecisionObject *self) +{ + if (self->backend == BACKEND_SLEEF) { + return PyBool_FromLong(Sleef_icmpneq1(self->value.sleef_value, Sleef_cast_from_int64q1(0))); + } + else { + return PyBool_FromLong(self->value.longdouble_value != 0.0L); + } +} + +template +static PyObject * +quad_binary_func(PyObject *op1, PyObject *op2) +{ + QuadPrecisionObject *self; + PyObject *other; + QuadPrecisionObject *other_quad = NULL; + int is_forward; + QuadBackendType backend; + + if (PyObject_TypeCheck(op1, &QuadPrecision_Type)) { + is_forward = 1; + self = (QuadPrecisionObject *)op1; + other = Py_NewRef(op2); + backend = self->backend; + } + else { + is_forward = 0; + self = (QuadPrecisionObject *)op2; + other = Py_NewRef(op1); + backend = self->backend; + } + + if (PyObject_TypeCheck(other, &QuadPrecision_Type)) { + Py_INCREF(other); + other_quad = (QuadPrecisionObject *)other; + if (other_quad->backend != backend) { + PyErr_SetString(PyExc_TypeError, "Cannot mix QuadPrecision backends"); + Py_DECREF(other); + return NULL; + } + } + else if (PyLong_Check(other) || PyFloat_Check(other)) { + other_quad = QuadPrecision_from_object(other, backend); + if (!other_quad) { + Py_DECREF(other); + return NULL; + } + } + else { + Py_DECREF(other); + Py_RETURN_NOTIMPLEMENTED; + } + + QuadPrecisionObject *res = QuadPrecision_raw_new(backend); + if (!res) { + Py_DECREF(other_quad); + Py_DECREF(other); + return NULL; + } + + if (backend == BACKEND_SLEEF) { + if (is_forward) { + res->value.sleef_value = + sleef_op(&self->value.sleef_value, &other_quad->value.sleef_value); + } + else { + res->value.sleef_value = + sleef_op(&other_quad->value.sleef_value, &self->value.sleef_value); + } + } + else { + if (is_forward) { + res->value.longdouble_value = longdouble_op(&self->value.longdouble_value, + &other_quad->value.longdouble_value); + } + else { + res->value.longdouble_value = longdouble_op(&other_quad->value.longdouble_value, + &self->value.longdouble_value); + } + } + + Py_DECREF(other_quad); + Py_DECREF(other); + return (PyObject *)res; +} + +PyObject * +quad_richcompare(QuadPrecisionObject *self, PyObject *other, int cmp_op) +{ + QuadPrecisionObject *other_quad = NULL; + QuadBackendType backend = self->backend; + + if (PyObject_TypeCheck(other, &QuadPrecision_Type)) { + Py_INCREF(other); + other_quad = (QuadPrecisionObject *)other; + if (other_quad->backend != backend) { + PyErr_SetString(PyExc_TypeError, + "Cannot compare QuadPrecision objects with different backends"); + Py_DECREF(other_quad); + return NULL; + } + } + else if (PyLong_CheckExact(other) || PyFloat_CheckExact(other)) { + other_quad = QuadPrecision_from_object(other, backend); + if (other_quad == NULL) { + return NULL; + } + } + else { + Py_RETURN_NOTIMPLEMENTED; + } + + int cmp; + if (backend == BACKEND_SLEEF) { + switch (cmp_op) { + case Py_LT: + cmp = Sleef_icmpltq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + case Py_LE: + cmp = Sleef_icmpleq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + case Py_EQ: + cmp = Sleef_icmpeqq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + case Py_NE: + cmp = Sleef_icmpneq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + case Py_GT: + cmp = Sleef_icmpgtq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + case Py_GE: + cmp = Sleef_icmpgeq1(self->value.sleef_value, other_quad->value.sleef_value); + break; + default: + Py_DECREF(other_quad); + Py_RETURN_NOTIMPLEMENTED; + } + } + else { + switch (cmp_op) { + case Py_LT: + cmp = self->value.longdouble_value < other_quad->value.longdouble_value; + break; + case Py_LE: + cmp = self->value.longdouble_value <= other_quad->value.longdouble_value; + break; + case Py_EQ: + cmp = self->value.longdouble_value == other_quad->value.longdouble_value; + break; + case Py_NE: + cmp = self->value.longdouble_value != other_quad->value.longdouble_value; + break; + case Py_GT: + cmp = self->value.longdouble_value > other_quad->value.longdouble_value; + break; + case Py_GE: + cmp = self->value.longdouble_value >= other_quad->value.longdouble_value; + break; + default: + Py_DECREF(other_quad); + Py_RETURN_NOTIMPLEMENTED; + } + } + Py_DECREF(other_quad); + + return PyBool_FromLong(cmp); +} + +static PyObject * +QuadPrecision_float(QuadPrecisionObject *self) +{ + if (self->backend == BACKEND_SLEEF) { + return PyFloat_FromDouble(Sleef_cast_to_doubleq1(self->value.sleef_value)); + } + else { + return PyFloat_FromDouble((double)self->value.longdouble_value); + } +} + +static PyObject * +QuadPrecision_int(QuadPrecisionObject *self) +{ + if (self->backend == BACKEND_SLEEF) { + return PyLong_FromLongLong(Sleef_cast_to_int64q1(self->value.sleef_value)); + } + else { + return PyLong_FromLongLong((long long)self->value.longdouble_value); + } +} + +PyNumberMethods quad_as_scalar = { + .nb_add = (binaryfunc)quad_binary_func, + .nb_subtract = (binaryfunc)quad_binary_func, + .nb_multiply = (binaryfunc)quad_binary_func, + .nb_power = (ternaryfunc)quad_binary_func, + .nb_negative = (unaryfunc)quad_unary_func, + .nb_positive = (unaryfunc)quad_unary_func, + .nb_absolute = (unaryfunc)quad_unary_func, + .nb_bool = (inquiry)quad_nonzero, + .nb_int = (unaryfunc)QuadPrecision_int, + .nb_float = (unaryfunc)QuadPrecision_float, + .nb_true_divide = (binaryfunc)quad_binary_func, +}; \ No newline at end of file diff --git a/quaddtype/quaddtype/src/scalar_ops.h b/quaddtype/numpy_quaddtype/src/scalar_ops.h similarity index 100% rename from quaddtype/quaddtype/src/scalar_ops.h rename to quaddtype/numpy_quaddtype/src/scalar_ops.h diff --git a/quaddtype/numpy_quaddtype/src/umath.cpp b/quaddtype/numpy_quaddtype/src/umath.cpp new file mode 100644 index 00000000..0058236a --- /dev/null +++ b/quaddtype/numpy_quaddtype/src/umath.cpp @@ -0,0 +1,806 @@ +#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API +#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API +#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION +#define NPY_TARGET_VERSION NPY_2_0_API_VERSION +#define NO_IMPORT_ARRAY +#define NO_IMPORT_UFUNC + +extern "C" { +#include +#include + +#include "numpy/arrayobject.h" +#include "numpy/ndarraytypes.h" +#include "numpy/ufuncobject.h" + +#include "numpy/dtype_api.h" +} +#include "quad_common.h" +#include "scalar.h" +#include "dtype.h" +#include "umath.h" +#include "ops.hpp" + +// helper debugging function +static const char * +get_dtype_name(PyArray_DTypeMeta *dtype) +{ + if (dtype == &QuadPrecDType) { + return "QuadPrecDType"; + } + else if (dtype == &PyArray_BoolDType) { + return "BoolDType"; + } + else if (dtype == &PyArray_ByteDType) { + return "ByteDType"; + } + else if (dtype == &PyArray_UByteDType) { + return "UByteDType"; + } + else if (dtype == &PyArray_ShortDType) { + return "ShortDType"; + } + else if (dtype == &PyArray_UShortDType) { + return "UShortDType"; + } + else if (dtype == &PyArray_IntDType) { + return "IntDType"; + } + else if (dtype == &PyArray_UIntDType) { + return "UIntDType"; + } + else if (dtype == &PyArray_LongDType) { + return "LongDType"; + } + else if (dtype == &PyArray_ULongDType) { + return "ULongDType"; + } + else if (dtype == &PyArray_LongLongDType) { + return "LongLongDType"; + } + else if (dtype == &PyArray_ULongLongDType) { + return "ULongLongDType"; + } + else if (dtype == &PyArray_FloatDType) { + return "FloatDType"; + } + else if (dtype == &PyArray_DoubleDType) { + return "DoubleDType"; + } + else if (dtype == &PyArray_LongDoubleDType) { + return "LongDoubleDType"; + } + else { + return "UnknownDType"; + } +} + +static NPY_CASTING +quad_unary_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[], + PyArray_Descr *const given_descrs[], PyArray_Descr *loop_descrs[], + npy_intp *NPY_UNUSED(view_offset)) +{ + Py_INCREF(given_descrs[0]); + loop_descrs[0] = given_descrs[0]; + + if (given_descrs[1] == NULL) { + Py_INCREF(given_descrs[0]); + loop_descrs[1] = given_descrs[0]; + } + else { + Py_INCREF(given_descrs[1]); + loop_descrs[1] = given_descrs[1]; + } + + QuadPrecDTypeObject *descr_in = (QuadPrecDTypeObject *)given_descrs[0]; + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)loop_descrs[1]; + + if (descr_in->backend != descr_out->backend) { + return NPY_UNSAFE_CASTING; + } + + return NPY_NO_CASTING; +} + +template +int +quad_generic_unary_op_strided_loop_unaligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + npy_intp in_stride = strides[0]; + npy_intp out_stride = strides[1]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + quad_value in, out; + while (N--) { + memcpy(&in, in_ptr, elem_size); + if (backend == BACKEND_SLEEF) { + out.sleef_value = sleef_op(&in.sleef_value); + } + else { + out.longdouble_value = longdouble_op(&in.longdouble_value); + } + memcpy(out_ptr, &out, elem_size); + + in_ptr += in_stride; + out_ptr += out_stride; + } + return 0; +} + +template +int +quad_generic_unary_op_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in_ptr = data[0]; + char *out_ptr = data[1]; + npy_intp in_stride = strides[0]; + npy_intp out_stride = strides[1]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + + while (N--) { + if (backend == BACKEND_SLEEF) { + *(Sleef_quad *)out_ptr = sleef_op((Sleef_quad *)in_ptr); + } + else { + *(long double *)out_ptr = longdouble_op((long double *)in_ptr); + } + in_ptr += in_stride; + out_ptr += out_stride; + } + return 0; +} + +template +int +create_quad_unary_ufunc(PyObject *numpy, const char *ufunc_name) +{ + PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); + if (ufunc == NULL) { + return -1; + } + + PyArray_DTypeMeta *dtypes[2] = {&QuadPrecDType, &QuadPrecDType}; + + PyType_Slot slots[] = { + {NPY_METH_resolve_descriptors, (void *)&quad_unary_op_resolve_descriptors}, + {NPY_METH_strided_loop, + (void *)&quad_generic_unary_op_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, + (void *)&quad_generic_unary_op_strided_loop_unaligned}, + {0, NULL}}; + + PyArrayMethod_Spec Spec = { + .name = "quad_unary_op", + .nin = 1, + .nout = 1, + .casting = NPY_NO_CASTING, + .flags = NPY_METH_SUPPORTS_UNALIGNED, + .dtypes = dtypes, + .slots = slots, + }; + + if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { + return -1; + } + + return 0; +} + +int +init_quad_unary_ops(PyObject *numpy) +{ + if (create_quad_unary_ufunc(numpy, "negative") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "positive") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "absolute") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "rint") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "trunc") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "floor") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "ceil") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "sqrt") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "square") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "log") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "log2") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "log10") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "log1p") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "exp") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "exp2") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "sin") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "cos") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "tan") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "arcsin") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "arccos") < 0) { + return -1; + } + if (create_quad_unary_ufunc(numpy, "arctan") < 0) { + return -1; + } + return 0; +} + +// Binary ufuncs + +static NPY_CASTING +quad_binary_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[], + PyArray_Descr *const given_descrs[], + PyArray_Descr *loop_descrs[], npy_intp *NPY_UNUSED(view_offset)) +{ + QuadPrecDTypeObject *descr_in1 = (QuadPrecDTypeObject *)given_descrs[0]; + QuadPrecDTypeObject *descr_in2 = (QuadPrecDTypeObject *)given_descrs[1]; + QuadBackendType target_backend; + + // Determine target backend and if casting is needed + NPY_CASTING casting = NPY_NO_CASTING; + if (descr_in1->backend != descr_in2->backend) { + target_backend = BACKEND_LONGDOUBLE; + casting = NPY_SAFE_CASTING; + } + else { + target_backend = descr_in1->backend; + } + + // Set up input descriptors, casting if necessary + for (int i = 0; i < 2; i++) { + if (((QuadPrecDTypeObject *)given_descrs[i])->backend != target_backend) { + loop_descrs[i] = (PyArray_Descr *)new_quaddtype_instance(target_backend); + if (!loop_descrs[i]) { + return (NPY_CASTING)-1; + } + } + else { + Py_INCREF(given_descrs[i]); + loop_descrs[i] = given_descrs[i]; + } + } + + // Set up output descriptor + if (given_descrs[2] == NULL) { + loop_descrs[2] = (PyArray_Descr *)new_quaddtype_instance(target_backend); + if (!loop_descrs[2]) { + return (NPY_CASTING)-1; + } + } + else { + QuadPrecDTypeObject *descr_out = (QuadPrecDTypeObject *)given_descrs[2]; + if (descr_out->backend != target_backend) { + loop_descrs[2] = (PyArray_Descr *)new_quaddtype_instance(target_backend); + if (!loop_descrs[2]) { + return (NPY_CASTING)-1; + } + } + else { + Py_INCREF(given_descrs[2]); + loop_descrs[2] = given_descrs[2]; + } + } + return casting; +} + +template +int +quad_generic_binop_strided_loop_unaligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in1_ptr = data[0], *in2_ptr = data[1]; + char *out_ptr = data[2]; + npy_intp in1_stride = strides[0]; + npy_intp in2_stride = strides[1]; + npy_intp out_stride = strides[2]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + quad_value in1, in2, out; + while (N--) { + memcpy(&in1, in1_ptr, elem_size); + memcpy(&in2, in2_ptr, elem_size); + if (backend == BACKEND_SLEEF) { + out.sleef_value = sleef_op(&in1.sleef_value, &in2.sleef_value); + } + else { + out.longdouble_value = longdouble_op(&in1.longdouble_value, &in2.longdouble_value); + } + memcpy(out_ptr, &out, elem_size); + + in1_ptr += in1_stride; + in2_ptr += in2_stride; + out_ptr += out_stride; + } + return 0; +} + +template +int +quad_generic_binop_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in1_ptr = data[0], *in2_ptr = data[1]; + char *out_ptr = data[2]; + npy_intp in1_stride = strides[0]; + npy_intp in2_stride = strides[1]; + npy_intp out_stride = strides[2]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + + while (N--) { + if (backend == BACKEND_SLEEF) { + *(Sleef_quad *)out_ptr = sleef_op((Sleef_quad *)in1_ptr, (Sleef_quad *)in2_ptr); + } + else { + *(long double *)out_ptr = longdouble_op((long double *)in1_ptr, (long double *)in2_ptr); + } + + in1_ptr += in1_stride; + in2_ptr += in2_stride; + out_ptr += out_stride; + } + return 0; +} + +static int +quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], + PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) +{ + int nin = ufunc->nin; + int nargs = ufunc->nargs; + PyArray_DTypeMeta *common = NULL; + bool has_quad = false; + + // Handle the special case for reductions + if (op_dtypes[0] == NULL) { + assert(nin == 2 && ufunc->nout == 1); /* must be reduction */ + for (int i = 0; i < 3; i++) { + Py_INCREF(op_dtypes[1]); + new_op_dtypes[i] = op_dtypes[1]; + } + return 0; + } + + // Check if any input or signature is QuadPrecision + for (int i = 0; i < nin; i++) { + if (op_dtypes[i] == &QuadPrecDType) { + has_quad = true; + } + } + + if (has_quad) { + common = &QuadPrecDType; + } + else { + for (int i = nin; i < nargs; i++) { + if (signature[i] != NULL) { + if (common == NULL) { + Py_INCREF(signature[i]); + common = signature[i]; + } + else if (common != signature[i]) { + Py_CLEAR(common); // Not homogeneous, unset common + break; + } + } + } + } + // If no common output dtype, use standard promotion for inputs + if (common == NULL) { + common = PyArray_PromoteDTypeSequence(nin, op_dtypes); + if (common == NULL) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) { + PyErr_Clear(); // Do not propagate normal promotion errors + } + + return -1; + } + } + + // Set all new_op_dtypes to the common dtype + for (int i = 0; i < nargs; i++) { + if (signature[i]) { + // If signature is specified for this argument, use it + Py_INCREF(signature[i]); + new_op_dtypes[i] = signature[i]; + } + else { + // Otherwise, use the common dtype + Py_INCREF(common); + + new_op_dtypes[i] = common; + } + } + + Py_XDECREF(common); + + return 0; +} + +template +int +create_quad_binary_ufunc(PyObject *numpy, const char *ufunc_name) +{ + PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); + if (ufunc == NULL) { + return -1; + } + + PyArray_DTypeMeta *dtypes[3] = {&QuadPrecDType, &QuadPrecDType, &QuadPrecDType}; + + PyType_Slot slots[] = { + {NPY_METH_resolve_descriptors, (void *)&quad_binary_op_resolve_descriptors}, + {NPY_METH_strided_loop, + (void *)&quad_generic_binop_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, + (void *)&quad_generic_binop_strided_loop_unaligned}, + {0, NULL}}; + + PyArrayMethod_Spec Spec = { + .name = "quad_binop", + .nin = 2, + .nout = 1, + .casting = NPY_NO_CASTING, + .flags = (NPY_ARRAYMETHOD_FLAGS)(NPY_METH_SUPPORTS_UNALIGNED | NPY_METH_IS_REORDERABLE), + .dtypes = dtypes, + .slots = slots, + }; + + if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { + return -1; + } + + PyObject *promoter_capsule = + PyCapsule_New((void *)&quad_ufunc_promoter, "numpy._ufunc_promoter", NULL); + if (promoter_capsule == NULL) { + return -1; + } + + PyObject *DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &PyArrayDescr_Type, &PyArrayDescr_Type); + if (DTypes == 0) { + Py_DECREF(promoter_capsule); + return -1; + } + + if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) { + Py_DECREF(promoter_capsule); + Py_DECREF(DTypes); + return -1; + } + Py_DECREF(promoter_capsule); + Py_DECREF(DTypes); + return 0; +} + +int +init_quad_binary_ops(PyObject *numpy) +{ + if (create_quad_binary_ufunc(numpy, "add") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "subtract") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "multiply") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "divide") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "power") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "mod") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "minimum") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "maximum") < 0) { + return -1; + } + if (create_quad_binary_ufunc(numpy, "arctan2") < 0) { + return -1; + } + return 0; +} + +// comparison functions + +static NPY_CASTING +quad_comparison_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[], + PyArray_Descr *const given_descrs[], + PyArray_Descr *loop_descrs[], + npy_intp *NPY_UNUSED(view_offset)) +{ + QuadPrecDTypeObject *descr_in1 = (QuadPrecDTypeObject *)given_descrs[0]; + QuadPrecDTypeObject *descr_in2 = (QuadPrecDTypeObject *)given_descrs[1]; + QuadBackendType target_backend; + + // As dealing with different backends then cast to boolean + NPY_CASTING casting = NPY_NO_CASTING; + if (descr_in1->backend != descr_in2->backend) { + target_backend = BACKEND_LONGDOUBLE; + casting = NPY_SAFE_CASTING; + } + else { + target_backend = descr_in1->backend; + } + + // Set up input descriptors, casting if necessary + for (int i = 0; i < 2; i++) { + if (((QuadPrecDTypeObject *)given_descrs[i])->backend != target_backend) { + loop_descrs[i] = (PyArray_Descr *)new_quaddtype_instance(target_backend); + if (!loop_descrs[i]) { + return (NPY_CASTING)-1; + } + } + else { + Py_INCREF(given_descrs[i]); + loop_descrs[i] = given_descrs[i]; + } + } + + // Set up output descriptor + loop_descrs[2] = PyArray_DescrFromType(NPY_BOOL); + if (!loop_descrs[2]) { + return (NPY_CASTING)-1; + } + return casting; +} + +template +int +quad_generic_comp_strided_loop(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in1_ptr = data[0], *in2_ptr = data[1]; + char *out_ptr = data[2]; + npy_intp in1_stride = strides[0]; + npy_intp in2_stride = strides[1]; + npy_intp out_stride = strides[2]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + size_t elem_size = (backend == BACKEND_SLEEF) ? sizeof(Sleef_quad) : sizeof(long double); + + quad_value in1, in2; + while (N--) { + memcpy(&in1, in1_ptr, elem_size); + memcpy(&in2, in2_ptr, elem_size); + npy_bool result; + + if (backend == BACKEND_SLEEF) { + result = sleef_comp(&in1.sleef_value, &in2.sleef_value); + } + else { + result = ld_comp(&in1.longdouble_value, &in2.longdouble_value); + } + + memcpy(out_ptr, &result, sizeof(npy_bool)); + + in1_ptr += in1_stride; + in2_ptr += in2_stride; + out_ptr += out_stride; + } + return 0; +} + +template +int +quad_generic_comp_strided_loop_aligned(PyArrayMethod_Context *context, char *const data[], + npy_intp const dimensions[], npy_intp const strides[], + NpyAuxData *auxdata) +{ + npy_intp N = dimensions[0]; + char *in1_ptr = data[0], *in2_ptr = data[1]; + char *out_ptr = data[2]; + npy_intp in1_stride = strides[0]; + npy_intp in2_stride = strides[1]; + npy_intp out_stride = strides[2]; + + QuadPrecDTypeObject *descr = (QuadPrecDTypeObject *)context->descriptors[0]; + QuadBackendType backend = descr->backend; + while (N--) { + quad_value in1 = *(quad_value *)in1_ptr; + quad_value in2 = *(quad_value *)in2_ptr; + + npy_bool result; + + if (backend == BACKEND_SLEEF) { + result = sleef_comp(&in1.sleef_value, &in2.sleef_value); + } + else { + result = ld_comp(&in1.longdouble_value, &in2.longdouble_value); + } + + *(npy_bool *)out_ptr = result; + + in1_ptr += in1_stride; + in2_ptr += in2_stride; + out_ptr += out_stride; + } + return 0; +} + +NPY_NO_EXPORT int +comparison_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], + PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) +{ + PyArray_DTypeMeta *new_signature[NPY_MAXARGS]; + memcpy(new_signature, signature, 3 * sizeof(PyArray_DTypeMeta *)); + new_signature[2] = NULL; + int res = quad_ufunc_promoter(ufunc, op_dtypes, new_signature, new_op_dtypes); + if (res < 0) { + return -1; + } + Py_XSETREF(new_op_dtypes[2], &PyArray_BoolDType); + return 0; +} + +template +int +create_quad_comparison_ufunc(PyObject *numpy, const char *ufunc_name) +{ + PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); + if (ufunc == NULL) { + return -1; + } + + PyArray_DTypeMeta *dtypes[3] = {&QuadPrecDType, &QuadPrecDType, &PyArray_BoolDType}; + + PyType_Slot slots[] = { + {NPY_METH_resolve_descriptors, (void *)&quad_comparison_op_resolve_descriptors}, + {NPY_METH_strided_loop, + (void *)&quad_generic_comp_strided_loop_aligned}, + {NPY_METH_unaligned_strided_loop, + (void *)&quad_generic_comp_strided_loop}, + {0, NULL}}; + + PyArrayMethod_Spec Spec = { + .name = "quad_comp", + .nin = 2, + .nout = 1, + .casting = NPY_SAFE_CASTING, + .flags = NPY_METH_SUPPORTS_UNALIGNED, + .dtypes = dtypes, + .slots = slots, + }; + + if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { + return -1; + } + + PyObject *promoter_capsule = + PyCapsule_New((void *)&comparison_ufunc_promoter, "numpy._ufunc_promoter", NULL); + if (promoter_capsule == NULL) { + return -1; + } + + PyObject *DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &PyArrayDescr_Type, &PyArray_BoolDType); + if (DTypes == 0) { + Py_DECREF(promoter_capsule); + return -1; + } + + if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) { + Py_DECREF(promoter_capsule); + Py_DECREF(DTypes); + return -1; + } + Py_DECREF(promoter_capsule); + Py_DECREF(DTypes); + + return 0; +} + +int +init_quad_comps(PyObject *numpy) +{ + if (create_quad_comparison_ufunc(numpy, "equal") < 0) { + return -1; + } + if (create_quad_comparison_ufunc(numpy, "not_equal") < 0) { + return -1; + } + if (create_quad_comparison_ufunc(numpy, "less") < 0) { + return -1; + } + if (create_quad_comparison_ufunc(numpy, "less_equal") < 0) { + return -1; + } + if (create_quad_comparison_ufunc(numpy, "greater") < 0) { + return -1; + } + if (create_quad_comparison_ufunc(numpy, "greater_equal") < + 0) { + return -1; + } + + return 0; +} + +int +init_quad_umath(void) +{ + PyObject *numpy = PyImport_ImportModule("numpy"); + if (!numpy) { + PyErr_SetString(PyExc_ImportError, "Failed to import numpy module"); + return -1; + } + + if (init_quad_unary_ops(numpy) < 0) { + PyErr_SetString(PyExc_RuntimeError, "Failed to initialize quad unary operations"); + goto err; + } + + if (init_quad_binary_ops(numpy) < 0) { + PyErr_SetString(PyExc_RuntimeError, "Failed to initialize quad binary operations"); + goto err; + } + + if (init_quad_comps(numpy) < 0) { + PyErr_SetString(PyExc_RuntimeError, "Failed to initialize quad comparison operations"); + goto err; + } + + Py_DECREF(numpy); + return 0; + +err: + Py_DECREF(numpy); + return -1; +} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/umath.h b/quaddtype/numpy_quaddtype/src/umath.h similarity index 100% rename from quaddtype/quaddtype/src/umath.h rename to quaddtype/numpy_quaddtype/src/umath.h diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index c262e37e..5e9a142a 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -8,7 +8,7 @@ requires = [ build-backend = "mesonpy" [project] -name = "quaddtype" +name = "numpy_quaddtype" description = "Quad (128-bit) float dtype for numpy" version = "0.0.2" readme = 'README.md' @@ -21,62 +21,4 @@ dependencies = [ [project.optional-dependencies] test = [ "pytest", -] - -# [tool.cibuildwheel] -# archs = ["auto64"] -# skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*", "cp39-*", "cp313-*"] -# test-command = """ -# python -c "import platform; print('Python version:', platform.python_version())" -# python -c "import sys; print('sys.platform:', sys.platform)" -# python -c "import quaddtype; print('quaddtype imported successfully')" -# pip install {package}[test] -# pytest {project}/tests -# """ -# test-extras = ["test"] -# manylinux-x86_64-image = "manylinux_2_28" - -# [tool.cibuildwheel.linux] -# before-all = ''' -# set -ex -# yum install -y wget -# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh -# bash miniconda.sh -b -p $HOME/miniconda -# export PATH="$HOME/miniconda/bin:$PATH" -# conda init bash -# source ~/.bashrc -# conda update -q conda -# conda config --add channels conda-forge -# conda config --set channel_priority strict -# conda install -y -c conda-forge sleef -# if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then -# echo "sleef.h not found. Installation may have failed." -# exit 1 -# fi -# ls -l $HOME/miniconda/include/sleef.h -# ls -l $HOME/miniconda/lib/libsleef* -# ''' -# 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" } -# repair-wheel-command = "auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}" - -# [tool.cibuildwheel.macos] -# before-all = ''' -# set -ex -# ARCH=$(uname -m) -# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-${ARCH}.sh -O miniconda.sh -# bash miniconda.sh -b -p $HOME/miniconda -# export PATH="$HOME/miniconda/bin:$PATH" -# source ~/.bash_profile -# conda update -q conda -# conda config --add channels conda-forge -# conda config --set channel_priority strict -# conda install -y -c conda-forge sleef -# if [ ! -f "$HOME/miniconda/include/sleef.h" ]; then -# echo "sleef.h not found. Installation may have failed." -# exit 1 -# fi -# ls -l $HOME/miniconda/include/sleef.h -# ls -l $HOME/miniconda/lib/libsleef* -# ''' -# 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", SLEEF_INCLUDE_DIR = "$HOME/miniconda/include", SLEEF_LIBRARY = "$HOME/miniconda/lib", MACOSX_DEPLOYMENT_TARGET = "10.13"} -# repair-wheel-command = "delocate-wheel -w {dest_dir} -v {wheel}" \ No newline at end of file +] \ No newline at end of file diff --git a/quaddtype/quaddtype/__init__.py b/quaddtype/quaddtype/__init__.py deleted file mode 100644 index 9f246f73..00000000 --- a/quaddtype/quaddtype/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._quaddtype_main import QuadPrecDType, QuadPrecision \ No newline at end of file diff --git a/quaddtype/quaddtype/src/casts.cpp b/quaddtype/quaddtype/src/casts.cpp deleted file mode 100644 index c096fe5c..00000000 --- a/quaddtype/quaddtype/src/casts.cpp +++ /dev/null @@ -1,468 +0,0 @@ -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NPY_TARGET_VERSION NPY_2_0_API_VERSION -#define NO_IMPORT_ARRAY -#define NO_IMPORT_UFUNC - -extern "C" { -#include - -#include "numpy/arrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/dtype_api.h" -} -#include "sleef.h" -#include "sleefquad.h" - -#include "scalar.h" -#include "casts.h" -#include "dtype.h" - -#define NUM_CASTS 29 // 14 to_casts + 14 from_casts + 1 quad_to_quad - -static NPY_CASTING -quad_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self), - PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]), - QuadPrecDTypeObject *given_descrs[2], - QuadPrecDTypeObject *loop_descrs[2], npy_intp *view_offset) -{ - Py_INCREF(given_descrs[0]); - loop_descrs[0] = given_descrs[0]; - - if (given_descrs[1] == NULL) { - Py_INCREF(given_descrs[0]); - loop_descrs[1] = given_descrs[0]; - } - else { - Py_INCREF(given_descrs[1]); - loop_descrs[1] = given_descrs[1]; - } - - *view_offset = 0; - return NPY_NO_CASTING; -} - -static int -quad_to_quad_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - void *NPY_UNUSED(auxdata)) -{ - npy_intp N = dimensions[0]; - char *in_ptr = data[0]; - char *out_ptr = data[1]; - - npy_intp in_stride = strides[0]; - npy_intp out_stride = strides[1]; - - while (N--) { - memcpy(out_ptr, in_ptr, sizeof(Sleef_quad)); - in_ptr += in_stride; - out_ptr += out_stride; - } - return 0; -} - -// Casting from other types to QuadDType - -template -static inline Sleef_quad -to_quad(T x); - -template <> -inline Sleef_quad -to_quad(npy_bool x) -{ - return x ? Sleef_cast_from_doubleq1(1.0) : Sleef_cast_from_doubleq1(0.0); -} -template <> -inline Sleef_quad -to_quad(npy_byte x) -{ - return Sleef_cast_from_int64q1(x); -} -// template <> -// inline Sleef_quad -// to_quad(npy_ubyte x) -// { -// return Sleef_cast_from_uint64q1(x); -// } -template <> -inline Sleef_quad -to_quad(npy_short x) -{ - return Sleef_cast_from_int64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_ushort x) -{ - return Sleef_cast_from_uint64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_int x) -{ - return Sleef_cast_from_int64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_uint x) -{ - return Sleef_cast_from_uint64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_long x) -{ - return Sleef_cast_from_int64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_ulong x) -{ - return Sleef_cast_from_uint64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_longlong x) -{ - return Sleef_cast_from_int64q1(x); -} -template <> -inline Sleef_quad -to_quad(npy_ulonglong x) -{ - return Sleef_cast_from_uint64q1(x); -} -template <> -inline Sleef_quad -to_quad(float x) -{ - return Sleef_cast_from_doubleq1(x); -} -template <> -inline Sleef_quad -to_quad(double x) -{ - return Sleef_cast_from_doubleq1(x); -} -template <> -inline Sleef_quad -to_quad(long double x) -{ - return Sleef_cast_from_doubleq1(x); -} - -template -static NPY_CASTING -numpy_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self), PyArray_DTypeMeta *dtypes[2], - PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2], - npy_intp *view_offset) -{ - if (given_descrs[1] == NULL) { - loop_descrs[1] = (PyArray_Descr *)new_quaddtype_instance(); - if (loop_descrs[1] == nullptr) { - return (NPY_CASTING)-1; - } - } - else { - Py_INCREF(given_descrs[1]); - loop_descrs[1] = given_descrs[1]; - } - - loop_descrs[0] = PyArray_GetDefaultDescr(dtypes[0]); - // *view_offset = 0; - return NPY_SAFE_CASTING; -} - -template -static int -numpy_to_quad_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - void *NPY_UNUSED(auxdata)) -{ - npy_intp N = dimensions[0]; - char *in_ptr = data[0]; - char *out_ptr = data[1]; - - while (N--) { - T in_val; - Sleef_quad out_val; - - memcpy(&in_val, in_ptr, sizeof(T)); - out_val = to_quad(in_val); - memcpy(out_ptr, &out_val, sizeof(Sleef_quad)); - - in_ptr += strides[0]; - out_ptr += strides[1]; - } - return 0; -} - -// Casting from QuadDType to other types - -template -static inline T -from_quad(Sleef_quad x); - -template <> -inline npy_bool -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_int64q1(x) != 0; -} -template <> -inline npy_byte -from_quad(Sleef_quad x) -{ - return (npy_byte)Sleef_cast_to_int64q1(x); -} -// template <> -// inline npy_ubyte -// from_quad(Sleef_quad x) -// { -// return (npy_ubyte)Sleef_cast_to_uint64q1(x); -// } -template <> -inline npy_short -from_quad(Sleef_quad x) -{ - return (npy_short)Sleef_cast_to_int64q1(x); -} -template <> -inline npy_ushort -from_quad(Sleef_quad x) -{ - return (npy_ushort)Sleef_cast_to_uint64q1(x); -} -template <> -inline npy_int -from_quad(Sleef_quad x) -{ - return (npy_int)Sleef_cast_to_int64q1(x); -} -template <> -inline npy_uint -from_quad(Sleef_quad x) -{ - return (npy_uint)Sleef_cast_to_uint64q1(x); -} -template <> -inline npy_long -from_quad(Sleef_quad x) -{ - return (npy_long)Sleef_cast_to_int64q1(x); -} -template <> -inline npy_ulong -from_quad(Sleef_quad x) -{ - return (npy_ulong)Sleef_cast_to_uint64q1(x); -} -template <> -inline npy_longlong -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_int64q1(x); -} -template <> -inline npy_ulonglong -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_uint64q1(x); -} -template <> -inline float -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_doubleq1(x); -} -template <> -inline double -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_doubleq1(x); -} -template <> -inline long double -from_quad(Sleef_quad x) -{ - return Sleef_cast_to_doubleq1(x); -} - -template -static NPY_CASTING -quad_to_numpy_resolve_descriptors(PyObject *NPY_UNUSED(self), PyArray_DTypeMeta *dtypes[2], - PyArray_Descr *given_descrs[2], PyArray_Descr *loop_descrs[2], - npy_intp *view_offset) -{ - Py_INCREF(given_descrs[0]); - loop_descrs[0] = given_descrs[0]; - - loop_descrs[1] = PyArray_GetDefaultDescr(dtypes[1]); - // *view_offset = 0; - return NPY_UNSAFE_CASTING; -} - -template -static int -quad_to_numpy_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - void *NPY_UNUSED(auxdata)) -{ - npy_intp N = dimensions[0]; - char *in_ptr = data[0]; - char *out_ptr = data[1]; - - while (N--) { - Sleef_quad in_val = *(Sleef_quad *)in_ptr; - T *out_val = (T *)out_ptr; - *out_val = from_quad(in_val); - - in_ptr += strides[0]; - out_ptr += strides[1]; - } - return 0; -} - -static PyArrayMethod_Spec *specs[NUM_CASTS + 1]; // +1 for NULL terminator -static size_t spec_count = 0; - -void -add_spec(PyArrayMethod_Spec *spec) -{ - if (spec_count < NUM_CASTS) { - specs[spec_count++] = spec; - } -} - -// functions to add casts -template -void -add_cast_from(PyArray_DTypeMeta *to) -{ - PyArray_DTypeMeta **dtypes = new PyArray_DTypeMeta *[2]{nullptr, to}; - - PyType_Slot *slots = new PyType_Slot[3]{ - {NPY_METH_resolve_descriptors, (void *)&quad_to_numpy_resolve_descriptors}, - {NPY_METH_strided_loop, (void *)&quad_to_numpy_strided_loop}, - {0, nullptr}}; - - PyArrayMethod_Spec *spec = new PyArrayMethod_Spec{ - .name = "cast_QuadPrec_to_NumPy", - .nin = 1, - .nout = 1, - .casting = NPY_UNSAFE_CASTING, - .flags = (NPY_ARRAYMETHOD_FLAGS)0, - .dtypes = dtypes, - .slots = slots, - }; - add_spec(spec); -} - -template -void -add_cast_to(PyArray_DTypeMeta *from) -{ - PyArray_DTypeMeta **dtypes = new PyArray_DTypeMeta *[2]{from, nullptr}; - - PyType_Slot *slots = new PyType_Slot[3]{ - {NPY_METH_resolve_descriptors, (void *)&numpy_to_quad_resolve_descriptors}, - {NPY_METH_strided_loop, (void *)&numpy_to_quad_strided_loop}, - {0, nullptr}}; - - PyArrayMethod_Spec *spec = new PyArrayMethod_Spec{ - .name = "cast_NumPy_to_QuadPrec", - .nin = 1, - .nout = 1, - .casting = NPY_SAFE_CASTING, - .flags = (NPY_ARRAYMETHOD_FLAGS)0, - .dtypes = dtypes, - .slots = slots, - }; - - add_spec(spec); -} - -PyArrayMethod_Spec ** -init_casts_internal(void) -{ - PyArray_DTypeMeta **quad2quad_dtypes = new PyArray_DTypeMeta *[2]{nullptr, nullptr}; - PyType_Slot *quad2quad_slots = new PyType_Slot[4]{ - {NPY_METH_resolve_descriptors, (void *)&quad_to_quad_resolve_descriptors}, - {NPY_METH_strided_loop, (void *)&quad_to_quad_strided_loop}, - {NPY_METH_unaligned_strided_loop, (void *)&quad_to_quad_strided_loop}, - {0, nullptr}}; - - PyArrayMethod_Spec *quad2quad_spec = new PyArrayMethod_Spec{ - .name = "cast_QuadPrec_to_QuadPrec", - .nin = 1, - .nout = 1, - .casting = NPY_NO_CASTING, - .flags = NPY_METH_SUPPORTS_UNALIGNED, - .dtypes = quad2quad_dtypes, - .slots = quad2quad_slots, - }; - - add_spec(quad2quad_spec); - - add_cast_to(&PyArray_BoolDType); - add_cast_to(&PyArray_ByteDType); - add_cast_to(&PyArray_UByteDType); - add_cast_to(&PyArray_ShortDType); - add_cast_to(&PyArray_UShortDType); - add_cast_to(&PyArray_IntDType); - add_cast_to(&PyArray_UIntDType); - add_cast_to(&PyArray_LongDType); - add_cast_to(&PyArray_ULongDType); - add_cast_to(&PyArray_LongLongDType); - add_cast_to(&PyArray_ULongLongDType); - add_cast_to(&PyArray_FloatDType); - add_cast_to(&PyArray_DoubleDType); - add_cast_to(&PyArray_LongDoubleDType); - - add_cast_from(&PyArray_BoolDType); - add_cast_from(&PyArray_ByteDType); - add_cast_from(&PyArray_UByteDType); - add_cast_from(&PyArray_ShortDType); - add_cast_from(&PyArray_UShortDType); - add_cast_from(&PyArray_IntDType); - add_cast_from(&PyArray_UIntDType); - add_cast_from(&PyArray_LongDType); - add_cast_from(&PyArray_ULongDType); - add_cast_from(&PyArray_LongLongDType); - add_cast_from(&PyArray_ULongLongDType); - add_cast_from(&PyArray_FloatDType); - add_cast_from(&PyArray_DoubleDType); - add_cast_from(&PyArray_LongDoubleDType); - - specs[spec_count] = nullptr; - return specs; -} - -PyArrayMethod_Spec ** -init_casts(void) -{ - try { - return init_casts_internal(); - } - catch (int e) { - PyErr_NoMemory(); - return nullptr; - } -} - -void -free_casts(void) -{ - for (auto cast : specs) { - if (cast == nullptr) { - continue; - } - delete cast->dtypes; - delete cast->slots; - delete cast; - } - spec_count = 0; -} diff --git a/quaddtype/quaddtype/src/dtype.c b/quaddtype/quaddtype/src/dtype.c deleted file mode 100644 index a6f485bf..00000000 --- a/quaddtype/quaddtype/src/dtype.c +++ /dev/null @@ -1,216 +0,0 @@ -#include -#include -#include - -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NPY_TARGET_VERSION NPY_2_0_API_VERSION -#define NO_IMPORT_ARRAY -#define NO_IMPORT_UFUNC -#include "numpy/arrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/dtype_api.h" - -#include "scalar.h" -#include "casts.h" -#include "dtype.h" - -static inline int quad_load(Sleef_quad *x, char *data_ptr) -{ - if (data_ptr == NULL || x == NULL) - { - return -1; - } - *x = *(Sleef_quad *)data_ptr; - return 0; -} - -static inline int quad_store(char *data_ptr, Sleef_quad x) -{ - if (data_ptr == NULL) - { - return -1; - } - *(Sleef_quad *)data_ptr = x; - return 0; -} - -QuadPrecDTypeObject * new_quaddtype_instance(void) -{ - QuadPrecDTypeObject *new = (QuadPrecDTypeObject *)PyArrayDescr_Type.tp_new((PyTypeObject *)&QuadPrecDType, NULL, NULL); - if (new == NULL) { - return NULL; - } - new->base.elsize = sizeof(Sleef_quad); - new->base.alignment = _Alignof(Sleef_quad); - - return new; -} - -static QuadPrecDTypeObject * ensure_canonical(QuadPrecDTypeObject *self) -{ - Py_INCREF(self); - return self; -} - -static QuadPrecDTypeObject * common_instance(QuadPrecDTypeObject *dtype1, QuadPrecDTypeObject *dtype2) -{ - Py_INCREF(dtype1); - return dtype1; -} - - -static PyArray_DTypeMeta * common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other) -{ - // Promote integer and floating-point types to QuadPrecDType - if (other->type_num >= 0 && - (PyTypeNum_ISINTEGER(other->type_num) || - PyTypeNum_ISFLOAT(other->type_num))) { - Py_INCREF(cls); - return cls; - } - // Don't promote complex types - if (PyTypeNum_ISCOMPLEX(other->type_num)) { - Py_INCREF(Py_NotImplemented); - return (PyArray_DTypeMeta *)Py_NotImplemented; - } - - Py_INCREF(Py_NotImplemented); - return (PyArray_DTypeMeta *)Py_NotImplemented; -} - -static PyArray_Descr * -quadprec_discover_descriptor_from_pyobject(PyArray_DTypeMeta *NPY_UNUSED(cls), PyObject *obj) -{ - if (Py_TYPE(obj) != &QuadPrecision_Type) - { - PyErr_SetString(PyExc_TypeError, "Can only store QuadPrecision in a QuadPrecDType array."); - return NULL; - } - return (PyArray_Descr *)new_quaddtype_instance(); -} - -static int quadprec_setitem(QuadPrecDTypeObject *descr, PyObject *obj, char *dataptr) -{ - QuadPrecisionObject *value; - if (PyObject_TypeCheck(obj, &QuadPrecision_Type)) - { - Py_INCREF(obj); - value = (QuadPrecisionObject *)obj; - } - else - { - value = QuadPrecision_from_object(obj); - if (value == NULL) { - return -1; - } - } - - if (quad_store(dataptr, value->quad.value) < 0) - { - Py_DECREF(value); - char error_msg[100]; - snprintf(error_msg, sizeof(error_msg), "Invalid memory location %p", (void*)dataptr); - PyErr_SetString(PyExc_ValueError, error_msg); - return -1; - } - - Py_DECREF(value); - return 0; -} - -static PyObject * quadprec_getitem(QuadPrecDTypeObject *descr, char *dataptr) -{ - QuadPrecisionObject *new = QuadPrecision_raw_new(); - if (!new) - { - return NULL; - } - if (quad_load(&new->quad.value, dataptr) < 0) - { - Py_DECREF(new); - char error_msg[100]; - snprintf(error_msg, sizeof(error_msg), "Invalid memory location %p", (void*)dataptr); - PyErr_SetString(PyExc_ValueError, error_msg); - return NULL; - } - return (PyObject *)new; -} - -static PyArray_Descr *quadprec_default_descr(PyArray_DTypeMeta *NPY_UNUSED(cls)) -{ - return (PyArray_Descr *)new_quaddtype_instance(); -} - -static PyType_Slot QuadPrecDType_Slots[] = -{ - {NPY_DT_ensure_canonical, &ensure_canonical}, - {NPY_DT_common_instance, &common_instance}, - {NPY_DT_common_dtype, &common_dtype}, - {NPY_DT_discover_descr_from_pyobject, &quadprec_discover_descriptor_from_pyobject}, - {NPY_DT_setitem, &quadprec_setitem}, - {NPY_DT_getitem, &quadprec_getitem}, - {NPY_DT_default_descr, &quadprec_default_descr}, - {0, NULL} -}; - - -static PyObject * QuadPrecDType_new(PyTypeObject *NPY_UNUSED(cls), PyObject *args, PyObject *kwds) -{ - if (PyTuple_GET_SIZE(args) != 0 || (kwds != NULL && PyDict_Size(kwds) != 0)) { - PyErr_SetString(PyExc_TypeError, - "QuadPrecDType takes no arguments"); - return NULL; - } - - return (PyObject *)new_quaddtype_instance(); -} - -static PyObject * QuadPrecDType_repr(QuadPrecDTypeObject *self) -{ - return PyUnicode_FromString("QuadPrecDType()"); -} - -PyArray_DTypeMeta QuadPrecDType = { - {{ - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "QuadPrecDType.QuadPrecDType", - .tp_basicsize = sizeof(QuadPrecDTypeObject), - .tp_new = QuadPrecDType_new, - .tp_repr = (reprfunc)QuadPrecDType_repr, - .tp_str = (reprfunc)QuadPrecDType_repr, - }}, -}; - -int init_quadprec_dtype(void) -{ - PyArrayMethod_Spec **casts = init_casts(); - if (!casts) - return -1; - - PyArrayDTypeMeta_Spec QuadPrecDType_DTypeSpec = { - .flags = NPY_DT_NUMERIC, - .casts = casts, - .typeobj = &QuadPrecision_Type, - .slots = QuadPrecDType_Slots, - }; - - ((PyObject *)&QuadPrecDType)->ob_type = &PyArrayDTypeMeta_Type; - - ((PyTypeObject *)&QuadPrecDType)->tp_base = &PyArrayDescr_Type; - - if (PyType_Ready((PyTypeObject *)&QuadPrecDType) < 0) - { - return -1; - } - - if (PyArrayInitDTypeMeta_FromSpec(&QuadPrecDType, &QuadPrecDType_DTypeSpec) < 0) - { - return -1; - } - - free_casts(); - - return 0; -} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/dtype.h b/quaddtype/quaddtype/src/dtype.h deleted file mode 100644 index 162d5714..00000000 --- a/quaddtype/quaddtype/src/dtype.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _QUADDTYPE_DTYPE_H -#define _QUADDTYPE_DTYPE_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#include "scalar.h" - -typedef struct -{ - PyArray_Descr base; - -} QuadPrecDTypeObject; - -extern PyArray_DTypeMeta QuadPrecDType; - -QuadPrecDTypeObject * new_quaddtype_instance(void); - -int init_quadprec_dtype(void); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/quaddtype/quaddtype/src/ops.hpp b/quaddtype/quaddtype/src/ops.hpp deleted file mode 100644 index 6a3511c4..00000000 --- a/quaddtype/quaddtype/src/ops.hpp +++ /dev/null @@ -1,207 +0,0 @@ -#include -#include - -typedef int (*unary_op_def)(Sleef_quad *, Sleef_quad *); - -static inline int -quad_negative(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_negq1(*op); - return 0; -} - -static int -quad_positive(Sleef_quad *op, Sleef_quad *out) -{ - *out = *op; - return 0; -} - -static inline int -quad_absolute(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_fabsq1(*op); - return 0; -} - -static inline int -quad_rint(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_rintq1(*op); - return 0; -} - -static inline int -quad_trunc(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_truncq1(*op); - return 0; -} - -static inline int -quad_floor(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_floorq1(*op); - return 0; -} - -static inline int -quad_ceil(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_ceilq1(*op); - return 0; -} - -static inline int -quad_sqrt(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_sqrtq1_u05(*op); - return 0; -} - -static inline int -quad_square(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_mulq1_u05(*op, *op); - return 0; -} - -static inline int -quad_log(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_logq1_u10(*op); - return 0; -} - -static inline int -quad_log2(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_log2q1_u10(*op); - return 0; -} - -static inline int -quad_log10(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_log10q1_u10(*op); - return 0; -} - -static inline int -quad_log1p(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_log1pq1_u10(*op); - return 0; -} - -static inline int -quad_exp(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_expq1_u10(*op); - return 0; -} - -static inline int -quad_exp2(Sleef_quad *op, Sleef_quad *out) -{ - *out = Sleef_exp2q1_u10(*op); - return 0; -} - -// binary ops -typedef int (*binop_def)(Sleef_quad *, Sleef_quad *, Sleef_quad *); - -static inline int -quad_add(Sleef_quad *out, Sleef_quad *in1, Sleef_quad *in2) -{ - *out = Sleef_addq1_u05(*in1, *in2); - return 0; -} - -static inline int -quad_sub(Sleef_quad *out, Sleef_quad *in1, Sleef_quad *in2) -{ - *out = Sleef_subq1_u05(*in1, *in2); - return 0; -} - -static inline int -quad_mul(Sleef_quad *res, Sleef_quad *a, Sleef_quad *b) -{ - *res = Sleef_mulq1_u05(*a, *b); - return 0; -} - -static inline int -quad_div(Sleef_quad *res, Sleef_quad *a, Sleef_quad *b) -{ - *res = Sleef_divq1_u05(*a, *b); - return 0; -} - -static inline int -quad_pow(Sleef_quad *res, Sleef_quad *a, Sleef_quad *b) -{ - *res = Sleef_powq1_u10(*a, *b); - return 0; -} - -static inline int -quad_mod(Sleef_quad *res, Sleef_quad *a, Sleef_quad *b) -{ - *res = Sleef_fmodq1(*a, *b); - return 0; -} - -static inline int -quad_minimum(Sleef_quad *out, Sleef_quad *in1, Sleef_quad *in2) -{ - *out = Sleef_icmpleq1(*in1, *in2) ? *in1 : *in2; - return 0; -} - -static inline int -quad_maximum(Sleef_quad *out, Sleef_quad *in1, Sleef_quad *in2) -{ - *out = Sleef_icmpgeq1(*in1, *in2) ? *in1 : *in2; - return 0; -} - -// comparison functions -typedef npy_bool (*cmp_def)(const Sleef_quad *, const Sleef_quad *); - -static inline npy_bool -quad_equal(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpeqq1(*a, *b); -} - -static inline npy_bool -quad_notequal(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpneq1(*a, *b); -} - -static inline npy_bool -quad_less(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpltq1(*a, *b); -} - -static inline npy_bool -quad_lessequal(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpleq1(*a, *b); -} - -static inline npy_bool -quad_greater(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpgtq1(*a, *b); -} - -static inline npy_bool -quad_greaterequal(const Sleef_quad *a, const Sleef_quad *b) -{ - return Sleef_icmpgeq1(*a, *b); -} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/quaddtype_main.c b/quaddtype/quaddtype/src/quaddtype_main.c deleted file mode 100644 index 098c0749..00000000 --- a/quaddtype/quaddtype/src/quaddtype_main.c +++ /dev/null @@ -1,55 +0,0 @@ -#include - -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NPY_TARGET_VERSION NPY_2_0_API_VERSION - -#include "numpy/arrayobject.h" -#include "numpy/dtype_api.h" -#include "numpy/ufuncobject.h" - -#include "dtype.h" -#include "umath.h" - -static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - .m_name = "_quaddtype_main", - .m_doc = "Quad (128-bit) floating point Data Type for Numpy", - .m_size = -1, -}; - -PyMODINIT_FUNC -PyInit__quaddtype_main(void) -{ - import_array(); - import_umath(); - PyObject *m = PyModule_Create(&moduledef); - if (!m) - { - return NULL; - } - - if (init_quadprecision_scalar() < 0) - goto error; - - if(PyModule_AddObject(m, "QuadPrecision", (PyObject *)&QuadPrecision_Type) < 0) - goto error; - - if(init_quadprec_dtype() < 0) - goto error; - - if(PyModule_AddObject(m, "QuadPrecDType", (PyObject *)&QuadPrecDType) < 0) - goto error; - - if (init_quad_umath() < 0) { - goto error; - } - - return m; - - -error: - Py_DECREF(m); - return NULL; -} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/scalar.c b/quaddtype/quaddtype/src/scalar.c deleted file mode 100644 index 15f727d8..00000000 --- a/quaddtype/quaddtype/src/scalar.c +++ /dev/null @@ -1,126 +0,0 @@ -#include -#include -#include - -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NO_IMPORT_ARRAY - -#include "numpy/arrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/dtype_api.h" - -#include "scalar.h" -#include "scalar_ops.h" - - -// static PyTypeObject QuadPrecision_Type; - - -QuadPrecisionObject * QuadPrecision_raw_new(void) -{ - QuadPrecisionObject * new = PyObject_New(QuadPrecisionObject, &QuadPrecision_Type); - if(!new) - return NULL; - new->quad.value = Sleef_cast_from_doubleq1(0.0); // initialize to 0 - return new; -} - -QuadPrecisionObject * QuadPrecision_from_object(PyObject * value) -{ - QuadPrecisionObject *self = QuadPrecision_raw_new(); - if(!self) - return NULL; - - if(PyFloat_Check(value)) - self->quad.value = Sleef_cast_from_doubleq1(PyFloat_AsDouble(value)); - - else if(PyUnicode_CheckExact(value)) - { - const char * s = PyUnicode_AsUTF8(value); - char *endptr = NULL; - self->quad.value = Sleef_strtoq(s, &endptr); - if (*endptr != '\0' || endptr == s) - { - PyErr_SetString(PyExc_ValueError, "Unable to parse string to QuadPrecision"); - Py_DECREF(self); - return NULL; - } - } - else if(PyLong_Check(value)) - { - long int val = PyLong_AsLong(value); - if (val == -1) - { - PyErr_SetString(PyExc_OverflowError, "Overflow Error, value out of range"); - Py_DECREF(self); - return NULL; - } - self->quad.value = Sleef_cast_from_int64q1(val); - } - else - { - PyErr_SetString(PyExc_TypeError, "QuadPrecision value must be a float, int or string"); - Py_DECREF(self); - return NULL; - } - - return self; -} - -static PyObject * -QuadPrecision_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) -{ - PyObject *value; - - if (!PyArg_ParseTuple(args, "O", &value)) { - return NULL; - } - - return (PyObject *)QuadPrecision_from_object(value); -} - -static PyObject * QuadPrecision_str(QuadPrecisionObject * self) -{ - char buffer[128]; - Sleef_snprintf(buffer, sizeof(buffer), "%.*Qe", SLEEF_QUAD_DIG, self->quad.value); - return PyUnicode_FromString(buffer); -} - -static PyObject * QuadPrecision_repr(QuadPrecisionObject* self) -{ - PyObject *str = QuadPrecision_str(self); - if (str == NULL) { - return NULL; - } - PyObject *res = PyUnicode_FromFormat("QuadPrecision('%S')", str); - Py_DECREF(str); - return res; -} - -static void -quad_dealloc(QuadPrecDTypeObject *self) -{ - Py_TYPE(self)->tp_free((PyObject *)self); -} - -PyTypeObject QuadPrecision_Type = -{ - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "QuadPrecType.QuadPrecision", - .tp_basicsize = sizeof(QuadPrecisionObject), - .tp_itemsize = 0, - .tp_new = QuadPrecision_new, - .tp_dealloc = (destructor)quad_dealloc, - .tp_repr = (reprfunc)QuadPrecision_repr, - .tp_str = (reprfunc)QuadPrecision_str, - .tp_as_number = &quad_as_scalar, - .tp_richcompare = (richcmpfunc)quad_richcompare - -}; - -int -init_quadprecision_scalar(void) -{ - return PyType_Ready(&QuadPrecision_Type); -} \ No newline at end of file diff --git a/quaddtype/quaddtype/src/scalar.h b/quaddtype/quaddtype/src/scalar.h deleted file mode 100644 index 962a1fec..00000000 --- a/quaddtype/quaddtype/src/scalar.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _QUADDTYPE_SCALAR_H -#define _QUADDTYPE_SCALAR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct { - Sleef_quad value; -} quad_field; - -typedef struct { - PyObject_HEAD - quad_field quad; -} QuadPrecisionObject; - -extern PyTypeObject QuadPrecision_Type; - -QuadPrecisionObject * -QuadPrecision_raw_new(void); - -QuadPrecisionObject * -QuadPrecision_from_object(PyObject *value); - -int -init_quadprecision_scalar(void); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/quaddtype/quaddtype/src/scalar_ops.cpp b/quaddtype/quaddtype/src/scalar_ops.cpp deleted file mode 100644 index a51bc69a..00000000 --- a/quaddtype/quaddtype/src/scalar_ops.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NPY_TARGET_VERSION NPY_2_0_API_VERSION -#define NO_IMPORT_ARRAY - -extern "C" { -#include - -#include "numpy/arrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/ufuncobject.h" - -#include "numpy/dtype_api.h" -} - -#include "scalar.h" -#include "ops.hpp" -#include "scalar_ops.h" - -template -static PyObject * -quad_unary_func(QuadPrecisionObject *self) -{ - QuadPrecisionObject *res = QuadPrecision_raw_new(); - if (!res) { - return NULL; - } - - unary_op(&self->quad.value, &res->quad.value); - return (PyObject *)res; -} - -PyObject * -quad_nonzero(QuadPrecisionObject *self) -{ - return PyBool_FromLong(Sleef_icmpneq1(self->quad.value, Sleef_cast_from_int64q1(0))); -} - -template -static PyObject * -quad_binary_func(PyObject *op1, PyObject *op2) -{ - QuadPrecisionObject *self; - PyObject *other; - QuadPrecisionObject *other_quad = NULL; - int is_forward; - - if (PyObject_TypeCheck(op1, &QuadPrecision_Type)) { - is_forward = 1; - self = (QuadPrecisionObject *)op1; - other = Py_NewRef(op2); - } - else { - is_forward = 0; - self = (QuadPrecisionObject *)op2; - other = Py_NewRef(op1); - } - - if (PyObject_TypeCheck(other, &QuadPrecision_Type)) { - Py_INCREF(other); - other_quad = (QuadPrecisionObject *)other; - } - else if (PyLong_Check(other) || PyFloat_Check(other)) { - other_quad = QuadPrecision_raw_new(); - if (!other_quad) { - Py_DECREF(other); - return NULL; - } - - if (PyLong_Check(other)) { - long long value = PyLong_AsLongLong(other); - if (value == -1 && PyErr_Occurred()) { - Py_DECREF(other); - Py_DECREF(other_quad); - return NULL; - } - other_quad->quad.value = Sleef_cast_from_int64q1(value); - } - else { - double value = PyFloat_AsDouble(other); - if (value == -1.0 && PyErr_Occurred()) { - Py_DECREF(other); - Py_DECREF(other_quad); - return NULL; - } - other_quad->quad.value = Sleef_cast_from_doubleq1(value); - } - } - else { - Py_DECREF(other); - Py_RETURN_NOTIMPLEMENTED; - } - - QuadPrecisionObject *res = QuadPrecision_raw_new(); - if (!res) { - Py_DECREF(other_quad); - Py_DECREF(other); - return NULL; - } - - if (is_forward) { - binary_op(&res->quad.value, &self->quad.value, &other_quad->quad.value); - } - else { - binary_op(&res->quad.value, &other_quad->quad.value, &self->quad.value); - } - - Py_DECREF(other_quad); - Py_DECREF(other); - return (PyObject *)res; -} - -// todo: add support with float and int -PyObject * -quad_richcompare(QuadPrecisionObject *self, PyObject *other, int cmp_op) -{ - QuadPrecisionObject *other_quad = NULL; - - if (PyObject_TypeCheck(other, &QuadPrecision_Type)) { - Py_INCREF(other); - other_quad = (QuadPrecisionObject *)other; - } - else if (PyLong_CheckExact(other) || PyFloat_CheckExact(other)) { - other_quad = QuadPrecision_from_object(other); - if (other_quad == NULL) { - return NULL; - } - } - else { - Py_RETURN_NOTIMPLEMENTED; - } - int cmp; - switch (cmp_op) { - case Py_LT: - cmp = Sleef_icmpltq1(self->quad.value, other_quad->quad.value); - break; - case Py_LE: - cmp = Sleef_icmpleq1(self->quad.value, other_quad->quad.value); - break; - case Py_EQ: - cmp = Sleef_icmpeqq1(self->quad.value, other_quad->quad.value); - break; - case Py_NE: - cmp = Sleef_icmpneq1(self->quad.value, other_quad->quad.value); - break; - case Py_GT: - cmp = Sleef_icmpgtq1(self->quad.value, other_quad->quad.value); - break; - case Py_GE: - cmp = Sleef_icmpgeq1(self->quad.value, other_quad->quad.value); - break; - default: - Py_DECREF(other_quad); - Py_RETURN_NOTIMPLEMENTED; - } - Py_DECREF(other_quad); - - return PyBool_FromLong(cmp); -} - -PyNumberMethods quad_as_scalar = { - .nb_add = (binaryfunc)quad_binary_func, - .nb_subtract = (binaryfunc)quad_binary_func, - .nb_multiply = (binaryfunc)quad_binary_func, - .nb_power = (ternaryfunc)quad_binary_func, - .nb_negative = (unaryfunc)quad_unary_func, - .nb_positive = (unaryfunc)quad_unary_func, - .nb_absolute = (unaryfunc)quad_unary_func, - .nb_bool = (inquiry)quad_nonzero, - .nb_true_divide = (binaryfunc)quad_binary_func, -}; \ No newline at end of file diff --git a/quaddtype/quaddtype/src/umath.cpp b/quaddtype/quaddtype/src/umath.cpp deleted file mode 100644 index 9007f890..00000000 --- a/quaddtype/quaddtype/src/umath.cpp +++ /dev/null @@ -1,576 +0,0 @@ -#include "scalar.h" - -#define PY_ARRAY_UNIQUE_SYMBOL QuadPrecType_ARRAY_API -#define PY_UFUNC_UNIQUE_SYMBOL QuadPrecType_UFUNC_API -#define NPY_NO_DEPRECATED_API NPY_2_0_API_VERSION -#define NPY_TARGET_VERSION NPY_2_0_API_VERSION -#define NO_IMPORT_ARRAY -#define NO_IMPORT_UFUNC - -extern "C" { -#include -#include - -#include "numpy/arrayobject.h" -#include "numpy/ndarraytypes.h" -#include "numpy/ufuncobject.h" - -#include "numpy/dtype_api.h" -} -#include "dtype.h" -#include "umath.h" -#include "ops.hpp" - -template -int -quad_generic_unary_op_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - NpyAuxData *auxdata) -{ - npy_intp N = dimensions[0]; - char *in_ptr = data[0]; - char *out_ptr = data[1]; - npy_intp in_stride = strides[0]; - npy_intp out_stride = strides[1]; - - Sleef_quad in, out; - while (N--) { - memcpy(&in, in_ptr, sizeof(Sleef_quad)); - unary_op(&in, &out); - memcpy(out_ptr, &out, sizeof(Sleef_quad)); - - in_ptr += in_stride; - out_ptr += out_stride; - } - return 0; -} - -static NPY_CASTING -quad_unary_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[], - PyArray_Descr *const given_descrs[], PyArray_Descr *loop_descrs[], - npy_intp *NPY_UNUSED(view_offset)) -{ - Py_INCREF(given_descrs[0]); - loop_descrs[0] = given_descrs[0]; - - if (given_descrs[1] == NULL) { - Py_INCREF(given_descrs[0]); - loop_descrs[1] = given_descrs[0]; - return NPY_NO_CASTING; - } - Py_INCREF(given_descrs[1]); - loop_descrs[1] = given_descrs[1]; - - return NPY_NO_CASTING; -} - -template -int -create_quad_unary_ufunc(PyObject *numpy, const char *ufunc_name) -{ - PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); - if (ufunc == NULL) { - return -1; - } - - PyArray_DTypeMeta *dtypes[2] = {&QuadPrecDType, &QuadPrecDType}; - - PyType_Slot slots[] = { - {NPY_METH_resolve_descriptors, (void *)&quad_unary_op_resolve_descriptors}, - {NPY_METH_strided_loop, (void *)&quad_generic_unary_op_strided_loop}, - {0, NULL}}; - - PyArrayMethod_Spec Spec = { - .name = "quad_unary_op", - .nin = 1, - .nout = 1, - .casting = NPY_NO_CASTING, - .flags = (NPY_ARRAYMETHOD_FLAGS)0, - .dtypes = dtypes, - .slots = slots, - }; - - if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { - return -1; - } - - return 0; -} - -int -init_quad_unary_ops(PyObject *numpy) -{ - if (create_quad_unary_ufunc(numpy, "negative") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "absolute") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "rint") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "trunc") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "floor") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "ceil") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "sqrt") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "square") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "log") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "log2") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "log10") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "log1p") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "exp") < 0) { - return -1; - } - if (create_quad_unary_ufunc(numpy, "exp2") < 0) { - return -1; - } - return 0; -} - -// Binary ufuncs - -template -int -quad_generic_binop_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - NpyAuxData *auxdata) -{ - npy_intp N = dimensions[0]; - char *in1_ptr = data[0], *in2_ptr = data[1]; - char *out_ptr = data[2]; - npy_intp in1_stride = strides[0]; - npy_intp in2_stride = strides[1]; - npy_intp out_stride = strides[2]; - - Sleef_quad in1, in2, out; - while (N--) { - memcpy(&in1, in1_ptr, sizeof(Sleef_quad)); - memcpy(&in2, in2_ptr, sizeof(Sleef_quad)); - binop(&out, &in1, &in2); - memcpy(out_ptr, &out, sizeof(Sleef_quad)); - - in1_ptr += in1_stride; - in2_ptr += in2_stride; - out_ptr += out_stride; - } - return 0; -} - -static NPY_CASTING -quad_binary_op_resolve_descriptors(PyObject *self, PyArray_DTypeMeta *const dtypes[], - PyArray_Descr *const given_descrs[], - PyArray_Descr *loop_descrs[], npy_intp *NPY_UNUSED(view_offset)) -{ - Py_INCREF(given_descrs[0]); - loop_descrs[0] = given_descrs[0]; - Py_INCREF(given_descrs[1]); - loop_descrs[1] = given_descrs[1]; - - if (given_descrs[2] == NULL) { - PyArray_Descr *out_descr = (PyArray_Descr *)new_quaddtype_instance(); - if (!out_descr) { - return (NPY_CASTING)-1; - } - Py_INCREF(given_descrs[0]); - loop_descrs[2] = out_descr; - } - else { - Py_INCREF(given_descrs[2]); - loop_descrs[2] = given_descrs[2]; - } - - return NPY_NO_CASTING; -} - -// helper debugging function -static const char * -get_dtype_name(PyArray_DTypeMeta *dtype) -{ - if (dtype == &QuadPrecDType) { - return "QuadPrecDType"; - } - else if (dtype == &PyArray_BoolDType) { - return "BoolDType"; - } - else if (dtype == &PyArray_ByteDType) { - return "ByteDType"; - } - else if (dtype == &PyArray_UByteDType) { - return "UByteDType"; - } - else if (dtype == &PyArray_ShortDType) { - return "ShortDType"; - } - else if (dtype == &PyArray_UShortDType) { - return "UShortDType"; - } - else if (dtype == &PyArray_IntDType) { - return "IntDType"; - } - else if (dtype == &PyArray_UIntDType) { - return "UIntDType"; - } - else if (dtype == &PyArray_LongDType) { - return "LongDType"; - } - else if (dtype == &PyArray_ULongDType) { - return "ULongDType"; - } - else if (dtype == &PyArray_LongLongDType) { - return "LongLongDType"; - } - else if (dtype == &PyArray_ULongLongDType) { - return "ULongLongDType"; - } - else if (dtype == &PyArray_FloatDType) { - return "FloatDType"; - } - else if (dtype == &PyArray_DoubleDType) { - return "DoubleDType"; - } - else if (dtype == &PyArray_LongDoubleDType) { - return "LongDoubleDType"; - } - else { - return "UnknownDType"; - } -} - -static int -quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], - PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) -{ - // printf("quad_ufunc_promoter called for ufunc: %s\n", ufunc->name); - // printf("Entering quad_ufunc_promoter\n"); - // printf("Ufunc name: %s\n", ufunc->name); - // printf("nin: %d, nargs: %d\n", ufunc->nin, ufunc->nargs); - - int nin = ufunc->nin; - int nargs = ufunc->nargs; - PyArray_DTypeMeta *common = NULL; - bool has_quad = false; - - // Handle the special case for reductions - if (op_dtypes[0] == NULL) { - assert(nin == 2 && ufunc->nout == 1); /* must be reduction */ - for (int i = 0; i < 3; i++) { - Py_INCREF(op_dtypes[1]); - new_op_dtypes[i] = op_dtypes[1]; - // printf("new_op_dtypes[%d] set to %s\n", i, get_dtype_name(new_op_dtypes[i])); - } - return 0; - } - - // Check if any input or signature is QuadPrecision - for (int i = 0; i < nargs; i++) { - if ((i < nin && op_dtypes[i] == &QuadPrecDType) || (signature[i] == &QuadPrecDType)) { - has_quad = true; - // printf("QuadPrecision detected in input %d or signature\n", i); - break; - } - } - - if (has_quad) { - // If QuadPrecision is involved, use it for all arguments - common = &QuadPrecDType; - // printf("Using QuadPrecDType as common type\n"); - } - else { - // Check if output signature is homogeneous - for (int i = nin; i < nargs; i++) { - if (signature[i] != NULL) { - if (common == NULL) { - Py_INCREF(signature[i]); - common = signature[i]; - // printf("Common type set to %s from signature\n", get_dtype_name(common)); - } - else if (common != signature[i]) { - Py_CLEAR(common); // Not homogeneous, unset common - // printf("Output signature not homogeneous, cleared common type\n"); - break; - } - } - } - - // If no common output dtype, use standard promotion for inputs - if (common == NULL) { - // printf("Using standard promotion for inputs\n"); - common = PyArray_PromoteDTypeSequence(nin, op_dtypes); - if (common == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) { - PyErr_Clear(); // Do not propagate normal promotion errors - } - // printf("Exiting quad_ufunc_promoter (promotion failed)\n"); - return -1; - } - // printf("Common type after promotion: %s\n", get_dtype_name(common)); - } - } - - // Set all new_op_dtypes to the common dtype - for (int i = 0; i < nargs; i++) { - if (signature[i]) { - // If signature is specified for this argument, use it - Py_INCREF(signature[i]); - new_op_dtypes[i] = signature[i]; - // printf("new_op_dtypes[%d] set to %s (from signature)\n", i, - // get_dtype_name(new_op_dtypes[i])); - } - else { - // Otherwise, use the common dtype - Py_INCREF(common); - new_op_dtypes[i] = common; - // printf("new_op_dtypes[%d] set to %s (from common)\n", i, - // get_dtype_name(new_op_dtypes[i])); - } - } - - Py_XDECREF(common); - // printf("Exiting quad_ufunc_promoter\n"); - return 0; -} - -template -int -create_quad_binary_ufunc(PyObject *numpy, const char *ufunc_name) -{ - PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); - if (ufunc == NULL) { - Py_DecRef(ufunc); - return -1; - } - - PyArray_DTypeMeta *dtypes[3] = {&QuadPrecDType, &QuadPrecDType, &QuadPrecDType}; - - PyType_Slot slots[] = { - {NPY_METH_resolve_descriptors, (void *)&quad_binary_op_resolve_descriptors}, - {NPY_METH_strided_loop, (void *)&quad_generic_binop_strided_loop}, - {0, NULL}}; - - PyArrayMethod_Spec Spec = { - .name = "quad_binop", - .nin = 2, - .nout = 1, - .casting = NPY_NO_CASTING, - .flags = (NPY_ARRAYMETHOD_FLAGS)0, - .dtypes = dtypes, - .slots = slots, - }; - - if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { - return -1; - } - - PyObject *promoter_capsule = - PyCapsule_New((void *)&quad_ufunc_promoter, "numpy._ufunc_promoter", NULL); - if (promoter_capsule == NULL) { - return -1; - } - - PyObject *DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &PyArrayDescr_Type, &PyArrayDescr_Type); - if (DTypes == 0) { - Py_DECREF(promoter_capsule); - return -1; - } - - if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) { - Py_DECREF(promoter_capsule); - Py_DECREF(DTypes); - return -1; - } - Py_DECREF(promoter_capsule); - Py_DECREF(DTypes); - return 0; -} - -int -init_quad_binary_ops(PyObject *numpy) -{ - if (create_quad_binary_ufunc(numpy, "add") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "subtract") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "multiply") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "divide") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "power") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "mod") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "minimum") < 0) { - return -1; - } - if (create_quad_binary_ufunc(numpy, "maximum") < 0) { - return -1; - } - return 0; -} - -// comparison functions - -template -int -quad_generic_comp_strided_loop(PyArrayMethod_Context *context, char *const data[], - npy_intp const dimensions[], npy_intp const strides[], - NpyAuxData *auxdata) -{ - npy_intp N = dimensions[0]; - char *in1_ptr = data[0], *in2_ptr = data[1]; - char *out_ptr = data[2]; - npy_intp in1_stride = strides[0]; - npy_intp in2_stride = strides[1]; - npy_intp out_stride = strides[2]; - - while (N--) { - *((npy_bool *)out_ptr) = comp((Sleef_quad *)in1_ptr, (Sleef_quad *)in2_ptr); - - in1_ptr += in1_stride; - in2_ptr += in2_stride; - out_ptr += out_stride; - } - return 0; -} - -NPY_NO_EXPORT int -comparison_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], - PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) -{ - PyArray_DTypeMeta *new_signature[NPY_MAXARGS]; - - memcpy(new_signature, signature, 3 * sizeof(PyArray_DTypeMeta *)); - new_signature[2] = NULL; - int res = quad_ufunc_promoter(ufunc, op_dtypes, new_signature, new_op_dtypes); - if (res < 0) { - return -1; - } - Py_XSETREF(new_op_dtypes[2], &PyArray_BoolDType); - return 0; -} - -template -int -create_quad_comparison_ufunc(PyObject *numpy, const char *ufunc_name) -{ - PyObject *ufunc = PyObject_GetAttrString(numpy, ufunc_name); - if (ufunc == NULL) { - return -1; - } - - PyArray_DTypeMeta *dtypes[3] = {&QuadPrecDType, &QuadPrecDType, &PyArray_BoolDType}; - - PyType_Slot slots[] = {{NPY_METH_strided_loop, (void *)&quad_generic_comp_strided_loop}, - {0, NULL}}; - - PyArrayMethod_Spec Spec = { - .name = "quad_comp", - .nin = 2, - .nout = 1, - .casting = NPY_NO_CASTING, - .flags = (NPY_ARRAYMETHOD_FLAGS)0, - .dtypes = dtypes, - .slots = slots, - }; - - if (PyUFunc_AddLoopFromSpec(ufunc, &Spec) < 0) { - return -1; - } - - PyObject *promoter_capsule = - PyCapsule_New((void *)&comparison_ufunc_promoter, "numpy._ufunc_promoter", NULL); - if (promoter_capsule == NULL) { - return -1; - } - - PyObject *DTypes = PyTuple_Pack(3, &PyArrayDescr_Type, &PyArrayDescr_Type, &PyArray_BoolDType); - if (DTypes == 0) { - Py_DECREF(promoter_capsule); - return -1; - } - - if (PyUFunc_AddPromoter(ufunc, DTypes, promoter_capsule) < 0) { - Py_DECREF(promoter_capsule); - Py_DECREF(DTypes); - return -1; - } - Py_DECREF(promoter_capsule); - Py_DECREF(DTypes); - - return 0; -} - -int -init_quad_comps(PyObject *numpy) -{ - if (create_quad_comparison_ufunc(numpy, "equal") < 0) { - return -1; - } - if (create_quad_comparison_ufunc(numpy, "not_equal") < 0) { - return -1; - } - if (create_quad_comparison_ufunc(numpy, "less") < 0) { - return -1; - } - if (create_quad_comparison_ufunc(numpy, "less_equal") < 0) { - return -1; - } - if (create_quad_comparison_ufunc(numpy, "greater") < 0) { - return -1; - } - if (create_quad_comparison_ufunc(numpy, "greater_equal") < 0) { - return -1; - } - - return 0; -} - -int -init_quad_umath(void) -{ - PyObject *numpy = PyImport_ImportModule("numpy"); - if (!numpy) - return -1; - - if (init_quad_unary_ops(numpy) < 0) { - goto err; - } - - if (init_quad_binary_ops(numpy) < 0) { - goto err; - } - - if (init_quad_comps(numpy) < 0) { - goto err; - } - - Py_DECREF(numpy); - return 0; - -err: - Py_DECREF(numpy); - return -1; -} \ No newline at end of file diff --git a/quaddtype/reinstall.sh b/quaddtype/reinstall.sh index 31479511..5131f15a 100755 --- a/quaddtype/reinstall.sh +++ b/quaddtype/reinstall.sh @@ -8,6 +8,6 @@ then fi #meson setup build -Db_sanitize=address,undefined -python -m pip uninstall -y 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 +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 20ccd91c..11cf7671 100644 --- a/quaddtype/tests/test_quaddtype.py +++ b/quaddtype/tests/test_quaddtype.py @@ -3,7 +3,7 @@ import numpy as np import operator -from quaddtype import QuadPrecDType, QuadPrecision +from numpy_quaddtype import QuadPrecDType, QuadPrecision def test_create_scalar_simple(): @@ -17,12 +17,6 @@ def test_basic_equality(): "12.0") == QuadPrecision("12.00") -@pytest.mark.parametrize("val", ["123532.543", "12893283.5"]) -def test_scalar_repr(val): - expected = f"QuadPrecision('{str(QuadPrecision(val))}')" - assert repr(QuadPrecision(val)) == expected - - @pytest.mark.parametrize("op", ["add", "sub", "mul", "truediv", "pow"]) @pytest.mark.parametrize("other", ["3.0", "12.5", "100.0"]) def test_binary_ops(op, other): From cb77ce4e64afb18dfbe3ac899ff11ddef85d0888 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Wed, 25 Sep 2024 23:10:37 +0530 Subject: [PATCH 180/182] refactoring --- .../{build_wheel.yml => build_wheels.yml} | 150 +++++++----------- quaddtype/meson.build | 80 +++------- quaddtype/pyproject.toml | 2 +- 3 files changed, 78 insertions(+), 154 deletions(-) rename .github/workflows/{build_wheel.yml => build_wheels.yml} (53%) diff --git a/.github/workflows/build_wheel.yml b/.github/workflows/build_wheels.yml similarity index 53% rename from .github/workflows/build_wheel.yml rename to .github/workflows/build_wheels.yml index aeb5784d..1310da04 100644 --- a/.github/workflows/build_wheel.yml +++ b/.github/workflows/build_wheels.yml @@ -5,8 +5,13 @@ on: branches: - main tags: - - "v*" + - "quaddtype-v*" + paths: + - "quaddtype/**" pull_request: + paths: + - "quaddtype/**" + workflow_dispatch: jobs: build_wheels_linux: @@ -29,32 +34,19 @@ jobs: CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 CIBW_BUILD_VERBOSITY: "3" CIBW_BEFORE_ALL: | - yum install -y wget - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p /root/miniconda - export PATH="/root/miniconda/bin:$PATH" - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a - conda config --add channels conda-forge - conda config --set channel_priority strict - conda create -n build_env python=3.10 - source activate build_env - conda install -y sleef + git clone 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 + cmake --install build --prefix /usr/local CIBW_ENVIRONMENT: > - LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH" - LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH" - CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS" - CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS" - LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS" - SLEEF_PATH="/root/miniconda/envs/build_env" - CIBW_REPAIR_WHEEL_COMMAND: > + CFLAGS="-I/usr/local/include $CFLAGS" + CXXFLAGS="-I/usr/local/include $CXXFLAGS" + LDFLAGS="-L/usr/local/lib64 $LDFLAGS" + LD_LIBRARY_PATH="/usr/local/lib64:$LD_LIBRARY_PATH" + CIBW_REPAIR_WHEEL_COMMAND: | auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel} CIBW_TEST_COMMAND: | - python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] pytest {project}/tests CIBW_TEST_EXTRAS: "test" @@ -62,7 +54,7 @@ jobs: python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./quaddtype/wheelhouse/*.whl name: wheels-linux @@ -80,59 +72,48 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ">=3.10.0" - - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true python-version: "3.10" - channels: conda-forge - name: Install SLEEF - shell: bash -l {0} + env: + MACOSX_DEPLOYMENT_TARGET: "11.0" run: | - conda install -y -c conda-forge sleef - echo $CONDA_PREFIX - echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV - + git clone 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 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -DCMAKE_INSTALL_RPATH="@loader_path/../lib" \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON + cmake --build build/ --clean-first -j + sudo cmake --install build --prefix /usr/local - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 - name: Build wheels env: - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD: "cp310-* cp311-* cp312-*" CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BUILD_VERBOSITY: "1" CIBW_ENVIRONMENT: > - SLEEF_PATH="${{ env.SLEEF_PATH }}" - DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH" - LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH" - CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS" - CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS" - LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS" - MACOSX_DEPLOYMENT_TARGET="10.13" - CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}" + MACOSX_DEPLOYMENT_TARGET="11.0" + DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" + CFLAGS="-I/usr/local/include $CFLAGS" + CXXFLAGS="-I/usr/local/include $CXXFLAGS" + LDFLAGS="-L/usr/local/lib $LDFLAGS" + CIBW_REPAIR_WHEEL_COMMAND: > + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} CIBW_TEST_COMMAND: | - python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))" - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] pytest {project}/tests CIBW_TEST_EXTRAS: "test" run: | - echo "SLEEF_PATH: $SLEEF_PATH" - ls $SLEEF_PATH/include/sleef* - echo "PATH: $PATH" - which python - python --version - which pip - pip --version - cd quaddtype python -m cibuildwheel --output-dir wheelhouse + working-directory: ./quaddtype - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./quaddtype/wheelhouse/*.whl name: wheels-${{ matrix.os }} @@ -171,20 +152,16 @@ jobs: conda config --add channels conda-forge conda config --set channel_priority strict conda install -y sleef numpy - conda list - if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then - echo "sleef.h not found. Installation may have failed." - exit 1 - fi - ls -l "$CONDA_PREFIX/Library/include/sleef.h" - ls -l "$CONDA_PREFIX/Library/lib/sleef"* - - name: Set environment variables + - name: Setup build environment shell: pwsh run: | - echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - $numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))" - echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + $env:INCLUDE += ";$env:CONDA_PREFIX\Library\include" + $env:LIB += ";$env:CONDA_PREFIX\Library\lib" + $env:PATH = "$env:CONDA_PREFIX\Library\bin;$env:PATH" + echo "INCLUDE=$env:INCLUDE" >> $env:GITHUB_ENV + echo "LIB=$env:LIB" >> $env:GITHUB_ENV + echo "PATH=$env:PATH" >> $env:GITHUB_ENV - name: Install build dependencies shell: bash -l {0} @@ -194,28 +171,19 @@ jobs: - name: Build wheels env: - CONDA_PREFIX: ${{ env.CONDA_PREFIX }} + CIBW_BUILD: "cp310-* cp311-* cp312-*" CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} - CIBW_BUILD_VERBOSITY: "1" - SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include - SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib + CIBW_BUILD_VERBOSITY: "3" DISTUTILS_USE_SDK: "1" MSSdk: "1" - NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }} - CIBW_ENVIRONMENT: >- - NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" - SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include" - SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib" - CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy + CIBW_BEFORE_BUILD: | + pip install meson meson-python ninja numpy CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" CIBW_TEST_COMMAND: | - python -c "import platform; print('Python version:', platform.python_version())" - python -c "import sys; print('sys.platform:', sys.platform)" - python -c "import quaddtype; print('quaddtype imported successfully')" pip install {package}[test] - pytest {project}\tests -v || (echo "Tests failed" && exit 1) - CIBW_TEST_EXTRAS: "test" + python -m pytest -v {project}/test + CIBW_TEST_EXTRAS: test CIBW_TEST_FAIL_FAST: 1 shell: pwsh run: | @@ -223,7 +191,7 @@ jobs: if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" } working-directory: ./quaddtype - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./quaddtype/wheelhouse/*.whl name: wheels-windows-${{ matrix.architecture }} @@ -232,10 +200,10 @@ jobs: name: Publish to TestPyPI needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/quaddtype-v') steps: - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: dist - name: Publish to TestPyPI @@ -250,14 +218,14 @@ jobs: name: Create Release needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows] runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') + 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@v2 + uses: actions/download-artifact@v4 with: path: artifacts diff --git a/quaddtype/meson.build b/quaddtype/meson.build index 21f68a7d..e7e8dd97 100644 --- a/quaddtype/meson.build +++ b/quaddtype/meson.build @@ -1,72 +1,27 @@ -project('numpy_quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++17', 'b_pie=true']) +project('numpy_quaddtype', 'c', 'cpp', default_options : ['cpp_std=c++20', 'b_pie=true']) py_mod = import('python') py = py_mod.find_installation() +py_dep = py.dependency() c = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') is_windows = build_machine.system() == 'windows' -incdir_numpy = '' if is_windows add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp']) - - conda_env_dir = run_command('cmd', '/c', 'echo %CONDA_PREFIX%', check: true).stdout().strip() - sleef_include_dir = conda_env_dir + '\\Library\\include' - sleef_library_dir = conda_env_dir + '\\Library\\lib' - incdir_numpy = run_command('cmd', '/c', 'echo %NUMPY_INCLUDE_DIR%', check: true).stdout().strip() - - add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) - add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) - - sleef_lib = c.find_library('sleef', dirs: [sleef_library_dir]) - sleefquad_lib = c.find_library('sleefquad', dirs: [sleef_library_dir]) - - sleef_dep = declare_dependency(include_directories: include_directories(sleef_include_dir), - dependencies: [sleef_lib, sleefquad_lib]) -else - # Linux and macOS configuration - - # Get the SLEEF path - sleef_path = run_command('bash', '-c', 'echo $SLEEF_PATH', check: false).stdout().strip() - if sleef_path == '' - sleef_path = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: false).stdout().strip() - endif - - if sleef_path == '' - error('SLEEF_PATH or CONDA_PREFIX environment variable is not set') - endif - - add_project_link_arguments('-L' + sleef_path + '/lib', language: ['c', 'cpp']) - - sleef_include_dir = sleef_path + '/include' - sleef_library_dir = sleef_path + '/lib' - - add_project_arguments('-I' + sleef_include_dir, language: ['c', 'cpp']) - add_project_link_arguments('-L' + sleef_library_dir, language: ['c', 'cpp']) - - sleef_dep = c.find_library('sleef', dirs: [sleef_library_dir]) - sleefquad_dep = c.find_library('sleefquad', dirs: [sleef_library_dir]) endif -if not sleef_dep.found() or (not is_windows and not sleefquad_dep.found()) - error('SLEEF library not found. Please ensure it is installed in your conda environment.') -endif +sleef_dep = [ + c.find_library('sleef', required : true), + c.find_library('sleefquad', required : true) +] -# Try to get NumPy include path from environment variable first -if incdir_numpy == '' - incdir_numpy = run_command(py, - [ - '-c', - 'import numpy; import os; print(os.path.relpath(numpy.get_include()))' - ], - check: false - ).stdout().strip() - - if incdir_numpy == '' - error('NumPy include directory not found. Please set NUMPY_INCLUDE_DIR or ensure NumPy is installed.') - endif -endif +incdir_numpy = run_command(py, + ['-c', 'import numpy; print(numpy.get_include())'], + check : true +).stdout().strip() includes = include_directories( [ @@ -102,10 +57,11 @@ py.install_sources( ) py.extension_module('_quaddtype_main', -srcs, -c_args: ['-g', '-O0', '-lsleef', '-lsleefquad'], -dependencies: [sleef_dep, sleefquad_dep], -install: true, -subdir: 'numpy_quaddtype', -include_directories: includes + srcs, + link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'], + link_language: 'cpp', + dependencies: [sleef_dep, py_dep], + install: true, + subdir: 'numpy_quaddtype', + include_directories: includes ) \ No newline at end of file diff --git a/quaddtype/pyproject.toml b/quaddtype/pyproject.toml index 5e9a142a..30898c72 100644 --- a/quaddtype/pyproject.toml +++ b/quaddtype/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "mesonpy" [project] name = "numpy_quaddtype" description = "Quad (128-bit) float dtype for numpy" -version = "0.0.2" +version = "0.0.1" readme = 'README.md' authors = [{name = "Swayam Singh", email = "singhswayam008@gmail.com"}] requires-python = ">=3.10.0" From 99ed1f8b1446422c0556a91569c31a9713ce5c49 Mon Sep 17 00:00:00 2001 From: swayaminsync Date: Wed, 25 Sep 2024 23:36:39 +0530 Subject: [PATCH 181/182] removed unnecessary env-var --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efb281b1..d0d32495 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - name: Install quaddtype working-directory: quaddtype run: | - export SLEEF_PATH=/usr && LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug" + LDFLAGS="-Wl,-rpath,/usr/lib" python -m pip install . -v --no-build-isolation -Cbuilddir=build -C'compile-args=-v' -Csetup-args="-Dbuildtype=debug" - name: Run quaddtype tests working-directory: quaddtype run: | From f9ced6e28ed6904687dc584a6274a4069b4febe7 Mon Sep 17 00:00:00 2001 From: t-swsingh_microsoft Date: Thu, 26 Sep 2024 13:59:44 +0530 Subject: [PATCH 182/182] win: replacing conda with manual sleef build --- .github/workflows/build_wheels.yml | 64 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 1310da04..dedafe4d 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -5,12 +5,12 @@ on: branches: - main tags: - - "quaddtype-v*" + - 'quaddtype-v*' paths: - - "quaddtype/**" + - 'quaddtype/**' pull_request: paths: - - "quaddtype/**" + - 'quaddtype/**' workflow_dispatch: jobs: @@ -23,16 +23,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ">=3.10.0" + python-version: '>=3.10.0' - name: Install cibuildwheel run: pip install cibuildwheel==2.20.0 - name: Build wheels env: - CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64" + CIBW_BUILD: 'cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64' CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 - CIBW_BUILD_VERBOSITY: "3" + CIBW_BUILD_VERBOSITY: '3' CIBW_BEFORE_ALL: | git clone https://github.com/shibatch/sleef.git cd sleef @@ -49,7 +49,7 @@ jobs: CIBW_TEST_COMMAND: | pip install {package}[test] pytest {project}/tests - CIBW_TEST_EXTRAS: "test" + CIBW_TEST_EXTRAS: 'test' run: | python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype @@ -72,11 +72,11 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: '3.10' - name: Install SLEEF env: - MACOSX_DEPLOYMENT_TARGET: "11.0" + MACOSX_DEPLOYMENT_TARGET: '11.0' run: | git clone https://github.com/shibatch/sleef.git cd sleef @@ -94,9 +94,9 @@ jobs: - name: Build wheels env: - CIBW_BUILD: "cp310-* cp311-* cp312-*" + CIBW_BUILD: 'cp310-* cp311-* cp312-*' CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }} - CIBW_BUILD_VERBOSITY: "1" + CIBW_BUILD_VERBOSITY: '1' CIBW_ENVIRONMENT: > MACOSX_DEPLOYMENT_TARGET="11.0" DYLD_LIBRARY_PATH="/usr/local/lib:$DYLD_LIBRARY_PATH" @@ -108,7 +108,7 @@ jobs: CIBW_TEST_COMMAND: | pip install {package}[test] pytest {project}/tests - CIBW_TEST_EXTRAS: "test" + CIBW_TEST_EXTRAS: 'test' run: | python -m cibuildwheel --output-dir wheelhouse working-directory: ./quaddtype @@ -136,29 +136,27 @@ jobs: - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: '3.10' architecture: ${{ matrix.architecture }} - - name: Install Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - auto-update-conda: true - python-version: "3.10" - architecture: ${{ matrix.architecture }} + - name: Install CMake + uses: lukka/get-cmake@latest - - name: Install SLEEF and other dependencies - shell: bash -l {0} + - name: Clone and Build SLEEF + shell: pwsh run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -y sleef numpy + git clone 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 --install build --prefix "C:/sleef" --config Release - name: Setup build environment shell: pwsh run: | - $env:INCLUDE += ";$env:CONDA_PREFIX\Library\include" - $env:LIB += ";$env:CONDA_PREFIX\Library\lib" - $env:PATH = "$env:CONDA_PREFIX\Library\bin;$env:PATH" + $env:INCLUDE += ";C:\sleef\include" + $env:LIB += ";C:\sleef\lib" + $env:PATH = "C:\sleef\bin;$env:PATH" echo "INCLUDE=$env:INCLUDE" >> $env:GITHUB_ENV echo "LIB=$env:LIB" >> $env:GITHUB_ENV echo "PATH=$env:PATH" >> $env:GITHUB_ENV @@ -171,15 +169,15 @@ jobs: - name: Build wheels env: - CIBW_BUILD: "cp310-* cp311-* cp312-*" - CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*" + CIBW_BUILD: 'cp310-* cp311-* cp312-*' + CIBW_SKIP: 'pp* cp36-* cp37-* cp38-* cp39-* cp313-*' CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }} - CIBW_BUILD_VERBOSITY: "3" - DISTUTILS_USE_SDK: "1" - MSSdk: "1" + CIBW_BUILD_VERBOSITY: '3' + DISTUTILS_USE_SDK: '1' + MSSdk: '1' CIBW_BEFORE_BUILD: | pip install meson meson-python ninja numpy - CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" + CIBW_REPAIR_WHEEL_COMMAND: 'delvewheel repair -w {dest_dir} {wheel} --add-path C:\sleef\bin' CIBW_TEST_COMMAND: | pip install {package}[test] python -m pytest -v {project}/test