Skip to content

Commit

Permalink
modernize with scikit-build-core (#5)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hobu authored Apr 15, 2024
1 parent 146d9db commit a77508a
Show file tree
Hide file tree
Showing 202 changed files with 177 additions and 126 deletions.
3 changes: 2 additions & 1 deletion .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: test
channels:
- conda-forge
dependencies:
- scikit-build
- scikit-build-core
- numpy
- pdal
- compilers
64 changes: 22 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,43 @@ jobs:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
python-version: ${{ matrix.python-version }}
auto-update-conda: true
environment-file: .github/environment.yml


- name: Install
shell: bash -l {0}
run: SKBUILD_CONFIGURE_OPTIONS="-DWITH_TESTS=ON" pip install .
run: |
pip install . -Ccmake.define.WITH_TESTS=ON .
- name: Test Unix
shell: bash -l {0}
if: matrix.os != 'windows-latest'
run: |
export PYTHONHOME=$CONDA_PREFIX
export WHEEL_DIR=$(python -m "scikit_build_core.builder.wheel_tag")
export PDAL_DRIVER_PATH=`pwd`/build/$WHEEL_DIR/Release
echo $PDAL_DRIVER_PATH
ls $PDAL_DRIVER_PATH
pdal --drivers
$PDAL_DRIVER_PATH/pdal_filters_python_test
$PDAL_DRIVER_PATH/pdal_io_numpy_test
- name: Test
- name: Test Windows
if: matrix.os == 'windows-latest'
shell: bash -l {0}
env:
EXT: ${{ matrix.os == 'windows-latest' && '.exe' || '' }}
run: |
export PYTHONHOME=$CONDA_PREFIX
export PDAL_DRIVER_PATH=$(python -c "import os, skbuild; print(os.path.join(skbuild.constants.SKBUILD_DIR(), 'cmake-build'))")
echo PDAL_DRIVER_PATH
export WHEEL_DIR=$(python -m "scikit_build_core.builder.wheel_tag")
export PDAL_DRIVER_PATH=`pwd`/build/$WHEEL_DIR/Release/Release
echo $PDAL_DRIVER_PATH
ls $PDAL_DRIVER_PATH
pdal --drivers
$PDAL_DRIVER_PATH/pdal_filters_python_test$EXT
$PDAL_DRIVER_PATH/pdal_io_numpy_test$EXT
dist:
name: Distribution
needs: [build]

runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ['ubuntu-latest']
python-version: ['3.9']

steps:
- uses: actions/checkout@v4
- name: Setup micromamba
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
auto-update-conda: true
mamba-version: "*"

- name: Dependencies
shell: bash -l {0}
run: mamba install --yes --quiet -c conda-forge scikit-build numpy python=${{ matrix.python-version }} pybind11 pdal
- name: sdist
shell: bash -l {0}
run: |
python setup.py sdist
ls dist
- uses: pypa/gh-action-pypi-publish@release/v1
name: Publish package
if: github.event_name == 'release' && github.event.action == 'published'
with:
user: __token__
password: ${{ secrets.pypi_token }}
packages_dir: ./dist
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
release:
types:
- published

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pdal-plugins
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install build
pip install build twine
python -m build . --sdist
- name: Publish package distributions to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1
59 changes: 30 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ option(WITH_TESTS "Enable tests" OFF)
set(Python3_FIND_STRATEGY "LOCATION")
set(Python3_FIND_REGISTRY "LAST")
set(Python3_FIND_FRAMEWORK "LAST")
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development.Module Development.Embed NumPy REQUIRED)


# find PDAL. Require 2.1+
find_package(PDAL 2.4 REQUIRED)
find_package(PDAL 2.6 REQUIRED)

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

Expand Down Expand Up @@ -96,7 +97,7 @@ macro(PDAL_PYTHON_ADD_PLUGIN _name _type _shortname)
)
target_link_options(${${_name}} BEFORE PRIVATE ${PDAL_PYTHON_ADD_PLUGIN_COMPILE_OPTIONS})
target_compile_definitions(${${_name}} PRIVATE
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}" PDAL_DLL_EXPORT)
PDAL_PYTHON_LIBRARY="${Python3_LIBRARIES}" PDAL_DLL_EXPORT)
target_compile_definitions(${${_name}} PRIVATE PDAL_DLL_EXPORT)
if (PDAL_PYTHON_ADD_PLUGIN_SYSTEM_INCLUDES)
target_include_directories(${${_name}} SYSTEM PRIVATE
Expand Down Expand Up @@ -141,7 +142,7 @@ macro(PDAL_PYTHON_ADD_TEST _name)
${WINSOCK_LIBRARY}
)
target_compile_definitions(${_name} PRIVATE
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}")
PDAL_PYTHON_LIBRARY="${Python3_LIBRARIES}")
add_test(NAME ${_name}
COMMAND
"${PROJECT_BINARY_DIR}/bin/${_name}"
Expand All @@ -160,12 +161,12 @@ endif()

PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
FILES
./pdal/io/NumpyReader.cpp
./pdal/io/NumpyReader.hpp
./pdal/plang/Invocation.cpp
./pdal/plang/Environment.cpp
./pdal/plang/Redirector.cpp
./pdal/plang/Script.cpp
./src/pdal/io/NumpyReader.cpp
./src/pdal/io/NumpyReader.hpp
./src/pdal/plang/Invocation.cpp
./src/pdal/plang/Environment.cpp
./src/pdal/plang/Redirector.cpp
./src/pdal/plang/Script.cpp
LINK_WITH
${PDAL_LIBRARIES}
${Python3_LIBRARIES}
Expand All @@ -180,12 +181,12 @@ PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy

PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
FILES
./pdal/filters/PythonFilter.cpp
./pdal/filters/PythonFilter.hpp
./pdal/plang/Invocation.cpp
./pdal/plang/Environment.cpp
./pdal/plang/Redirector.cpp
./pdal/plang/Script.cpp
./src/pdal/filters/PythonFilter.cpp
./src/pdal/filters/PythonFilter.hpp
./src/pdal/plang/Invocation.cpp
./src/pdal/plang/Environment.cpp
./src/pdal/plang/Redirector.cpp
./src/pdal/plang/Script.cpp
LINK_WITH
${PDAL_LIBRARIES}
${Python3_LIBRARIES}
Expand All @@ -202,17 +203,17 @@ PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
if (WITH_TESTS)
enable_testing()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(pdal/test/gtest)
add_subdirectory(src/pdal/test/gtest)
enable_testing()
include_directories(pdal/test/gtest/include .. ${CMAKE_CURRENT_BINARY_DIR})
PDAL_PYTHON_ADD_TEST(pdal_io_numpy_test
FILES
./pdal/test/NumpyReaderTest.cpp
./pdal/test/Support.cpp
./pdal/plang/Invocation.cpp
./pdal/plang/Environment.cpp
./pdal/plang/Redirector.cpp
./pdal/plang/Script.cpp
./src/pdal/test/NumpyReaderTest.cpp
./src/pdal/test/Support.cpp
./src/pdal/plang/Invocation.cpp
./src/pdal/plang/Environment.cpp
./src/pdal/plang/Redirector.cpp
./src/pdal/plang/Script.cpp
LINK_WITH
${numpy_reader}
${Python3_LIBRARIES}
Expand All @@ -225,12 +226,12 @@ if (WITH_TESTS)
)
PDAL_PYTHON_ADD_TEST(pdal_filters_python_test
FILES
./pdal/test/PythonFilterTest.cpp
./pdal/test/Support.cpp
./pdal/plang/Invocation.cpp
./pdal/plang/Environment.cpp
./pdal/plang/Redirector.cpp
./pdal/plang/Script.cpp
./src/pdal/test/PythonFilterTest.cpp
./src/pdal/test/Support.cpp
./src/pdal/plang/Invocation.cpp
./src/pdal/plang/Environment.cpp
./src/pdal/plang/Redirector.cpp
./src/pdal/plang/Script.cpp
LINK_WITH
${python_filter}
${Python3_LIBRARIES}
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The repository for PDAL's Python plugins is available at https://github.com/PDAL
Requirements
================================================================================

* PDAL 2.4+
* Python >=3.7
* PDAL 2.6+
* Python >=3.9
* Numpy (eg :code:`pip install numpy`)
* scikit-build (eg :code:`pip install scikit-build`)
* scikit-build-core (eg :code:`pip install scikit-build-core`)
74 changes: 73 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
[project]
name = "pdal-plugins"
description = "Point cloud data processing Python plugins"
readme = "README.rst"
requires-python = ">=3.9"
license = {file = "LICENSE"}
keywords = ["point", "cloud", "spatial"]
authors = [
{email = "[email protected]"},
{name = "Howard Butler"}
]
maintainers = [
{name = "Howard Butler", email = "[email protected]"}
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: GIS",
]

dependencies = [
"numpy"
]

#dynamic = ["version"]

#[tool.scikit-build.dynamic]
#version = { attr = "pdal.__version__" }
version="1.4.0"

[project.optional-dependencies]
test = [
]

[tool.setuptools]
package-dir = {"" = "src"}
zip-safe = false

[project.urls]
homepage = "https://pdal.io"
documentation = "https://pdal.io"
repository = "https://github.com/PDAL/python-plugins"
changelog = "https://github.com/PDAL/python-plugins/blob/main/README.rst"

[build-system]
requires = ["scikit-build", "cmake", "ninja", "numpy"]
requires = ["scikit-build-core", "numpy", "pybind11[global]"]
build-backend = "scikit_build_core.build"

#[tool.scikit-build-core]
#wheel.py-api = "cp12"
#wheel.cmake = true


[tool.scikit-build]
build-dir = "build/{wheel_tag}/{build_type}"
sdist.exclude = [".github"]
sdist.cmake = true
cmake.build-type = "Release"
sdist.include = [
"src",
"CMakeLists.txt"
]
cmake.verbose = true
logging.level = "INFO"

#[tool.scikit-build.cmake.define]
#WITH_TESTS = "ON"
31 changes: 0 additions & 31 deletions setup.py

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.
6 changes: 3 additions & 3 deletions pdal/test/TestConfig.hpp → src/pdal/test/TestConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
#ifndef UNITTEST_TESTCONFIG_INCLUDED
#define UNITTEST_TESTCONFIG_INCLUDED

#define UNITTEST_TESTCONFIG_DATA_PATH "./pdal/test/data/"
#define UNITTEST_TESTCONFIG_CONFIGURED_PATH "./pdal/test/data/"
#define UNITTEST_TESTCONFIG_DATA_PATH "./src/pdal/test/data/"
#define UNITTEST_TESTCONFIG_CONFIGURED_PATH "./src/pdal/test/data/"
#define UNITTEST_TESTCONFIG_BINARY_PATH ""
#define UNITTEST_TESTCONFIG_OCI_CONNECTION ""

#include <string>

namespace TestConfig
namespace TestConfig
{

inline std::string dataPath()
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pipeline":[
"./pdal/test/data/1.2-with-color.las",
"./src/pdal/test/data/1.2-with-color.las",
{
"type":"filters.crop",
"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))",
Expand All @@ -13,7 +13,7 @@
"module":"anything"
},
{
"filename":"./pdal/test/temp/crop-wkt-2d-classification.las",
"filename":"./src/pdal/test/temp/crop-wkt-2d-classification.las",
"compression":false
}
]
Expand Down
Loading

0 comments on commit a77508a

Please sign in to comment.