Skip to content

Commit

Permalink
Merge pull request #8 from tataratat/v0.1.0
Browse files Browse the repository at this point in the history
V0.1.0
  • Loading branch information
j042 authored Jun 20, 2024
2 parents f404ea2 + 33b3b52 commit 30151ff
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 149 deletions.
42 changes: 25 additions & 17 deletions .github/workflows/build_and_upload_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,33 @@ on:
pull_request:

jobs:
macos_wheel:
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64, arm64]
cw_build: ["pp*", "cp*"]
exclude:
- arch: arm64
cw_build: "pp*"
macos_wheel_m:
runs-on: macos-14

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cw_build }}
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_ARCHS: "arm64"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

macos_wheel_intel:
runs-on: macos-13

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: "x86_64"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -45,7 +52,7 @@ jobs:
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cw_build }}
Expand All @@ -59,7 +66,7 @@ jobs:
strategy:
matrix:
arch: [aarch64, ppc64le]
cw_build: ["cp36*many*", "cp37*many*", "cp38*many*", "cp39*many*", "cp310*many*", "cp311*many*", "cp312*many*", "pp37*many*", "pp38*many*", "pp39*many*"]
cw_build: ["cp37*many*", "cp38*many*", "cp39*many*", "cp310*many*", "cp311*many*", "cp312*many*", "pp37*many*", "pp38*many*", "pp39*many*"]
exclude:
- arch: ppc64le
cw_build: "pp37*many*"
Expand Down Expand Up @@ -103,9 +110,10 @@ jobs:
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: "pp*"


- uses: actions/upload-artifact@v3
Expand All @@ -128,7 +136,7 @@ jobs:
path: ./dist/*

upload_pypi:
needs: [macos_wheel, linux_wheel, windows_wheel, source_dist]
needs: [macos_wheel_m, macos_wheel_intel, linux_wheel, windows_wheel, source_dist]
runs-on: ubuntu-latest
# try to publish only if this is a push to stable branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
Expand Down
39 changes: 13 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ ci:
autoupdate_schedule: "monthly"
submodules: false

exclude: "third_party/nanoflann.hpp"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v4.6.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -28,31 +26,20 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: "v3.15.0"
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/PyCQA/isort
rev: "5.12.0"
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: "23.10.1"
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.5
hooks:
- id: black
args: [--line-length=79]
- id: clang-format
types_or: [c, c++]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
hooks:
- id: flake8
args: [--extend-ignore=E203]
- id: cmake-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.4
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: clang-format
types_or: [c++]
- id: codespell
args: [-w]
additional_dependencies: [tomli]
90 changes: 48 additions & 42 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
cmake_minimum_required(VERSION 3.12)
project(funi VERSION 0.0.0 LANGUAGES CXX)
cmake_minimum_required(VERSION 3.17)
project(
funi
VERSION 0.1.0
LANGUAGES CXX)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

endif()

# options - default is header only
option(FUNI_PYTHON "add python ext header" ON)
# options - default is to build python module together
option(FUNI_BUILD_PYTHON "build python module" ON)

# config
set(exe_dest "bin")
Expand All @@ -20,51 +24,53 @@ set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")

# sources
set(CXX_HEADERS src/funi.hpp)

if (FUNI_PYTHON)
set(CXX_HEADERS ${CXX_HEADERS} src/pyfuni.hpp)
endif()
set(CXX_HEADERS src/axis.hpp src/lexi.hpp src/pyfuni.hpp)

# add library - header only
add_library(funi INTERFACE)
target_include_directories(funi
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${incl_dest}>)
add_library(headers INTERFACE)
target_include_directories(
headers INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${incl_dest}>)

add_library(funi::funi ALIAS funi)
set_target_properties(funi PROPERTIES CXX_STANDARD 17)
add_library(funi::headers ALIAS headers)
set_target_properties(headers PROPERTIES CXX_STANDARD 17)

if(FUNI_BUILD_PYTHON)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
python_add_library(funi MODULE src/pyfuni.cpp WITH_SOABI)
target_link_libraries(funi PRIVATE pybind11::headers funi::headers)
target_compile_definitions(funi PRIVATE $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES
"Clang")
target_compile_options(funi PRIVATE $<$<NOT:$<CONFIG:Debug>>:-O3>)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSCV")
target_compile_options(funi PRIVATE $<$<NOT:$<CONFIG:Debug>>:/O2>)
endif()
endif()

# configure config files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"cmake/config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${cfg_dest}"
)
write_basic_package_version_file("${version_config}"
COMPATIBILITY SameMajorVersion)
configure_package_config_file("cmake/config.cmake.in" "${project_config}"
INSTALL_DESTINATION "${cfg_dest}")

install(
TARGETS funi
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${lib_dest}
ARCHIVE DESTINATION ${lib_dest}
INCLUDES DESTINATION "${incl_dest}"
)
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${cfg_dest}"
)
TARGETS headers
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${lib_dest}
ARCHIVE DESTINATION ${lib_dest}
INCLUDES
DESTINATION "${incl_dest}")
install(FILES "${project_config}" "${version_config}" DESTINATION "${cfg_dest}")

install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${cfg_dest}"
)
install(
FILES ${CXX_HEADERS}
DESTINATION ${incl_dest}
)
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${cfg_dest}")
install(FILES ${CXX_HEADERS} DESTINATION ${incl_dest})

if(FUNI_BUILD_PYTHON)
install(TARGETS funi DESTINATION .)
endif()
35 changes: 23 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"pybind11",
requires = ["scikit-build-core", "pybind11>=2.12"]
build-backend = "scikit_build_core.build"

[project]
name = "funi"
version = "0.1.0"
authors = [
{name="Jaewook Lee", email="[email protected]"},
]
license = {file = "LICENSE"}
description = "Find unique float arrays."
urls = {Homepage = "https://github.com/tataratat/funi"}
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Natural Language :: English",
"Topic :: Scientific/Engineering",
]
dependencies = ["numpy"]
requires-python = '>=3.7'

build-backend = "setuptools.build_meta"
[project.readme]
file = "README.md"
content-type = "text/markdown"

[tool.cibuildwheel]
test-command = "python {project}/tests/test_funi.py"

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
test-skip = ["*arm64"]

[tool.cibuildwheel.windows]
skip = "pp*"
49 changes: 0 additions & 49 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ inline void Uff(DataType* original_points, /* in */
newpointmasks[metric_order_indices[lower_limit]] = true;
}

// Value only required for stable sort (tracks the lowest occurence id of a
// Value only required for stable sort (tracks the lowest occurrence id of a
// given point, that might be duplicate)
IndexingType current_lowest_id{metric_order_indices[lower_limit]};

Expand Down
4 changes: 3 additions & 1 deletion src/pyfuni.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>

#include <pyfuni.hpp>
#include "pyfuni.hpp"

PYBIND11_MODULE(funi, m) {
m.def("unique_rows",
Expand All @@ -10,4 +10,6 @@ PYBIND11_MODULE(funi, m) {
pybind11::arg("tolerance"),
pybind11::arg("sorted_index"),
pybind11::arg("method"));

m.attr("__version__") = "0.1.0";
}
2 changes: 1 addition & 1 deletion src/pyfuni.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ py::tuple LexiUnique(const py::array_t<DataType>& array_2d,
inverse_ptr);
}

// get unique count incase we need to return index or data
// get unique count in case we need to return index or data
const IndexType n_unique = static_cast<IndexType>(unique_ids.size());

// finally, copy unique_ids
Expand Down

0 comments on commit 30151ff

Please sign in to comment.