Skip to content

Commit 1575ac4

Browse files
committed
packaging quaddtype
1 parent cf6cf91 commit 1575ac4

File tree

4 files changed

+150
-4
lines changed

4 files changed

+150
-4
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build quaddtype wheels and release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
11+
jobs:
12+
build_wheels:
13+
name: Build wheels on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: [ubuntu-20.04, windows-2019, macos-11]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: '3.10'
26+
27+
- name: Set up Conda
28+
uses: conda-incubator/setup-miniconda@v2
29+
with:
30+
auto-update-conda: true
31+
python-version: '3.10'
32+
channels: conda-forge,defaults
33+
channel-priority: strict
34+
35+
- name: Install SLEEF and other dependencies
36+
shell: bash -l {0}
37+
run: |
38+
conda install -y sleef numpy meson meson-python patchelf wheel
39+
40+
- name: Install cibuildwheel
41+
run: python -m pip install cibuildwheel==2.11.2
42+
43+
- name: Build wheels
44+
shell: bash -l {0}
45+
run: |
46+
export LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH
47+
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
48+
export CPATH=$CONDA_PREFIX/include:$CPATH
49+
python -m cibuildwheel --output-dir wheelhouse
50+
env:
51+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
52+
CIBW_BUILD_VERBOSITY: "1"
53+
CIBW_ENVIRONMENT: >
54+
LIBRARY_PATH=$CONDA_PREFIX/lib:$LIBRARY_PATH
55+
LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
56+
CPATH=$CONDA_PREFIX/include:$CPATH
57+
working-directory: ./quaddtype
58+
59+
- uses: actions/upload-artifact@v2
60+
with:
61+
path: ./quaddtype/wheelhouse/*.whl
62+
name: wheels
63+
64+
create_release:
65+
name: Create Release
66+
needs: build_wheels
67+
runs-on: ubuntu-latest
68+
if: startsWith(github.ref, 'refs/tags/')
69+
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v2
73+
74+
- name: Download all workflow run artifacts
75+
uses: actions/download-artifact@v2
76+
with:
77+
path: artifacts
78+
79+
- name: Create Release
80+
id: create_release
81+
uses: actions/create-release@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
with:
85+
tag_name: ${{ github.ref }}
86+
release_name: Release ${{ github.ref }}
87+
draft: false
88+
prerelease: false
89+
90+
- name: Upload Release Assets
91+
uses: actions/upload-release-asset@v1
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
with:
95+
upload_url: ${{ steps.create_release.outputs.upload_url }}
96+
asset_path: ./artifacts/wheels/*.whl
97+
asset_name: quaddtype-${{ github.ref_name }}.whl
98+
asset_content_type: application/zip

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ compile_commands.json
133133

134134
.ruff-cache/
135135
.asv
136-
.vscode/
136+
.vscode/
137+
*.whl

quaddtype/meson.build

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@ py = py_mod.find_installation()
55

66
c = meson.get_compiler('c')
77

8-
sleef_dep = c.find_library('sleef')
9-
sleefquad_dep = c.find_library('sleefquad')
8+
# Get the conda prefix
9+
conda_prefix = run_command('bash', '-c', 'echo $CONDA_PREFIX', check: true).stdout().strip()
10+
11+
# Add conda lib directory to library path
12+
add_project_link_arguments('-L' + conda_prefix + '/lib', language: ['c', 'cpp'])
13+
14+
sleef_dep = c.find_library('sleef', dirs: [conda_prefix + '/lib'])
15+
sleefquad_dep = c.find_library('sleefquad', dirs: [conda_prefix + '/lib'])
16+
17+
if not sleef_dep.found() or not sleefquad_dep.found()
18+
error('SLEEF library not found. Please ensure it is installed in your conda environment\nconda install sleef.')
19+
endif
1020

1121
incdir_numpy = run_command(py,
1222
[

quaddtype/pyproject.toml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name = "quaddtype"
1313
description = "Quad (128-bit) float dtype for numpy"
1414
version = "0.0.1"
1515
readme = 'README.md'
16-
author = "Swayam Singh"
16+
authors = [{name = "Swayam Singh", email = "[email protected]"}]
1717
requires-python = ">=3.9.0"
1818
dependencies = [
1919
"numpy"
@@ -23,3 +23,40 @@ dependencies = [
2323
test = [
2424
"pytest",
2525
]
26+
27+
[tool.cibuildwheel]
28+
archs = ["auto64"]
29+
skip = ["*-musllinux*", "pp*", "cp36-*", "cp37-*", "cp38-*"]
30+
environment = { PATH = "$PATH:/usr/share/miniconda3/bin" }
31+
32+
[tool.cibuildwheel.linux]
33+
before-all = """
34+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
35+
bash miniconda.sh -b -p /usr/share/miniconda3
36+
export PATH="/usr/share/miniconda3/bin:$PATH"
37+
conda config --add channels conda-forge
38+
conda config --set channel_priority strict
39+
conda install -y sleef
40+
"""
41+
42+
[tool.cibuildwheel.macos]
43+
before-all = """
44+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
45+
bash miniconda.sh -b -p $HOME/miniconda3
46+
export PATH="$HOME/miniconda3/bin:$PATH"
47+
conda config --add channels conda-forge
48+
conda config --set channel_priority strict
49+
conda install -y sleef
50+
"""
51+
52+
[tool.cibuildwheel.windows]
53+
before-all = """
54+
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'miniconda.exe')"
55+
start /wait "" miniconda.exe /S /D=C:\\Miniconda3
56+
set PATH=C:\\Miniconda3;C:\\Miniconda3\\Scripts;%PATH%
57+
conda config --add channels conda-forge
58+
conda config --set channel_priority strict
59+
conda install -y sleef
60+
"""
61+
before-build = "pip install delvewheel"
62+
repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}"

0 commit comments

Comments
 (0)