Skip to content

Commit a77508a

Browse files
authored
modernize with scikit-build-core (#5)
* modernize with scikit-build-core * remove Werror from cmake config * adjust build settings * typo * scikit_build_core.builder.wheel_tag * scikit-build-core needed * -m not -c * turn up cmake logging * override python-version * link against Python3_LIBRARIES * windows fixes? * conditionalize tests * build_type * proper condition variables
1 parent 146d9db commit a77508a

File tree

202 files changed

+177
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+177
-126
lines changed

.github/environment.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: test
22
channels:
33
- conda-forge
44
dependencies:
5-
- scikit-build
5+
- scikit-build-core
66
- numpy
77
- pdal
8+
- compilers

.github/workflows/build.yml

+22-42
Original file line numberDiff line numberDiff line change
@@ -36,63 +36,43 @@ jobs:
3636
miniforge-variant: Mambaforge
3737
miniforge-version: latest
3838
use-mamba: true
39+
python-version: ${{ matrix.python-version }}
3940
auto-update-conda: true
4041
environment-file: .github/environment.yml
4142

4243

4344
- name: Install
4445
shell: bash -l {0}
45-
run: SKBUILD_CONFIGURE_OPTIONS="-DWITH_TESTS=ON" pip install .
46+
run: |
47+
pip install . -Ccmake.define.WITH_TESTS=ON .
48+
49+
- name: Test Unix
50+
shell: bash -l {0}
51+
if: matrix.os != 'windows-latest'
52+
run: |
53+
export PYTHONHOME=$CONDA_PREFIX
54+
export WHEEL_DIR=$(python -m "scikit_build_core.builder.wheel_tag")
55+
export PDAL_DRIVER_PATH=`pwd`/build/$WHEEL_DIR/Release
56+
echo $PDAL_DRIVER_PATH
57+
ls $PDAL_DRIVER_PATH
58+
pdal --drivers
59+
$PDAL_DRIVER_PATH/pdal_filters_python_test
60+
$PDAL_DRIVER_PATH/pdal_io_numpy_test
4661
47-
- name: Test
62+
63+
- name: Test Windows
64+
if: matrix.os == 'windows-latest'
4865
shell: bash -l {0}
4966
env:
5067
EXT: ${{ matrix.os == 'windows-latest' && '.exe' || '' }}
5168
run: |
5269
export PYTHONHOME=$CONDA_PREFIX
53-
export PDAL_DRIVER_PATH=$(python -c "import os, skbuild; print(os.path.join(skbuild.constants.SKBUILD_DIR(), 'cmake-build'))")
54-
echo PDAL_DRIVER_PATH
70+
export WHEEL_DIR=$(python -m "scikit_build_core.builder.wheel_tag")
71+
export PDAL_DRIVER_PATH=`pwd`/build/$WHEEL_DIR/Release/Release
72+
echo $PDAL_DRIVER_PATH
5573
ls $PDAL_DRIVER_PATH
5674
pdal --drivers
5775
$PDAL_DRIVER_PATH/pdal_filters_python_test$EXT
5876
$PDAL_DRIVER_PATH/pdal_io_numpy_test$EXT
5977
60-
dist:
61-
name: Distribution
62-
needs: [build]
63-
64-
runs-on: ${{ matrix.os }}
65-
strategy:
66-
fail-fast: true
67-
matrix:
68-
os: ['ubuntu-latest']
69-
python-version: ['3.9']
70-
71-
steps:
72-
- uses: actions/checkout@v4
73-
- name: Setup micromamba
74-
uses: conda-incubator/setup-miniconda@v3
75-
with:
76-
miniforge-variant: Mambaforge
77-
miniforge-version: latest
78-
use-mamba: true
79-
auto-update-conda: true
80-
mamba-version: "*"
81-
82-
- name: Dependencies
83-
shell: bash -l {0}
84-
run: mamba install --yes --quiet -c conda-forge scikit-build numpy python=${{ matrix.python-version }} pybind11 pdal
8578
86-
- name: sdist
87-
shell: bash -l {0}
88-
run: |
89-
python setup.py sdist
90-
ls dist
91-
92-
- uses: pypa/gh-action-pypi-publish@release/v1
93-
name: Publish package
94-
if: github.event_name == 'release' && github.event.action == 'published'
95-
with:
96-
user: __token__
97-
password: ${{ secrets.pypi_token }}
98-
packages_dir: ./dist

.github/workflows/release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
release:
3+
types:
4+
- published
5+
6+
jobs:
7+
pypi-publish:
8+
name: Upload release to PyPI
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: release
12+
url: https://pypi.org/p/pdal-plugins
13+
permissions:
14+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install build
24+
pip install build twine
25+
python -m build . --sdist
26+
- name: Publish package distributions to PyPI
27+
if: github.event_name == 'release' && github.event.action == 'published'
28+
uses: pypa/gh-action-pypi-publish@release/v1

CMakeLists.txt

+30-29
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ option(WITH_TESTS "Enable tests" OFF)
1010
set(Python3_FIND_STRATEGY "LOCATION")
1111
set(Python3_FIND_REGISTRY "LAST")
1212
set(Python3_FIND_FRAMEWORK "LAST")
13-
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
13+
find_package(Python3 COMPONENTS Interpreter Development.Module Development.Embed NumPy REQUIRED)
14+
1415

1516
# find PDAL. Require 2.1+
16-
find_package(PDAL 2.4 REQUIRED)
17+
find_package(PDAL 2.6 REQUIRED)
1718

1819
# Taken and adapted from PDAL's cmake macros.cmake
1920

@@ -96,7 +97,7 @@ macro(PDAL_PYTHON_ADD_PLUGIN _name _type _shortname)
9697
)
9798
target_link_options(${${_name}} BEFORE PRIVATE ${PDAL_PYTHON_ADD_PLUGIN_COMPILE_OPTIONS})
9899
target_compile_definitions(${${_name}} PRIVATE
99-
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}" PDAL_DLL_EXPORT)
100+
PDAL_PYTHON_LIBRARY="${Python3_LIBRARIES}" PDAL_DLL_EXPORT)
100101
target_compile_definitions(${${_name}} PRIVATE PDAL_DLL_EXPORT)
101102
if (PDAL_PYTHON_ADD_PLUGIN_SYSTEM_INCLUDES)
102103
target_include_directories(${${_name}} SYSTEM PRIVATE
@@ -141,7 +142,7 @@ macro(PDAL_PYTHON_ADD_TEST _name)
141142
${WINSOCK_LIBRARY}
142143
)
143144
target_compile_definitions(${_name} PRIVATE
144-
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}")
145+
PDAL_PYTHON_LIBRARY="${Python3_LIBRARIES}")
145146
add_test(NAME ${_name}
146147
COMMAND
147148
"${PROJECT_BINARY_DIR}/bin/${_name}"
@@ -160,12 +161,12 @@ endif()
160161

161162
PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
162163
FILES
163-
./pdal/io/NumpyReader.cpp
164-
./pdal/io/NumpyReader.hpp
165-
./pdal/plang/Invocation.cpp
166-
./pdal/plang/Environment.cpp
167-
./pdal/plang/Redirector.cpp
168-
./pdal/plang/Script.cpp
164+
./src/pdal/io/NumpyReader.cpp
165+
./src/pdal/io/NumpyReader.hpp
166+
./src/pdal/plang/Invocation.cpp
167+
./src/pdal/plang/Environment.cpp
168+
./src/pdal/plang/Redirector.cpp
169+
./src/pdal/plang/Script.cpp
169170
LINK_WITH
170171
${PDAL_LIBRARIES}
171172
${Python3_LIBRARIES}
@@ -180,12 +181,12 @@ PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
180181

181182
PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
182183
FILES
183-
./pdal/filters/PythonFilter.cpp
184-
./pdal/filters/PythonFilter.hpp
185-
./pdal/plang/Invocation.cpp
186-
./pdal/plang/Environment.cpp
187-
./pdal/plang/Redirector.cpp
188-
./pdal/plang/Script.cpp
184+
./src/pdal/filters/PythonFilter.cpp
185+
./src/pdal/filters/PythonFilter.hpp
186+
./src/pdal/plang/Invocation.cpp
187+
./src/pdal/plang/Environment.cpp
188+
./src/pdal/plang/Redirector.cpp
189+
./src/pdal/plang/Script.cpp
189190
LINK_WITH
190191
${PDAL_LIBRARIES}
191192
${Python3_LIBRARIES}
@@ -202,17 +203,17 @@ PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
202203
if (WITH_TESTS)
203204
enable_testing()
204205
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
205-
add_subdirectory(pdal/test/gtest)
206+
add_subdirectory(src/pdal/test/gtest)
206207
enable_testing()
207208
include_directories(pdal/test/gtest/include .. ${CMAKE_CURRENT_BINARY_DIR})
208209
PDAL_PYTHON_ADD_TEST(pdal_io_numpy_test
209210
FILES
210-
./pdal/test/NumpyReaderTest.cpp
211-
./pdal/test/Support.cpp
212-
./pdal/plang/Invocation.cpp
213-
./pdal/plang/Environment.cpp
214-
./pdal/plang/Redirector.cpp
215-
./pdal/plang/Script.cpp
211+
./src/pdal/test/NumpyReaderTest.cpp
212+
./src/pdal/test/Support.cpp
213+
./src/pdal/plang/Invocation.cpp
214+
./src/pdal/plang/Environment.cpp
215+
./src/pdal/plang/Redirector.cpp
216+
./src/pdal/plang/Script.cpp
216217
LINK_WITH
217218
${numpy_reader}
218219
${Python3_LIBRARIES}
@@ -225,12 +226,12 @@ if (WITH_TESTS)
225226
)
226227
PDAL_PYTHON_ADD_TEST(pdal_filters_python_test
227228
FILES
228-
./pdal/test/PythonFilterTest.cpp
229-
./pdal/test/Support.cpp
230-
./pdal/plang/Invocation.cpp
231-
./pdal/plang/Environment.cpp
232-
./pdal/plang/Redirector.cpp
233-
./pdal/plang/Script.cpp
229+
./src/pdal/test/PythonFilterTest.cpp
230+
./src/pdal/test/Support.cpp
231+
./src/pdal/plang/Invocation.cpp
232+
./src/pdal/plang/Environment.cpp
233+
./src/pdal/plang/Redirector.cpp
234+
./src/pdal/plang/Script.cpp
234235
LINK_WITH
235236
${python_filter}
236237
${Python3_LIBRARIES}

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The repository for PDAL's Python plugins is available at https://github.com/PDAL
3131
Requirements
3232
================================================================================
3333

34-
* PDAL 2.4+
35-
* Python >=3.7
34+
* PDAL 2.6+
35+
* Python >=3.9
3636
* Numpy (eg :code:`pip install numpy`)
37-
* scikit-build (eg :code:`pip install scikit-build`)
37+
* scikit-build-core (eg :code:`pip install scikit-build-core`)

pyproject.toml

+73-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
1+
[project]
2+
name = "pdal-plugins"
3+
description = "Point cloud data processing Python plugins"
4+
readme = "README.rst"
5+
requires-python = ">=3.9"
6+
license = {file = "LICENSE"}
7+
keywords = ["point", "cloud", "spatial"]
8+
authors = [
9+
{email = "[email protected]"},
10+
{name = "Howard Butler"}
11+
]
12+
maintainers = [
13+
{name = "Howard Butler", email = "[email protected]"}
14+
]
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Intended Audience :: Developers",
18+
"Intended Audience :: Science/Research",
19+
"License :: OSI Approved :: BSD License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Topic :: Scientific/Engineering :: GIS",
26+
]
27+
28+
dependencies = [
29+
"numpy"
30+
]
31+
32+
#dynamic = ["version"]
33+
34+
#[tool.scikit-build.dynamic]
35+
#version = { attr = "pdal.__version__" }
36+
version="1.4.0"
37+
38+
[project.optional-dependencies]
39+
test = [
40+
]
41+
42+
[tool.setuptools]
43+
package-dir = {"" = "src"}
44+
zip-safe = false
45+
46+
[project.urls]
47+
homepage = "https://pdal.io"
48+
documentation = "https://pdal.io"
49+
repository = "https://github.com/PDAL/python-plugins"
50+
changelog = "https://github.com/PDAL/python-plugins/blob/main/README.rst"
51+
152
[build-system]
2-
requires = ["scikit-build", "cmake", "ninja", "numpy"]
53+
requires = ["scikit-build-core", "numpy", "pybind11[global]"]
54+
build-backend = "scikit_build_core.build"
55+
56+
#[tool.scikit-build-core]
57+
#wheel.py-api = "cp12"
58+
#wheel.cmake = true
59+
60+
61+
[tool.scikit-build]
62+
build-dir = "build/{wheel_tag}/{build_type}"
63+
sdist.exclude = [".github"]
64+
sdist.cmake = true
65+
cmake.build-type = "Release"
66+
sdist.include = [
67+
"src",
68+
"CMakeLists.txt"
69+
]
70+
cmake.verbose = true
71+
logging.level = "INFO"
72+
73+
#[tool.scikit-build.cmake.define]
74+
#WITH_TESTS = "ON"

setup.py

-31
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pdal/test/TestConfig.hpp renamed to src/pdal/test/TestConfig.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
#ifndef UNITTEST_TESTCONFIG_INCLUDED
3636
#define UNITTEST_TESTCONFIG_INCLUDED
3737

38-
#define UNITTEST_TESTCONFIG_DATA_PATH "./pdal/test/data/"
39-
#define UNITTEST_TESTCONFIG_CONFIGURED_PATH "./pdal/test/data/"
38+
#define UNITTEST_TESTCONFIG_DATA_PATH "./src/pdal/test/data/"
39+
#define UNITTEST_TESTCONFIG_CONFIGURED_PATH "./src/pdal/test/data/"
4040
#define UNITTEST_TESTCONFIG_BINARY_PATH ""
4141
#define UNITTEST_TESTCONFIG_OCI_CONNECTION ""
4242

4343
#include <string>
4444

45-
namespace TestConfig
45+
namespace TestConfig
4646
{
4747

4848
inline std::string dataPath()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pdal/test/data/pipeline/crop_wkt_2d_classification.json renamed to src/pdal/test/data/pipeline/crop_wkt_2d_classification.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pipeline":[
3-
"./pdal/test/data/1.2-with-color.las",
3+
"./src/pdal/test/data/1.2-with-color.las",
44
{
55
"type":"filters.crop",
66
"polygon":"POLYGON ((636889.4129512392682955 851528.5122932585654780, 636899.1423342394409701 851475.0006867571501061, 636899.1423342394409701 851475.0006867571501061, 636928.3304832403082401 851494.4594527576118708, 636928.3304832403082401 851494.4594527576118708, 636928.3304832403082401 851494.4594527576118708, 636976.9773982415208593 851513.9182187581900507, 636976.9773982415208593 851513.9182187581900507, 637069.4065367440925911 851475.0006867571501061, 637132.6475262457970530 851445.8125377562828362, 637132.6475262457970530 851445.8125377562828362, 637336.9645692512858659 851411.7596972554456443, 637336.9645692512858659 851411.7596972554456443, 637473.1759312548674643 851158.7957392486277968, 637589.9285272579872981 850711.2441212366102263, 637244.5354307487141341 850511.7917697312077507, 636758.0662807356566191 850667.4618977354839444, 636539.1551632297923788 851056.6372177458833903, 636889.4129512392682955 851528.5122932585654780))",
@@ -13,7 +13,7 @@
1313
"module":"anything"
1414
},
1515
{
16-
"filename":"./pdal/test/temp/crop-wkt-2d-classification.las",
16+
"filename":"./src/pdal/test/temp/crop-wkt-2d-classification.las",
1717
"compression":false
1818
}
1919
]

0 commit comments

Comments
 (0)