Skip to content

Commit

Permalink
packaging quaddtype
Browse files Browse the repository at this point in the history
  • Loading branch information
SwayamInSync committed Aug 23, 2024
1 parent cf6cf91 commit 1575ac4
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 4 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/build_wheels_and_release.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ compile_commands.json

.ruff-cache/
.asv
.vscode/
.vscode/
*.whl
14 changes: 12 additions & 2 deletions quaddtype/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand Down
39 changes: 38 additions & 1 deletion quaddtype/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"}]
requires-python = ">=3.9.0"
dependencies = [
"numpy"
Expand All @@ -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}"

0 comments on commit 1575ac4

Please sign in to comment.