Repository: nmandery/h3ronpy (language: python)

Issue:
Build wheels for more architectures
While messing with GitHub actions is mostly no fun, it would be good to provide binaries for all OS and architectures pyarrow supports: https://pypi.org/project/pyarrow/#files

The workflow of wonnx seems to be a good example: https://github.com/webonnx/wonnx/blob/master/.github/workflows/python-package.yml


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index a587eef..6f817e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,7 @@ target
 perf.data
 perf.data.old
 flamegraph*.svg
-/h3ronpy/h3ronpy*.so
+*.so
 .ipynb_checkpoints
 /venv
 __pycache__
@@ -15,3 +15,5 @@ __pycache__
 .ruff_cache
 /docs/build/
 /docs/source/generated/
+/docs/source/_build/
+/dist
diff --git a/CHANGES.rst b/CHANGES.rst
index f4d8994..85230fb 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -12,6 +12,8 @@ Versioning <https://semver.org/spec/v2.0.0.html>`__.
 Unreleased
 ----------
 
+- Rework packaging and build process in CI. Adds support for apple silicon.
+
 0.17.4 - 2023-07-28
 -------------------
 
diff --git a/Cargo.toml b/Cargo.toml
index 91beabe..d65648a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ authors = ["Nico Mandery <nico@nmandery.net>"]
 description = "Data science toolkit for the H3 geospatial grid"
 edition = "2021"
 license = "MIT"
-keywords = ["geo", "spatial", "h3", "pandas", "geopandas", "arrow", "polars", "numpy", "python"]
+keywords = ["geo", "spatial", "h3", "arrow", "python"]
 homepage = "https://github.com/nmandery/h3ronpy"
 repository = "https://github.com/nmandery/h3ronpy"
 
diff --git a/justfile b/justfile
index aeb7ed3..ba69b87 100644
--- a/justfile
+++ b/justfile
@@ -1,7 +1,12 @@
 # to be executed via https://github.com/casey/just
 
 black:
-    black -l 120 h3ronpy tests *.py docs/source/*.py
+    black -l 120 python tests *.py docs/source/*.py
 
 ruff:
-    ruff check h3ronpy tests *.py docs/source/*.py
\ No newline at end of file
+    ruff check python tests *.py docs/source/*.py
+
+test:
+    maturin build --out dist
+    pip install --force-reinstall dist/*.whl
+    pytest -s
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 8ee973b..8fe1698 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [build-system]
 requires = [
-    "maturin==1.1",
+    "maturin==1.2",
 ]
 build-backend = "maturin"
 
@@ -43,4 +43,8 @@ test = [
     "pytest>=6",
     "h3>=3.7",
     "pytest-benchmark"
-]
\ No newline at end of file
+]
+
+[tool.maturin]
+python-source = "python"
+module-name = "h3ronpy.h3ronpyrs"
\ No newline at end of file
diff --git a/h3ronpy/__init__.py b/python/h3ronpy/__init__.py
similarity index 67%
rename from h3ronpy/__init__.py
rename to python/h3ronpy/__init__.py
index d18f690..7d5caa6 100644
--- a/h3ronpy/__init__.py
+++ b/python/h3ronpy/__init__.py
@@ -1,5 +1,5 @@
-from . import h3ronpy as _native
-from .h3ronpy import version, DEFAULT_CELL_COLUMN_NAME  # noqa: F401
+from . import h3ronpyrs as _native
+from .h3ronpyrs import version, DEFAULT_CELL_COLUMN_NAME  # noqa: F401
 
 __version__ = version()
 
diff --git a/h3ronpy/arrow/__init__.py b/python/h3ronpy/arrow/__init__.py
similarity index 99%
rename from h3ronpy/arrow/__init__.py
rename to python/h3ronpy/arrow/__init__.py
index 3bd6382..814292d 100644
--- a/h3ronpy/arrow/__init__.py
+++ b/python/h3ronpy/arrow/__init__.py
@@ -1,7 +1,7 @@
 from typing import Union
 
 import pyarrow as pa
-from ..h3ronpy import op
+from h3ronpy.h3ronpyrs import op
 
 try:
     import polars as pl
diff --git a/h3ronpy/arrow/raster.py b/python/h3ronpy/arrow/raster.py
similarity index 99%
rename from h3ronpy/arrow/raster.py
rename to python/h3ronpy/arrow/raster.py
index c7e5b4e..fa5cb27 100644
--- a/h3ronpy/arrow/raster.py
+++ b/python/h3ronpy/arrow/raster.py
@@ -28,7 +28,7 @@
 
 """
 
-from ..h3ronpy import raster
+from h3ronpy.h3ronpyrs import raster
 from .. import DEFAULT_CELL_COLUMN_NAME
 import numpy as np
 import pyarrow as pa
diff --git a/h3ronpy/arrow/util.py b/python/h3ronpy/arrow/util.py
similarity index 100%
rename from h3ronpy/arrow/util.py
rename to python/h3ronpy/arrow/util.py
diff --git a/h3ronpy/arrow/vector.py b/python/h3ronpy/arrow/vector.py
similarity index 99%
rename from h3ronpy/arrow/vector.py
rename to python/h3ronpy/arrow/vector.py
index 816ee51..d1a2ff5 100644
--- a/h3ronpy/arrow/vector.py
+++ b/python/h3ronpy/arrow/vector.py
@@ -1,4 +1,4 @@
-from ..h3ronpy import vector
+from h3ronpy.h3ronpyrs import vector
 from . import _to_uint64_array, _HAS_POLARS
 from typing import Optional, Tuple, Union
 import pyarrow as pa
diff --git a/h3ronpy/pandas/__init__.py b/python/h3ronpy/pandas/__init__.py
similarity index 100%
rename from h3ronpy/pandas/__init__.py
rename to python/h3ronpy/pandas/__init__.py
diff --git a/h3ronpy/pandas/raster.py b/python/h3ronpy/pandas/raster.py
similarity index 100%
rename from h3ronpy/pandas/raster.py
rename to python/h3ronpy/pandas/raster.py
diff --git a/h3ronpy/pandas/vector.py b/python/h3ronpy/pandas/vector.py
similarity index 100%
rename from h3ronpy/pandas/vector.py
rename to python/h3ronpy/pandas/vector.py
diff --git a/h3ronpy/polars/__init__.py b/python/h3ronpy/polars/__init__.py
similarity index 100%
rename from h3ronpy/polars/__init__.py
rename to python/h3ronpy/polars/__init__.py
diff --git a/h3ronpy/polars/raster.py b/python/h3ronpy/polars/raster.py
similarity index 100%
rename from h3ronpy/polars/raster.py
rename to python/h3ronpy/polars/raster.py
diff --git a/h3ronpy/polars/vector.py b/python/h3ronpy/polars/vector.py
similarity index 100%
rename from h3ronpy/polars/vector.py
rename to python/h3ronpy/polars/vector.py
diff --git a/src/lib.rs b/src/lib.rs
index 22224e2..efbf2a9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -40,7 +40,7 @@ fn is_release_build() -> bool {
 }
 
 #[pymodule]
-fn h3ronpy(py: Python<'_>, m: &PyModule) -> PyResult<()> {
+fn h3ronpyrs(py: Python<'_>, m: &PyModule) -> PyResult<()> {
     env_logger::init(); // run with the environment variable RUST_LOG set to "debug" for log output
 
     m.add_function(wrap_pyfunction!(version, m)?)?;


Test patch:
diff --git a/tests/arrow/test_vector.py b/tests/arrow/test_vector.py
index 75edf29..5cae41a 100644
--- a/tests/arrow/test_vector.py
+++ b/tests/arrow/test_vector.py
@@ -19,4 +19,4 @@ def test_geometry_to_cells_central_park():
 
     arr = geometry_to_cells(point, 8).to_numpy()
     assert len(arr) == 1
-    assert arr[0] == h3.geo_to_h3(point.y, point.x, 8)
\ No newline at end of file
+    assert arr[0] == h3.geo_to_h3(point.y, point.x, 8)
diff --git a/tests/pandas/test_resolution.py b/tests/pandas/test_resolution.py
index bc44705..3c32eef 100644
--- a/tests/pandas/test_resolution.py
+++ b/tests/pandas/test_resolution.py
@@ -1,8 +1,9 @@
-from h3ronpy.pandas import change_resolution, change_resolution_paired, cells_resolution
 import numpy as np
 import math
 import h3.api.numpy_int as h3
 
+from h3ronpy.pandas import change_resolution, change_resolution_paired, cells_resolution
+
 
 def test_change_resolution_up():
     h3indexes = np.array([h3.geo_to_h3(10.2, 45.5, 5), h3.geo_to_h3(10.3, 45.1, 8)], dtype=np.uint64)