Skip to content

Commit

Permalink
Trying pyproject.toml and scikit-build-core (#378)
Browse files Browse the repository at this point in the history
* trying a scikit-build-core setup

* trying things

* vendor FindCython

* fix build

* remove unused

* cython tests working

* fix lint action

* coverage fix

* drop annotation stuff for now, because i can't get it working

* book building

* all target

* try again

* don't install all

* numpy!

* pip install h3.tar.gz[test]

* drop wheel builds for 3.6 and 3.7

* move coverage config to pyproject.toml

* remove requirements-dev.txt

* remove cmake from the build system requirements

* single sourcing the version number in _version.py

* i think scikitbuild-core doesn't work with dynamic = ['version']. try something else

* uber's

* alphabetical files in cmakelists.txt

* tidy up files in the sdist

* move pytest config to pyproject.toml

* CIBW_TEST_COMMAND: pytest

* CIBW_TEST_COMMAND: pytest {project}/tests

* CIBW_TEST_REQUIRES: pytest pytest-cov numpy

* get better coverage on the testing code

* fix api reference link (#385)

* Added Bindings for Vertex-Related Functions (#388)

* Update CHANGELOG.md

* Update h3lib.pxd

* Update latlng.pxd

* Update latlng.pyx

* Update util.pxd

* Update util.pyx

* Update _version.py

* Update __init__.py

* Update __init__.py

* Update test_h3.py

* Update __init__.py

* Update test_h3.py

* Update CHANGELOG.md

* Update __init__.py

* Update test_h3.py

* Update _version.py

* Update test_h3.py

* Update __init__.py

* Update CMakeLists.txt

* Update latlng.pxd

* Update latlng.pyx

* Create vertex.pxd

* Create vertex.pyx

* Update __init__.py

* Update test_h3.py

* Update __init__.py

* Update api_quick.md

* Bump actions/download-artifact from 4.1.4 to 4.1.7 in /.github/workflows (#392)

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.4 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v4.1.4...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* prep for v4.0.0b6 release (#394)

* alphabetical files in cmakelists.txt

* single

* test with numpy>=2

* drop lower bound on numpy version

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Isaac Brodsky <[email protected]>
Co-authored-by: Pieter Provoost <[email protected]>
Co-authored-by: Shiran Yuan <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 4, 2024
1 parent cec946a commit 65c3d9e
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 206 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install -r requirements.in
pip install -r requirements-dev.txt
pip install .[all]
- name: Build the book
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/coverage-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Install from source
run: |
pip install --upgrade pip setuptools wheel
pip install .[all]
pip install .[test]
- name: Lint
run: flake8 src/h3 setup.py tests
run: flake8 src/h3 tests

- name: Pylint
# As a test for visibility of API bindings, we want to ensure that pylint has no
Expand All @@ -35,24 +35,13 @@ jobs:

- name: Coverage
run: |
pip install Cython
cythonize -i tests/test_cython/cython_example.pyx
pytest --cov=h3 --full-trace --cov-report=xml
pip install cython
cythonize tests/test_cython/cython_example.pyx
pytest --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
file: ./coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Copy Cython annotations to project dir
run: |
mkdir annotations
cp _skbuild/*/cmake-build/src/h3/_cy/*.html ./annotations
- name: Upload artifacts to GitHub
uses: actions/[email protected]
with:
name: annotations
path: ./annotations
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
- name: Install from source
run: |
pip install --upgrade pip setuptools wheel
pip install .[all]
pip install .[test]
- name: Tests
run: |
pip install Cython
cythonize -i tests/test_cython/cython_example.pyx
pytest tests --cov=h3 --full-trace
pip install cython
cythonize tests/test_cython/cython_example.pyx
pytest
19 changes: 3 additions & 16 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ jobs:
- name: Install from sdist
run: |
pip install --upgrade pip setuptools wheel
pip install pytest
cp dist/h3-*.tar.gz h3.tar.gz
pip install h3.tar.gz[all]
pip install h3.tar.gz[test]
- name: Test sdist
run: pytest --cov=h3 --full-trace
run: pytest

- name: Upload artifacts to GitHub
uses: actions/[email protected]
Expand Down Expand Up @@ -76,12 +75,6 @@ jobs:
build: 'cp*-manylinux_x86_64'
name: Linux Intel glibc 64-bit

- os: ubuntu-22.04
build: 'cp36-musllinux_x86_64'
name: Linux Intel musl 64-bit 3.6
- os: ubuntu-22.04
build: 'cp37-musllinux_x86_64'
name: Linux Intel musl 64-bit 3.7
- os: ubuntu-22.04
build: 'cp38-musllinux_x86_64'
name: Linux Intel musl 64-bit 3.8
Expand All @@ -98,12 +91,6 @@ jobs:
build: 'cp312-musllinux_x86_64'
name: Linux Intel musl 64-bit 3.12

- os: ubuntu-22.04
build: 'cp36-manylinux_aarch64'
name: Linux Aarch64 3.6
- os: ubuntu-22.04
build: 'cp37-manylinux_aarch64'
name: Linux Aarch64 3.7
- os: ubuntu-22.04
build: 'cp38-manylinux_aarch64'
name: Linux Aarch64 3.8
Expand Down Expand Up @@ -143,7 +130,7 @@ jobs:

- uses: pypa/[email protected]
env:
CIBW_TEST_REQUIRES: pytest numpy
CIBW_TEST_REQUIRES: pytest pytest-cov numpy
CIBW_TEST_COMMAND: pytest {project}/tests
CIBW_ARCHS_LINUX: auto aarch64
CIBW_BUILD: ${{ matrix.build }}
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cmake_minimum_required(VERSION 3.7.2)
cmake_minimum_required(VERSION 3.15...3.26)

project(h3)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Always make a release build
set(CMAKE_BUILD_TYPE Release)

find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)

# Avoid building tooling we won't need for release
# See all options with `cmake -LA` in an `h3/build` directory,
# or at https://h3geo.org/docs/next/core-library/compilation-options/
Expand Down Expand Up @@ -37,4 +42,4 @@ install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/src/h3lib/src/h3lib/include/h3api.h"
DESTINATION
src/h3/_cy)
${SKBUILD_PROJECT_NAME}/_cy)
24 changes: 0 additions & 24 deletions MANIFEST.in

This file was deleted.

24 changes: 10 additions & 14 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PYTHON=$(shell command -v python || command -v python3)


build-docs:
./env/bin/pip install -r requirements-dev.txt
./env/bin/pip install .[all]
./env/bin/jupyter-book build docs/ --warningiserror --keep-going --all

open:
Expand All @@ -14,39 +14,35 @@ init: purge
git submodule update --init
$(PYTHON) -m venv env
./env/bin/pip install --upgrade pip wheel setuptools
./env/bin/pip install .[all]
./env/bin/pip install -r requirements.in
./env/bin/pip install .[test]

clear:
-./env/bin/pip uninstall -y h3
-@rm -rf MANIFEST
-@rm -rf annotations
-@rm -rf .pytest_cache _skbuild dist .coverage build docs/_build
-@rm -rf .pytest_cache _skbuild dist .coverage build docs/_build .ruff_cache
-@find . -type d -name '__pycache__' | xargs rm -r
-@find . -type d -name '*.egg-info' | xargs rm -r
-@find . -type f -name '*.pyc' | xargs rm -r
-@find . -type f -name '*.so' | xargs rm -r
-@find . -type d -name '*.ipynb_checkpoints' | xargs rm -r
-@find ./tests -type f -name '*.c' | xargs rm -r
-@find ./tests -type f -name '*.html' | xargs rm -r

rebuild: clear
./env/bin/pip install .[all]
./env/bin/pip install .[test]

purge: clear
-@rm -rf env

annotations: rebuild
mkdir -p annotations
cp _skbuild/*/cmake-build/src/h3/_cy/*.html ./annotations

test:
./env/bin/cythonize -i tests/test_cython/cython_example.pyx
./env/bin/pytest tests --cov=h3 --cov-report term-missing --durations=10
./env/bin/pip install cython
./env/bin/cythonize tests/test_cython/cython_example.pyx
./env/bin/pytest

lint:
./env/bin/flake8 src/h3 setup.py tests
./env/bin/flake8 src/h3 tests
./env/bin/pylint --disable=all --enable=import-error tests/

lab:
./env/bin/pip install -r requirements-dev.txt
./env/bin/pip install .[all]
./env/bin/jupyter lab
95 changes: 91 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,93 @@
[build-system]
requires = [
'scikit-build',
'cython',
'cmake',
requires = ['scikit-build-core', 'cython']
build-backend = 'scikit_build_core.build'

[project]
name = 'h3'
version = '4.0.0b6'
description = "Uber's hierarchical hexagonal geospatial indexing system"
readme = 'readme.md'
license = {file = 'LICENSE'}
authors = [
{ name = 'Uber Technologies', email = '[email protected]' },
]
maintainers = [
{ name = 'AJ Friend', email = '[email protected]' },
]
requires-python = '>=3.8'

dependencies = []

classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: C',
'Programming Language :: Cython',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'Topic :: Scientific/Engineering :: GIS',
]

[project.urls]
Homepage = 'https://github.com/organization/package'
Documentation = 'https://package.readthedocs.io/'
'Bug Tracker' = 'https://github.com/organization/package/issues'
Discussions = 'https://github.com/organization/package/discussions'
Changelog = 'https://package.readthedocs.io/en/latest/changelog.html'


[project.optional-dependencies]
numpy = ['numpy']
test = ['pytest', 'pytest-cov', 'flake8', 'pylint', 'numpy']
all = [
'jupyter-book',
'flake8',
'sphinx>=7.3.3', # https://github.com/sphinx-doc/sphinx/issues/12290
'jupyterlab',
'jupyterlab-geojson',
'geopandas',
'geodatasets',
'matplotlib',
'contextily',
'cartopy',
'geoviews',
'numpy',
'pytest',
'pytest-cov',
'pylint',
]

[tool.pytest.ini_options]
addopts = "--cov=h3 --cov=tests --cov-report=term-missing --durations=10"

[tool.coverage.run]
omit = [
'*/h3/api/basic_int/__init__.py',
'*/h3/api/memview_int/__init__.py',
'*/h3/api/numpy_int/__init__.py'
]


[tool.scikit-build]
sdist.exclude = [
'src/h3lib',
'docs',
'dev_notes.md',
'makefile',
]
sdist.include = [
'src/h3lib/LICENSE',
'src/h3lib/README.md',
'src/h3lib/VERSION',
'src/h3lib/CMakeLists.txt',
'src/h3lib/cmake/*',
'src/h3lib/src/h3lib/*'
]
8 changes: 0 additions & 8 deletions requirements-dev.txt

This file was deleted.

15 changes: 0 additions & 15 deletions requirements.in

This file was deleted.

44 changes: 0 additions & 44 deletions setup.py

This file was deleted.

Loading

0 comments on commit 65c3d9e

Please sign in to comment.