Skip to content

Update build system #78

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

Merged
merged 5 commits into from
Mar 31, 2025
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand All @@ -30,7 +30,7 @@ jobs:
shell: bash
run: |
python -m pip install wheel
python -m pip install --upgrade pip "conan<2"
python -m pip install --upgrade pip "conan"
cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
Expand All @@ -40,7 +40,7 @@ jobs:
-DCMAKE_C_COMPILER=gcc
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
-Dpython=False
-Dconan_deps=True
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake

- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
158 changes: 96 additions & 62 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,96 +9,130 @@ name: Python Build
pull_request:

jobs:
from-sdist:
name: python source distribution
from_uv:
name: python uv installation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.8

- name: Install build packages and pytest
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install "conan<2" scikit-build pytest cython numpy>=2

- name: Create sdist
run: python setup.py sdist
version: "0.6.5"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install pyssht
run: "pip install dist/pyssht-*.tar.gz"
run: uv sync --all-extras --dev

- name: run pytest
run: pytest tests/test_pyssht.py
run: uv run pytest

from_sdist:
name: python source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.5"

- uses: actions/upload-artifact@v2
if: ${{ startsWith(github.ref, 'refs/tags') }}
- name: "Set up Python"
uses: actions/setup-python@v5
with:
path: ./dist/*.tar.gz
name: source-distribution
python-version-file: "pyproject.toml"

- name: Build sdist
run: uv build --sdist

- name: create venv
run: uv venv

- name: install wheel
run: "uv pip install dist/pyssht-*.tar.gz"

- name: run pytests
run: uv pip install pytest && uv run pytest

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
python-version: [3.8]
name: Build wheels
runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup environment
run: |
python -m pip install --upgrade pip wheel
python -m pip install "conan<2" pytest ducc0
conan profile new default --detect
version: "0.6.5"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Build wheels
run: pip wheel . --use-pep517 --no-deps -w dist
run: uv build --wheel

- name: create venv
run: uv venv

- name: install wheel
run: "pip install dist/*.whl"
run: "uv pip install dist/*.whl"

- name: run pytests
run: pytest tests
run: uv pip install pytest && uv run pytest

- uses: actions/upload-artifact@v2
if: ${{ startsWith(github.ref, 'refs/tags') }}
publish_wheels:
name: Build wheels and publish on ${{ matrix.os }}
if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-14]
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
path: ./dist/*.whl
name: wheel-${{matrix.os}}-${{matrix.python-version}}
version: "0.6.5"

publication:
name: publish to pypi
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *musllinux*"
CIBW_BUILD_FRONTEND: "build[uv]"

- name: Publish distribution 📦 to Test PyPI
if: ${{ github.ref != 'refs/tags/v1.5.3' }}
run: "uv publish --publish-url https://test.pypi.org/legacy/ wheelhouse/*.whl"

- name: Publish distribution 📦 to PyPI
if: ${{ github.ref == 'refs/tags/v1.5.3' }}
run: "uv publish wheelhouse/*.whl"

publish_sdist:
name: Build sdist and publish on ubuntu
if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
needs: [build_wheels, from-sdist]
permissions:
id-token: write
steps:
- name: Download wheels and sdist
uses: actions/download-artifact@v2
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.5"

- name: Move wheels and source distribution to dist/
run: |
mkdir -p dist
mv source-distribution/*.tar.gz wheel-*/*.whl dist
- name: Build sdist
run: uv build --sdist

- name: Publish distribution 📦 to Test PyPI
if: ${{ github.ref != 'refs/tags/v1.5.2' }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
if: ${{ github.ref != 'refs/tags/v1.5.3' }}
run: "uv publish --publish-url https://test.pypi.org/legacy/ dist/*.tar.gz"

- name: Publish distribution 📦 to PyPI
if: ${{ github.ref == 'refs/tags/v1.5.2' }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_TOKEN }}
if: ${{ github.ref == 'refs/tags/v1.5.3' }}
run: "uv publish dist/*.tar.gz"
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ MANIFEST
dist/
compile_commands.json
.clangd/
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv
devenv.nix
.envrc
devenv.yaml
devenv.lock

# pre-commit
.pre-commit-config.yaml
33 changes: 16 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
cmake_minimum_required(VERSION 3.12)

cmake_minimum_required(VERSION 3.24)
if(NOT SKBUILD_PROJECT_NAME)
set(project_name Ssht)
else()
set(project_name ${SKBUILD_PROJECT_NAME})
endif()
project(
Ssht
VERSION "1.5.2"
${project_name}
VERSION "1.5.3"
DESCRIPTION "Fast and exact spin spherical harmonic transforms"
HOMEPAGE_URL "http://astro-informatics.github.io/ssht/"
LANGUAGES C)

option(conan_deps "Download dependencies using conan" OFF)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(CTest)
if(conan_deps OR CONAN_EDITABLE_MODE)
include("${PROJECT_SOURCE_DIR}/cmake/conan_dependencies.cmake")
endif()
if(EXISTS "${PROJECT_BINARY_DIR}/conan_paths.cmake")
include("${PROJECT_BINARY_DIR}/conan_paths.cmake")
elseif(EXISTS "${PROJECT_BINARY_DIR}/FindFFTW3.cmake")

if(EXISTS "${PROJECT_BINARY_DIR}/FindFFTW3.cmake")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_BINARY_DIR}")
else()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
Expand All @@ -33,16 +31,17 @@ if(BUILD_TESTING)
endif()

if(SKBUILD)
find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)
find_package(NumPy REQUIRED)
find_package(
Python
COMPONENTS Interpreter Development.Module NumPy
REQUIRED)
add_subdirectory(src/pyssht)
elseif(NOT CONAN_EXPORTED)
else()
include("${PROJECT_SOURCE_DIR}/cmake/exporting.cmake")
endif()

# only run documentation if this is not a sub-project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT SKBUILD)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C "YES")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Then **SSHT** can be compiled with:

```bash
git clone https://github.com/astro-informatics/ssht.git
mkdir ssht/build && cd ssht/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -Dconan_deps=True ..
make
make install
cmake -B ./build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
cmake --build build
ctest --test-dir build
cmake --install build --install-prefix=/usr/local
```

The above will also download [FFTW](http://www.fftw.org/), if necessary.
Expand Down
8 changes: 4 additions & 4 deletions cmake/FindFFTW3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ find_package_handle_standard_args(
VERSION_VAR FFTW3_VERSION_STRING
HANDLE_COMPONENTS)

add_library(FFTW3::FFTW3 INTERFACE IMPORTED)
target_link_libraries(FFTW3::FFTW3 INTERFACE ${FFTW3_DOUBLE_SERIAL_LIBRARY})
target_include_directories(FFTW3::FFTW3 INTERFACE ${FFTW3_INCLUDE_DIRS})
target_compile_definitions(FFTW3::FFTW3 INTERFACE ${FFTW3_DEFINITIONS})
add_library(fftw::fftw INTERFACE IMPORTED)
target_link_libraries(fftw::fftw INTERFACE ${FFTW3_DOUBLE_SERIAL_LIBRARY})
target_include_directories(fftw::fftw INTERFACE ${FFTW3_INCLUDE_DIRS})
target_compile_definitions(fftw::fftw INTERFACE ${FFTW3_DEFINITIONS})
23 changes: 0 additions & 23 deletions cmake/conan_dependencies.cmake

This file was deleted.

Loading
Loading