Skip to content

Commit 8332337

Browse files
authored
Merge pull request #98 from urschrei/shugel/push-kvxttvnpkznr
Switch to scikit-build
2 parents 01e9a67 + 1122c96 commit 8332337

File tree

6 files changed

+285
-144
lines changed

6 files changed

+285
-144
lines changed

.github/workflows/wheels.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ env:
1010
rustlib: polylineffi
1111
wheelname: pypolyline
1212

13-
on: [push, pull_request]
13+
on:
14+
pull_request:
15+
push:
16+
branches:
17+
- master
18+
tags:
19+
- 'v*'
1420

1521
jobs:
1622
get_latest_lib_tag:

CMakeLists.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
cmake_minimum_required(VERSION 3.15...3.27)
2+
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)
3+
4+
# Find Python
5+
find_package(
6+
Python
7+
COMPONENTS Interpreter Development.Module NumPy
8+
REQUIRED)
9+
10+
# Get NumPy include directory
11+
message(STATUS "NumPy include directory: ${Python_NumPy_INCLUDE_DIRS}")
12+
13+
# Cythonize the .pyx file to .c
14+
add_custom_command(
15+
OUTPUT cutil.c
16+
COMMENT "Cythonizing ${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline/cutil.pyx"
17+
COMMAND Python::Interpreter -m cython
18+
"${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline/cutil.pyx"
19+
--output-file cutil.c
20+
-I "${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline"
21+
DEPENDS src/pypolyline/cutil.pyx src/pypolyline/pypolyline_p.pxd
22+
VERBATIM)
23+
24+
# Create the extension module
25+
python_add_library(cutil MODULE cutil.c WITH_SOABI)
26+
27+
# Set include directories
28+
target_include_directories(cutil PRIVATE
29+
${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline
30+
${Python_NumPy_INCLUDE_DIRS}
31+
)
32+
33+
# Link against the Rust library
34+
# The library is pre-built and located in src/pypolyline/
35+
find_library(POLYLINE_LIBRARY
36+
NAMES polylineffi libpolylineffi
37+
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline
38+
NO_DEFAULT_PATH
39+
REQUIRED
40+
)
41+
message(STATUS "Found Rust polyline library: ${POLYLINE_LIBRARY}")
42+
43+
target_link_libraries(cutil PRIVATE ${POLYLINE_LIBRARY})
44+
45+
# Set RPATH for different platforms
46+
if(APPLE)
47+
set_target_properties(cutil PROPERTIES
48+
INSTALL_RPATH "@loader_path"
49+
BUILD_WITH_INSTALL_RPATH TRUE
50+
)
51+
elseif(UNIX)
52+
set_target_properties(cutil PROPERTIES
53+
INSTALL_RPATH "$ORIGIN"
54+
BUILD_WITH_INSTALL_RPATH TRUE
55+
)
56+
endif()
57+
58+
# Install the extension module
59+
install(TARGETS cutil DESTINATION pypolyline)
60+
61+
# Install the shared library
62+
if(APPLE)
63+
set(POLYLINE_LIB_NAME "libpolylineffi.dylib")
64+
elseif(UNIX)
65+
set(POLYLINE_LIB_NAME "libpolylineffi.so")
66+
elseif(WIN32)
67+
set(POLYLINE_LIB_NAME "polylineffi.dll")
68+
endif()
69+
70+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline/${POLYLINE_LIB_NAME}
71+
DESTINATION pypolyline)
72+
73+
# Install header file
74+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pypolyline/header.h
75+
DESTINATION pypolyline)

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
# Fast Google [Polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) Encoding and Decoding
44

55
## Installation
6+
`uv add pypolyline`
67
`pip install pypolyline`
78

9+
### Installing for local development
10+
1. Ensure you have a copy of `libpolylineffi` and `header.h` from https://github.com/urschrei/polyline-ffi/releases, and it's in the `src/pypolyline` subdir
11+
2. run `uv sync --dev`
12+
3. run `pytest .`
13+
4. If you make changes, you must rebuild the extension: `uv sync --reinstall`
14+
815
### Supported Python Versions
916
All [_currently_ supported Python versions](https://devguide.python.org/versions/).
1017

pyproject.toml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[project]
22
name = "pypolyline"
3-
dynamic = ["version", "readme"]
3+
version = "0.5.7"
44
description = "Fast Google Polyline encoding and decoding using Rust FFI"
5+
readme = "README.md"
56
requires-python = ">=3.10"
67
dependencies = [
78
"numpy >= 2.0.0",
@@ -29,34 +30,32 @@ classifiers = [
2930
Repository = "https://github.com/urschrei/pypolyline"
3031
Tracker = "https://github.com/urschrei/pypolyline/issues"
3132

32-
[project.optional-dependencies]
33-
test = ["pytest >= 7.4.2"]
33+
[dependency-groups]
34+
dev = [
35+
"pytest>=8.4.1",
36+
]
3437

35-
[tool.setuptools.dynamic]
36-
readme = {file = "README.md", content-type = "text/markdown"}
38+
[tool.scikit-build]
39+
minimum-version = "build-system.requires"
40+
wheel.packages = ["src/convertbng"]
3741

3842
[build-system]
39-
build-backend = "setuptools.build_meta"
4043
requires = [
41-
"setuptools >= 45",
42-
"setuptools-scm[toml] >= 6.2",
44+
"scikit-build-core>=0.10",
4345
"numpy >= 2.0.0",
44-
"cython >= 3.0.0",
45-
"wheel >= 0.29.0",
46+
"cython >= 3.1.0",
4647
]
48+
build-backend = "scikit_build_core.build"
4749

4850
[tool.pytest.ini_options]
49-
minversion = "6.2.2"
51+
minversion = "8.4.1"
5052
addopts = [
5153
"--import-mode=importlib",
5254
]
5355
testpaths = [
5456
"tests",
5557
]
5658

57-
[tool.setuptools_scm]
58-
write_to = "src/_version.py"
59-
6059
[tool.ruff]
6160
exclude = [
6261
".bzr",
@@ -99,5 +98,3 @@ quote-style = "double"
9998

10099
# Like Black, indent with spaces, rather than tabs.
101100
indent-style = "space"
102-
103-

setup.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)