Skip to content

Commit 10704de

Browse files
authored
Merge pull request #78 from astro-informatics/update-conan
Update build system
2 parents 17a7f72 + 2aae1b9 commit 10704de

19 files changed

+1560
-282
lines changed

.github/workflows/cmake.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
python-version: [3.8]
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323

2424
- name: Set up Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v2
@@ -30,7 +30,7 @@ jobs:
3030
shell: bash
3131
run: |
3232
python -m pip install wheel
33-
python -m pip install --upgrade pip "conan<2"
33+
python -m pip install --upgrade pip "conan"
3434
cmake -E make_directory ${{runner.workspace}}/build
3535
3636
- name: Configure CMake
@@ -40,7 +40,7 @@ jobs:
4040
-DCMAKE_C_COMPILER=gcc
4141
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
4242
-Dpython=False
43-
-Dconan_deps=True
43+
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
4444
4545
- name: Build
4646
working-directory: ${{runner.workspace}}/build

.github/workflows/python.yml

+96-62
Original file line numberDiff line numberDiff line change
@@ -9,96 +9,130 @@ name: Python Build
99
pull_request:
1010

1111
jobs:
12-
from-sdist:
13-
name: python source distribution
12+
from_uv:
13+
name: python uv installation
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python 3.8
18-
uses: actions/setup-python@v2
16+
- uses: actions/checkout@v4
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v5
1919
with:
20-
python-version: 3.8
21-
22-
- name: Install build packages and pytest
23-
run: |
24-
python -m pip install --upgrade pip wheel setuptools
25-
python -m pip install "conan<2" scikit-build pytest cython numpy>=2
26-
27-
- name: Create sdist
28-
run: python setup.py sdist
20+
version: "0.6.5"
21+
- name: "Set up Python"
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version-file: "pyproject.toml"
2925

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

3329
- name: run pytest
34-
run: pytest tests/test_pyssht.py
30+
run: uv run pytest
31+
32+
from_sdist:
33+
name: python source distribution
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
39+
with:
40+
version: "0.6.5"
3541

36-
- uses: actions/upload-artifact@v2
37-
if: ${{ startsWith(github.ref, 'refs/tags') }}
42+
- name: "Set up Python"
43+
uses: actions/setup-python@v5
3844
with:
39-
path: ./dist/*.tar.gz
40-
name: source-distribution
45+
python-version-file: "pyproject.toml"
46+
47+
- name: Build sdist
48+
run: uv build --sdist
49+
50+
- name: create venv
51+
run: uv venv
52+
53+
- name: install wheel
54+
run: "uv pip install dist/pyssht-*.tar.gz"
55+
56+
- name: run pytests
57+
run: uv pip install pytest && uv run pytest
4158

4259
build_wheels:
43-
name: Build wheels on ${{ matrix.os }}
44-
runs-on: ${{ matrix.os }}
45-
strategy:
46-
matrix:
47-
os: [macos-latest]
48-
python-version: [3.8]
60+
name: Build wheels
61+
runs-on: macos-latest
4962

5063
steps:
51-
- uses: actions/checkout@v2
52-
53-
- uses: actions/setup-python@v2
54-
name: Install Python
64+
- uses: actions/checkout@v4
65+
- name: Install uv
66+
uses: astral-sh/setup-uv@v5
5567
with:
56-
python-version: ${{ matrix.python-version }}
57-
58-
- name: Setup environment
59-
run: |
60-
python -m pip install --upgrade pip wheel
61-
python -m pip install "conan<2" pytest ducc0
62-
conan profile new default --detect
68+
version: "0.6.5"
69+
- name: "Set up Python"
70+
uses: actions/setup-python@v5
71+
with:
72+
python-version-file: "pyproject.toml"
6373

6474
- name: Build wheels
65-
run: pip wheel . --use-pep517 --no-deps -w dist
75+
run: uv build --wheel
76+
77+
- name: create venv
78+
run: uv venv
6679

6780
- name: install wheel
68-
run: "pip install dist/*.whl"
81+
run: "uv pip install dist/*.whl"
6982

7083
- name: run pytests
71-
run: pytest tests
84+
run: uv pip install pytest && uv run pytest
7285

73-
- uses: actions/upload-artifact@v2
74-
if: ${{ startsWith(github.ref, 'refs/tags') }}
86+
publish_wheels:
87+
name: Build wheels and publish on ${{ matrix.os }}
88+
if: ${{ startsWith(github.ref, 'refs/tags') }}
89+
runs-on: ${{ matrix.os }}
90+
strategy:
91+
matrix:
92+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-14]
93+
permissions:
94+
id-token: write
95+
steps:
96+
- uses: actions/checkout@v4
97+
- name: Install uv
98+
uses: astral-sh/setup-uv@v5
7599
with:
76-
path: ./dist/*.whl
77-
name: wheel-${{matrix.os}}-${{matrix.python-version}}
100+
version: "0.6.5"
78101

79-
publication:
80-
name: publish to pypi
102+
- name: Build wheels
103+
uses: pypa/[email protected]
104+
env:
105+
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *musllinux*"
106+
CIBW_BUILD_FRONTEND: "build[uv]"
107+
108+
- name: Publish distribution 📦 to Test PyPI
109+
if: ${{ github.ref != 'refs/tags/v1.5.3' }}
110+
run: "uv publish --publish-url https://test.pypi.org/legacy/ wheelhouse/*.whl"
111+
112+
- name: Publish distribution 📦 to PyPI
113+
if: ${{ github.ref == 'refs/tags/v1.5.3' }}
114+
run: "uv publish wheelhouse/*.whl"
115+
116+
publish_sdist:
117+
name: Build sdist and publish on ubuntu
81118
if: ${{ startsWith(github.ref, 'refs/tags') }}
82119
runs-on: ubuntu-latest
83-
needs: [build_wheels, from-sdist]
120+
permissions:
121+
id-token: write
84122
steps:
85-
- name: Download wheels and sdist
86-
uses: actions/download-artifact@v2
123+
- uses: actions/checkout@v4
124+
- name: Install uv
125+
uses: astral-sh/setup-uv@v5
126+
with:
127+
version: "0.6.5"
87128

88-
- name: Move wheels and source distribution to dist/
89-
run: |
90-
mkdir -p dist
91-
mv source-distribution/*.tar.gz wheel-*/*.whl dist
129+
- name: Build sdist
130+
run: uv build --sdist
92131

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

100136
- name: Publish distribution 📦 to PyPI
101-
if: ${{ github.ref == 'refs/tags/v1.5.2' }}
102-
uses: pypa/gh-action-pypi-publish@master
103-
with:
104-
password: ${{ secrets.PYPI_TOKEN }}
137+
if: ${{ github.ref == 'refs/tags/v1.5.3' }}
138+
run: "uv publish dist/*.tar.gz"

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ MANIFEST
1919
dist/
2020
compile_commands.json
2121
.clangd/
22+
# Devenv
23+
.devenv*
24+
devenv.local.nix
25+
26+
# direnv
27+
.direnv
28+
devenv.nix
29+
.envrc
30+
devenv.yaml
31+
devenv.lock
32+
33+
# pre-commit
34+
.pre-commit-config.yaml

CMakeLists.txt

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
cmake_minimum_required(VERSION 3.12)
2-
1+
cmake_minimum_required(VERSION 3.24)
2+
if(NOT SKBUILD_PROJECT_NAME)
3+
set(project_name Ssht)
4+
else()
5+
set(project_name ${SKBUILD_PROJECT_NAME})
6+
endif()
37
project(
4-
Ssht
5-
VERSION "1.5.2"
8+
${project_name}
9+
VERSION "1.5.3"
610
DESCRIPTION "Fast and exact spin spherical harmonic transforms"
711
HOMEPAGE_URL "http://astro-informatics.github.io/ssht/"
812
LANGUAGES C)
913

10-
option(conan_deps "Download dependencies using conan" OFF)
11-
1214
if(NOT CMAKE_BUILD_TYPE)
1315
set(CMAKE_BUILD_TYPE Debug)
1416
endif()
1517
include(CTest)
16-
if(conan_deps OR CONAN_EDITABLE_MODE)
17-
include("${PROJECT_SOURCE_DIR}/cmake/conan_dependencies.cmake")
18-
endif()
19-
if(EXISTS "${PROJECT_BINARY_DIR}/conan_paths.cmake")
20-
include("${PROJECT_BINARY_DIR}/conan_paths.cmake")
21-
elseif(EXISTS "${PROJECT_BINARY_DIR}/FindFFTW3.cmake")
18+
19+
if(EXISTS "${PROJECT_BINARY_DIR}/FindFFTW3.cmake")
2220
list(APPEND CMAKE_MODULE_PATH "${PROJECT_BINARY_DIR}")
2321
else()
2422
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@@ -33,16 +31,17 @@ if(BUILD_TESTING)
3331
endif()
3432

3533
if(SKBUILD)
36-
find_package(PythonExtensions REQUIRED)
37-
find_package(Cython REQUIRED)
38-
find_package(NumPy REQUIRED)
34+
find_package(
35+
Python
36+
COMPONENTS Interpreter Development.Module NumPy
37+
REQUIRED)
3938
add_subdirectory(src/pyssht)
40-
elseif(NOT CONAN_EXPORTED)
39+
else()
4140
include("${PROJECT_SOURCE_DIR}/cmake/exporting.cmake")
4241
endif()
4342

4443
# only run documentation if this is not a sub-project
45-
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
44+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT SKBUILD)
4645
find_package(Doxygen)
4746
if(DOXYGEN_FOUND)
4847
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C "YES")

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ Then **SSHT** can be compiled with:
4747

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

5656
The above will also download [FFTW](http://www.fftw.org/), if necessary.

cmake/FindFFTW3.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ find_package_handle_standard_args(
243243
VERSION_VAR FFTW3_VERSION_STRING
244244
HANDLE_COMPONENTS)
245245

246-
add_library(FFTW3::FFTW3 INTERFACE IMPORTED)
247-
target_link_libraries(FFTW3::FFTW3 INTERFACE ${FFTW3_DOUBLE_SERIAL_LIBRARY})
248-
target_include_directories(FFTW3::FFTW3 INTERFACE ${FFTW3_INCLUDE_DIRS})
249-
target_compile_definitions(FFTW3::FFTW3 INTERFACE ${FFTW3_DEFINITIONS})
246+
add_library(fftw::fftw INTERFACE IMPORTED)
247+
target_link_libraries(fftw::fftw INTERFACE ${FFTW3_DOUBLE_SERIAL_LIBRARY})
248+
target_include_directories(fftw::fftw INTERFACE ${FFTW3_INCLUDE_DIRS})
249+
target_compile_definitions(fftw::fftw INTERFACE ${FFTW3_DEFINITIONS})

cmake/conan_dependencies.cmake

-23
This file was deleted.

0 commit comments

Comments
 (0)