Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cibuildwheel #2

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ jobs:
with:
python-version: 3.9

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: |
python3 -m pip install coffe
python3 -m pip install -r pip-requirements-dev.txt
python3 -m pip install cibuildwheel
export SETUPTOOLS_SCM_PRETEND_VERSION='3.0.1'
export CIBW_ENVIRONMENT_PASS_LINUX='SETUPTOOLS_SCM_PRETEND_VERSION'
export CIBW_TEST_COMMAND='true'
CIBW_BUILD='cp39-manylinux_x86_64' python3 -m cibuildwheel --platform linux
# install with optional dependencies
find wheelhouse/ -name "*.whl" -exec python3 -m pip install '{}[docs]' \;

# Build the site
- name: Build the site
run: |
rm -fr coffe/__init__.py
sh generate_docs.sh
bash scripts/generate_docs.sh

# If we've pushed to master, push the book's HTML to github-pages
- if: ${{ github.ref == 'refs/heads/master' }}
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build

on:
pull_request:
push:
branches:
- master
workflow_dispatch:
inputs:
version:
description: 'The version of COFFE to release'

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13]

steps:
- uses: actions/checkout@v4

- name: Setup all external dependencies
if: runner.os == 'macOS'
run: |
brew install fftw gsl cuba automake jq
if [ "$(uname -m)" = 'arm64' ]
then
echo "BREW_PREFIX=/opt/homebrew/Cellar/" >> "$GITHUB_ENV"
else
echo "BREW_PREFIX=/usr/local/Cellar/" >> "$GITHUB_ENV"
fi
echo "GSL_VERSION=$(brew info --json gsl | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV"
echo "FFTW_VERSION=$(brew info --json fftw | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV"
echo "CUBA_VERSION=$(brew info --json cuba | jq -r '.[0].installed[0].version')" >> "$GITHUB_ENV"

# Used to host cibuildwheel
- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.5

# if we're not doing a release version (manual!), only build one python version
- name: Setup versions
if: ${{ ! (github.event_name == 'workflow_dispatch' && github.event.inputs.version) }}
run: |
echo "CIBW_BUILD=cp311-*" >> "$GITHUB_ENV"
# pretend version so setuptools doesn't fail
echo "SETUPTOOLS_SCM_PRETEND_VERSION=0.1.0" >> "$GITHUB_ENV"

- name: SCM
if: github.event_name == 'workflow_dispatch' && github.event.inputs.version
run: echo "SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.event.input.version }}" >> "$GITHUB_ENV"

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
# to supply options, put them in 'env', like:
env:
# we skip tests in CI to save time
CIBW_TEST_COMMAND: 'true'
CIBW_ENVIRONMENT_PASS_LINUX: 'SETUPTOOLS_SCM_PRETEND_VERSION'
CIBW_BEFORE_ALL_MACOS: >
bash scripts/install_other.sh class
CIBW_ENVIRONMENT_MACOS: >
CFLAGS="-I${BREW_PREFIX}/gsl/${GSL_VERSION}/include -I${BREW_PREFIX}/fftw/${FFTW_VERSION}/include -I${BREW_PREFIX}/cuba/${CUBA_VERSION}/include -I/opt/class_public/include ${CFLAGS}"
LDFLAGS="-L${BREW_PREFIX}/gsl/${GSL_VERSION}/lib -L${BREW_PREFIX}/fftw/${FFTW_VERSION}/lib -L${BREW_PREFIX}/cuba/${CUBA_VERSION}/lib -L/opt/class_public/lib ${LDFLAGS}"

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
8 changes: 0 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
[submodule "class_public"]
path = class_public
url = https://github.com/JCGoran/class_public
branch = feature/conda
[submodule "libcuba"]
path = libcuba
url = https://github.com/JCGoran/libcuba
branch = master
57 changes: 0 additions & 57 deletions Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions build_sdist.sh

This file was deleted.

11 changes: 0 additions & 11 deletions build_wheels_linux.sh

This file was deleted.

15 changes: 0 additions & 15 deletions build_wheels_linux_manylinux2014.sh

This file was deleted.

9 changes: 0 additions & 9 deletions build_wheels_linux_manylinux_2_24.sh

This file was deleted.

8 changes: 0 additions & 8 deletions build_wheels_linux_manylinux_2_28.sh

This file was deleted.

1 change: 0 additions & 1 deletion class_public
Submodule class_public deleted from 8efeba
9 changes: 0 additions & 9 deletions generate_docs.sh

This file was deleted.

20 changes: 0 additions & 20 deletions install

This file was deleted.

52 changes: 0 additions & 52 deletions install_other.sh

This file was deleted.

1 change: 0 additions & 1 deletion libcuba
Submodule libcuba deleted from 687b7f
12 changes: 0 additions & 12 deletions pip-requirements-dev.txt

This file was deleted.

1 change: 0 additions & 1 deletion pip-requirements.txt

This file was deleted.

33 changes: 27 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "coffe"
version = "3.0.0"
dynamic = ["version"]
description = "Python wrapper for the COrrelation Function Full-sky Estimator code"
readme = "README.md"
requires-python = ">=3.7"
Expand All @@ -25,6 +25,18 @@ classifiers = [
dependencies = [
"numpy>=1.19.5",
]
optional-dependencies.test = ["pytest", "pandas", "scipy"]
optional-dependencies.docs = ["pdoc"]
optional-dependencies.dev = [
"pylint",
"mypy",
"isort",
"reorder-python-imports",
"autoimport",
"black",
"cibuildwheel",
"twine",
]

[project.scripts]
coffe-cli = "coffe.__main__:main"
Expand All @@ -34,12 +46,21 @@ repository = "https://github.com/JCGoran/coffe"

[tool.cibuildwheel]
skip = ["cp36-*", "pp*", "pypy*", "*musllinux*"]

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
test-extras = ["test", "docs"]
test-command = [
"pytest {package}/tests",
"bash {package}/scripts/generate_docs.sh",
]

[tool.cibuildwheel.linux]
archs = ["x86_64"]
before-all = [
# install CUBA, FFTW, GSL, and CLASS
"bash scripts/install_other.sh gsl cuba class fftw",
]
environment = { LDFLAGS="-L/opt/cuba/lib -L/opt/class_public/lib ${LDFLAGS}", CFLAGS="-I/opt/cuba/include -I/opt/class_public/include ${CFLAGS}" }


[build-system]
requires = ["setuptools", "wheel", "Cython"]
requires = ["setuptools", "wheel", "Cython<3", "setuptools_scm"]

[tool.setuptools_scm]
10 changes: 0 additions & 10 deletions reinstall.sh

This file was deleted.

Loading
Loading