Skip to content

Commit fa49690

Browse files
Add pip pipeline for wheels (#87)
* Add pip pipeline for wheels * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove comment Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ce6004c commit fa49690

29 files changed

+329
-224
lines changed

Diff for: .github/workflows/pip.yaml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types:
7+
- published
8+
9+
env:
10+
CIBW_TEST_COMMAND: pytest {project}/test
11+
CIBW_TEST_EXTRAS: test
12+
CIBW_SKIP: "cp310-win* *_i686" # just exclude platforms that error :))
13+
14+
jobs:
15+
build_sdist:
16+
name: Build SDist
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
submodules: true
22+
23+
- uses: actions/checkout@v2
24+
with:
25+
repository: hobu/laz-perf
26+
ref: 3.0.0
27+
path: libs/laz-perf
28+
29+
- name: Build SDist
30+
run: pipx run build --sdist
31+
32+
- name: Check metadata
33+
run: pipx run twine check dist/*
34+
35+
- uses: actions/upload-artifact@v2
36+
with:
37+
path: dist/*.tar.gz
38+
39+
40+
build_wheels:
41+
name: Wheels on ${{ matrix.os }}
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
os: [ubuntu-latest, macos-latest, windows-latest]
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
with:
51+
submodules: true
52+
53+
- uses: actions/checkout@v2
54+
with:
55+
repository: hobu/laz-perf
56+
ref: 3.0.0
57+
path: libs/laz-perf
58+
59+
- uses: suisei-cn/actions-download-file@v1
60+
name: Download autzen
61+
with:
62+
url: "https://github.com/PDAL/data/raw/a3d2a351ca1002c7ea4daa96b5c5fcb0fafeaa6f/autzen/autzen-classified.copc.laz"
63+
target: test/data/
64+
65+
- uses: pypa/[email protected]
66+
67+
- name: Verify clean directory
68+
run: git diff --exit-code
69+
shell: bash
70+
71+
- name: Upload wheels
72+
uses: actions/upload-artifact@v2
73+
with:
74+
path: wheelhouse/*.whl
75+
76+
77+
upload_all:
78+
name: Upload if release
79+
needs: [build_wheels, build_sdist]
80+
runs-on: ubuntu-latest
81+
#if: github.event_name == 'release' && github.event.action == 'published'
82+
83+
steps:
84+
- uses: actions/setup-python@v2
85+
86+
- uses: actions/download-artifact@v2
87+
with:
88+
name: artifact
89+
path: dist
90+
91+
- uses: pypa/[email protected]
92+
with:
93+
user: __token__
94+
password: ${{ secrets.pypi_password }}

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ share/python-wheels/
6262
MANIFEST
6363

6464
/CMakeSettings.json
65+
66+
/_skbuild/

Diff for: .gitmodules

-7
This file was deleted.

Diff for: .pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
exclude: version
2+
13
repos:
24
- repo: https://github.com/pre-commit/pre-commit-hooks
35
rev: v4.1.0 # Use the ref you want to point at

Diff for: .release-it.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"plugins": {
1111
"@release-it/bumper": {
12-
"out": [ "setup.py", "CMakeLists.txt" ]
12+
"out": [ "version" ]
1313
},
1414
"@release-it/keep-a-changelog": {
1515
"filename": "CHANGELOG.md",

Diff for: CMakeLists.txt

+35-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
cmake_minimum_required(VERSION 3.15)
22

33
# ref https://github.com/robotology/how-to-export-cpp-library/blob/master/CMakeLists.txt
4+
file(READ "version" ver)
45
project(COPCLIB
56
LANGUAGES CXX C
6-
VERSION 2.2.0)
7+
VERSION ${ver})
78

89
# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros.
910
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
@@ -15,9 +16,8 @@ option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
1516

1617
option(WITH_TESTS "Build test and example files." OFF)
1718
option(WITH_PYTHON "Build python bindings." OFF)
18-
option(ONLY_PYTHON "Build only python bindings, for setup.py env" OFF)
1919

20-
if (ONLY_PYTHON)
20+
if (SKBUILD)
2121
set(WITH_PYTHON ON)
2222
set(WITH_TESTS OFF)
2323
set(BUILD_SHARED_LIBS ON)
@@ -51,6 +51,9 @@ endif()
5151
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
5252
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
5353

54+
# fix for static libraries
55+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
56+
5457
# Under MSVC, we set CMAKE_DEBUG_POSTFIX to "d" to add a trailing "d" to library
5558
# built in debug mode. In this Windows user can compile, build and install the
5659
# library in both Release and Debug configuration avoiding naming clashes in the
@@ -80,10 +83,26 @@ if(WITH_TESTS)
8083
enable_testing()
8184
endif()
8285

83-
# Find required packages
84-
# LAZPERF
86+
## Find required packages
87+
8588
set(LAZPERF_VERSION "3.0.0")
86-
find_package(LAZPERF ${LAZPERF_VERSION} REQUIRED)
89+
# First, see if the repo is cloned locally, and if so, compile it
90+
# this is required for CI build of sdist
91+
if(EXISTS "${CMAKE_SOURCE_DIR}/libs/laz-perf")
92+
set(WITH_TEST_TEMP ${WITH_TESTS})
93+
set(WITH_TESTS OFF) # never build lazperf tests
94+
add_subdirectory(libs/laz-perf)
95+
include_directories(libs/laz-perf/cpp)
96+
set(WITH_TESTS ${WITH_TEST_TEMP})
97+
set(LAZPERF_LIB_NAME "lazperf")
98+
set(LAZPERF_IS_FOUND ON)
99+
set(EXTRA_EXPORT_TARGETS "lazperf")
100+
else()
101+
# if not, assume lazperf is installed on the system
102+
find_package(LAZPERF ${LAZPERF_VERSION} REQUIRED)
103+
set(LAZPERF_LIB_NAME "LAZPERF::lazperf")
104+
set(EXTRA_EXPORT_TARGETS "")
105+
endif()
87106

88107
# Enable RPATH support for installed binaries and libraries
89108
include(AddInstallRPATHSupport)
@@ -101,6 +120,7 @@ if(NOT CMAKE_CONFIGURATION_TYPES)
101120
endif()
102121

103122
### Compile- and install-related commands.
123+
104124
add_subdirectory(cpp)
105125

106126
# Create and install CMake configuration files for your project that are
@@ -120,13 +140,15 @@ add_subdirectory(cpp)
120140
# Note that if your library depends from other libraries, you are probably
121141
# required to used the install_basic_package_files() DEPENDENCIES option.
122142
include(InstallBasicPackageFiles)
123-
install_basic_package_files(${PROJECT_NAME}
124-
VERSION ${${PROJECT_NAME}_VERSION}
125-
COMPATIBILITY AnyNewerVersion
126-
VARS_PREFIX ${PROJECT_NAME}
127-
DEPENDENCIES "LAZPERF ${LAZPERF_VERSION} REQUIRED"
128-
FIRST_TARGET copc-lib
129-
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
143+
if (NOT SKBUILD)
144+
install_basic_package_files(${PROJECT_NAME}
145+
VERSION ${${PROJECT_NAME}_VERSION}
146+
COMPATIBILITY AnyNewerVersion
147+
VARS_PREFIX ${PROJECT_NAME}
148+
DEPENDENCIES "LAZPERF ${LAZPERF_VERSION} REQUIRED"
149+
FIRST_TARGET copc-lib
150+
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
151+
endif()
130152
# Add the uninstall target
131153
include(AddUninstallTarget)
132154

Diff for: MANIFEST.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include CMakeLists.txt cpp/CMakeLists.txt python/CMakeLists.txt
2+
recursive-include cmake *.cmake
3+
recursive-include cpp *.cpp *.hpp
4+
recursive-include python *.cpp *.py
5+
include README.md CHANGELOG.md LICENSE.md setup.py version pyproject.toml
6+
7+
include libs/laz-perf/CMakeLists.txt libs/laz-perf/cpp/CMakeLists.txt
8+
recursive-include libs/laz-perf/cpp/lazperf *.cpp *.hpp
9+
recursive-include libs/laz-perf/cmake *.cmake
10+
recursive-include libs/laz-perf/cpp/benchmarks *.*
11+
recursive-include libs/laz-perf/cpp/tools *.*

Diff for: cmake/DownloadExampleFiles.cmake

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
macro(download_test_files OUT_PATH)
2-
32
if(NOT EXISTS ${OUT_PATH})
43
if (EXISTS ${BaseAutzenFilePath})
54
file(WRITE ${OUT_PATH}) # this will create any necessary pathes, as CREATE_LINK doens't
@@ -9,7 +8,7 @@ macro(download_test_files OUT_PATH)
98
file (DOWNLOAD
109
"https://github.com/PDAL/data/raw/a3d2a351ca1002c7ea4daa96b5c5fcb0fafeaa6f/autzen/autzen-classified.copc.laz"
1110
${OUT_PATH}
12-
)
11+
) # be sure to update this path in .github/workflows/pip.yaml as well!
1312

1413
set(BaseAutzenFilePath "${OUT_PATH}" PARENT_SCOPE)
1514
endif()

Diff for: cpp/CMakeLists.txt

+35-20
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,44 @@ set(${LIBRARY_TARGET_NAME}_SRC
4545
src/las/vlr.cpp
4646
)
4747

48-
add_library(${LIBRARY_TARGET_NAME} ${${LIBRARY_TARGET_NAME}_SRC} ${${LIBRARY_TARGET_NAME}_HDR})
49-
add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME})
48+
# Compile static library for pip wheels
49+
if (WITH_PYTHON)
50+
add_library(${LIBRARY_TARGET_NAME}-s STATIC ${${LIBRARY_TARGET_NAME}_SRC} ${${LIBRARY_TARGET_NAME}_HDR})
51+
set_target_properties(${LIBRARY_TARGET_NAME}-s PROPERTIES VERSION ${${PROJECT_NAME}_VERSION})
52+
target_include_directories(${LIBRARY_TARGET_NAME}-s PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
53+
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
54+
if (LAZPERF_IS_FOUND)
55+
target_link_libraries(${LIBRARY_TARGET_NAME}-s PRIVATE lazperf_s)
56+
else()
57+
target_link_libraries(${LIBRARY_TARGET_NAME}-s PRIVATE ${LAZPERF_LIB_NAME})
58+
endif()
59+
message(STATUS "Created target ${LIBRARY_TARGET_NAME}-s for export ${PROJECT_NAME}.")
60+
endif()
5061

51-
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION})
52-
#PUBLIC_HEADER "${${LIBRARY_TARGET_NAME}_HDR}")
62+
if (NOT SKBUILD)
63+
add_library(${LIBRARY_TARGET_NAME} ${${LIBRARY_TARGET_NAME}_SRC} ${${LIBRARY_TARGET_NAME}_HDR})
64+
add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME})
5365

54-
# Specify include directories for both compilation and installation process.
55-
# The $<INSTALL_PREFIX> generator expression is useful to ensure to create
56-
# relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages
57-
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
58-
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
66+
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION})
67+
68+
# Specify include directories for both compilation and installation process.
69+
# The $<INSTALL_PREFIX> generator expression is useful to ensure to create
70+
# relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages
71+
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
72+
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
5973

60-
target_link_libraries(${LIBRARY_TARGET_NAME} PUBLIC LAZPERF::lazperf)
74+
target_link_libraries(${LIBRARY_TARGET_NAME} PUBLIC ${LAZPERF_LIB_NAME})
6175

62-
# Specify installation targets, typology and destination folders.
63-
install(TARGETS ${LIBRARY_TARGET_NAME}
64-
EXPORT ${PROJECT_NAME}
65-
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
66-
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
67-
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin)
68-
# PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBRARY_TARGET_NAME}" COMPONENT dev)
76+
# Specify installation targets, typology and destination folders.
77+
install(TARGETS ${LIBRARY_TARGET_NAME} ${EXTRA_EXPORT_TARGETS}
78+
EXPORT ${PROJECT_NAME}
79+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
80+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
81+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin)
82+
# PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBRARY_TARGET_NAME}" COMPONENT dev)
6983

70-
# Keep header file hierarchy
71-
install(DIRECTORY "include/${LIBRARY_TARGET_NAME}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
84+
# Keep header file hierarchy
85+
install(DIRECTORY "include/${LIBRARY_TARGET_NAME}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
7286

73-
message(STATUS "Created target ${LIBRARY_TARGET_NAME} for export ${PROJECT_NAME}.")
87+
message(STATUS "Created target ${LIBRARY_TARGET_NAME} for export ${PROJECT_NAME}.")
88+
endif()

Diff for: cpp/include/copc-lib/geometry/vector3.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef COPCLIB_GEOMETRY_VECTOR3_H_
22
#define COPCLIB_GEOMETRY_VECTOR3_H_
33

4+
#include <limits>
45
#include <sstream>
56
#include <vector>
67

Diff for: example/__init__.py

Whitespace-only changes.

Diff for: example/example-reader.py renamed to example/example_reader.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import copclib as copc
2+
import os
3+
4+
DATADIRECTORY = os.path.join(os.path.dirname(__file__), "..", "test", "data")
25

36

47
def reader_example():
58
# Create a reader object
6-
reader = copc.FileReader("autzen-classified.copc.laz")
9+
reader = copc.FileReader(os.path.join(DATADIRECTORY, "autzen-classified.copc.laz"))
710

811
# Get the Las Header
912
las_header = reader.copc_config.las_header

0 commit comments

Comments
 (0)