diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9bb433a..45a1944 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,7 @@ -# This file is autogenerated by maturin v1.4.0 +# This file is autogenerated by maturin v0.14.17 # To update, run # -# maturin generate-ci github --platform all +# maturin generate-ci github -m Cargo.toml --platform all -o .github/workflows/CI.yml # name: CI @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] + target: [x86_64, x86, aarch64, armv7, ppc64le] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -91,26 +91,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' - run: pip install pyodide-build - - name: Get Emscripten and Python version info - shell: bash - run: | - echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV - echo PYTHON_VERSION=$(pyodide config get python_version | cut -d '.' -f 1-2) >> $GITHUB_ENV - pip uninstall -y pyodide-build + - shell: bash + run: echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV - uses: mymindstorm/setup-emsdk@v12 with: version: ${{ env.EMSCRIPTEN_VERSION }} actions-cache-folder: emsdk-cache - - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - run: pip install pyodide-build - name: Build wheels uses: PyO3/maturin-action@v1 with: target: wasm32-unknown-emscripten - args: --release --out dist -i ${{ env.PYTHON_VERSION }} + args: --release --out dist -i 3.10 sccache: 'true' rust-toolchain: nightly - name: Upload wheels @@ -152,7 +147,7 @@ jobs: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} with: command: upload - args: --non-interactive --skip-existing * + args: --skip-existing * - uses: actions/download-artifact@v3 with: name: wasm-wheels diff --git a/Cargo.toml b/Cargo.toml index a09f657..9334e27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polars_coord_transforms" -version = "0.9.1" +version = "0.10.0" edition = "2021" [lib] diff --git a/polars_coord_transforms/__init__.py b/polars_coord_transforms/__init__.py index e204b99..6e0391d 100644 --- a/polars_coord_transforms/__init__.py +++ b/polars_coord_transforms/__init__.py @@ -1,13 +1,11 @@ +from pathlib import Path import polars as pl -from polars.utils.udfs import _get_shared_lib_location +from polars.plugins import register_plugin_function from polars.type_aliases import PolarsDataType from typing import Protocol, Iterable, cast -lib = _get_shared_lib_location(__file__) - - @pl.api.register_expr_namespace("s2") class S2NameSpace: def __init__(self, expr: pl.Expr): @@ -16,29 +14,36 @@ def __init__(self, expr: pl.Expr): def lonlat_to_cellid(self, level: int = 30) -> pl.Expr: if level < 1 or level > 30: raise ValueError("`level` parameter must be between 1 and 30!") - - return self._expr.register_plugin( - lib=lib, - symbol="lonlat_to_cellid", - is_elementwise=True, + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="lonlat_to_cellid", + args=self._expr, kwargs={"level": level}, + is_elementwise=True ) def cellid_to_lonlat(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, symbol="cellid_to_lonlat", is_elementwise=True + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="cellid_to_lonlat", + args=self._expr, + is_elementwise=True ) def cell_contains_point(self, point: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, symbol="cell_contains_point", is_elementwise=True, args=[point] + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="cell_contains_point", + args=[self._expr, point], + is_elementwise=True ) def cellid_to_vertices(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="cellid_to_vertices", - is_elementwise=True, + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="cellid_to_vertices", + args=self._expr, + is_elementwise=True ) @@ -48,67 +53,78 @@ def __init__(self, expr: pl.Expr): self._expr = expr def map_to_ecef(self, rotation: pl.Expr, offset: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, symbol="map_to_ecef", is_elementwise=True, args=[rotation, offset] + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="map_to_ecef", + args=[self._expr, rotation, offset], + is_elementwise=True ) def ecef_to_map(self, rotation: pl.Expr, offset: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, symbol="ecef_to_map", is_elementwise=True, args=[rotation, offset] + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="ecef_to_map", + args=[self._expr, rotation, offset], + is_elementwise=True ) def ecef_to_lla(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="ecef_to_lla", - is_elementwise=True, + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="ecef_to_lla", + args=self._expr, + is_elementwise=True ) def lla_to_ecef(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="lla_to_ecef", - is_elementwise=True, + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="lla_to_ecef", + args=self._expr, + is_elementwise=True ) def lla_to_utm(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="lla_to_utm", + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="lla_to_utm", + args=self._expr, is_elementwise=True ) def lla_to_utm_zone_number(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="lla_to_utm_zone_number", + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="lla_to_utm_zone_number", + args=self._expr, is_elementwise=True ) def rotate_map_coords(self, rotation: pl.Expr, scale: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="rotate_map_coords", - is_elementwise=True, - args=[rotation, scale], + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="rotate_map_coords", + args=[self._expr, rotation, scale], + is_elementwise=True ) + def interpolate_linear(self, other: pl.Expr, coef=0.5): if coef < 0 or coef > 1: raise ValueError("`coef` parameter must be between 0 and 1!") - return self._expr.register_plugin( - lib=lib, - symbol="interpolate_linear", - is_elementwise=True, - args=[other,], + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="interpolate_linear", + args=[self._expr, other], kwargs={"coef": coef}, ) def quat_to_euler_angles(self) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="quat_to_euler_angles", + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="quat_to_euler_angles", + args=self._expr, is_elementwise=True ) @@ -119,35 +135,38 @@ def __init__(self, expr: pl.Expr): self._expr = expr def euclidean_3d(self, other: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="euclidean_3d", - is_elementwise=True, - args=[other], + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="euclidean_3d", + args=[self._expr, other], + is_elementwise=True + ) + def euclidean_2d(self, other: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="euclidean_2d", - is_elementwise=True, - args=[other], + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="euclidean_2d", + args=[self._expr, other], + is_elementwise=True + ) def cosine_similarity_2d(self, other: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="cosine_similarity_2d", - is_elementwise=True, - args=[other,] + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="cosine_similarity_2d", + args=[self._expr, other], + is_elementwise=True ) def cosine_similarity_3d(self, other: pl.Expr) -> pl.Expr: - return self._expr.register_plugin( - lib=lib, - symbol="cosine_similarity_3d", - is_elementwise=True, - args=[other,] + return register_plugin_function( + plugin_path=Path(__file__).parent, + function_name="cosine_similarity_3d", + args=[self._expr, other], + is_elementwise=True ) diff --git a/pyproject.toml b/pyproject.toml index 7134a49..61b274f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] -version = "0.9.1" +version = "0.10.0" authors = [ {name="Georgy Popov"} ] diff --git a/requirements.txt b/requirements.txt index f01183f..dad8431 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ maturin +patchelf polars pytest mypy