Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pypi #196

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(teaserpp VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 14)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious; is compile_commands.json needed to support pip installation?

Copy link
Author

@EmDash00 EmDash00 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is not. The compile flags just are convenient for development. The C++ linters and LSPs can use them to locate included libraries like pybind and Eigen so I don't get a billion errors everywhere and can get completion from the included libraries. I use clangd as my LSP so it's just helpful for me. I'm not sure if VSCode or other IDEs have more automatic detection. I'm just using a barebones setup with Neovim and their built-in LSP/linting support.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your kind answer. I thought compile_commands.json was needed pip3. But isn't can be produced by -DCMAKE_EXPORT_COMPILE_COMMANDS=1?

Copy link
Author

@EmDash00 EmDash00 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can yeah. I think when building with scikit-build it was easier just to put it in the file since I had to figure out a way to pass it through in the pyproject file. We could probably put a switch there where they aren't made during release builds.


# Check build types
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand All @@ -12,6 +13,10 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
STRING "Choose the type of build." FORCE)
endif ()

if (DEFINED SKBUILD)
message(STATUS "Building with Scikit-Build")
endif ()

# Options
option(BUILD_TESTS "Build tests" ON)
option(BUILD_TEASER_FPFH "Build TEASER++ wrappers for PCL FPFH estimation." OFF)
Expand Down
4 changes: 2 additions & 2 deletions cmake/pybind11.CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ project(pybind11-download NONE)
include(ExternalProject)
ExternalProject_Add(pmc
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.11.1
GIT_TAG v2.13.6
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/pybind11-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
)
154 changes: 154 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
[build-system]
requires = ["scikit_build_core", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
name = "teaserpp_python"
version = "1.1.0"
description = "Python binding for TEASER++"
readme = "README.md"
authors = [
{ name = "Jingnan Shi", email = "[email protected]" },
]
keywords = [
"Point cloud",
"Registration",
"Non-minimal solver",
"Solver",
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Other Audience",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"numpy",
]

[project.urls]
Homepage = "https://github.com/MIT-SPARK/TEASER-plusplus"

[tool.scikit-build]
build-dir = "build/{wheel_tag}"
build.verbose = false
cmake.version = ">=3.16"
wheel.install-dir = "teaserpp_python.libs"

[tool.cibuildwheel]
archs = ["auto64"]
skip = ["*-musllinux*", "pp*", "cp36-*"]

[tool.cibuildwheel.macos]
environment = "MACOSX_DEPLOYMENT_TARGET=10.14"
archs = ["auto64", "arm64"]

[tool.pyright]
venvPath = "."
venv = ".venv"

typeCheckingMode = "standard"
reportUnusedImport = "none"
reportUnusedFunction = "none"
reportUnusedVariable = "none"
reportUndefinedVariable = "none"


[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.9
target-version = "py39"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F", "I001"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

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

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

[dependency-groups]
dev = [
"basedpyright>=1.22.0",
"ruff>=0.8.1",
]
26 changes: 22 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same question) I'm just curious; is compile_commands.json needed to support pip installation?


project(teaser_python_bindings)

Expand All @@ -24,16 +25,23 @@ endif ()

# make sure to output the build file to teaserpp_python folder
SET_TARGET_PROPERTIES(teaserpp_python
PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python"
)
PROPERTIES
OUTPUT_NAME "_teaserpp"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python"
INSTALL_RPATH "$ORIGIN/../teaserpp_python.libs/lib;$ORIGIN/../../teaser/"
BUILD_WITH_INSTALL_RPATH TRUE
)

# copy package __init__.py file
configure_file(teaserpp_python/__init__.py
${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python/__init__.py
)

configure_file(teaserpp_python/__init__.py
${CMAKE_CURRENT_BINARY_DIR}/teaserpp_python/_teaserpp.pyi
)

# copy setup.py file
configure_file(setup.py.in
${CMAKE_CURRENT_BINARY_DIR}/setup.py
Expand All @@ -43,3 +51,13 @@ file(COPY .
DESTINATION .
FILES_MATCHING
PATTERN *.py)

if (DEFINED SKBUILD)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/teaserpp/
DESTINATION "../teaserpp"
FILES_MATCHING PATTERN "*.py"
PATTERN "*.pyi"
PATTERN "*.so"
)
install(TARGETS teaserpp_python DESTINATION "../teaserpp_python")
endif ()
38 changes: 37 additions & 1 deletion python/teaserpp_python/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
from .teaserpp_python import *
from enum import IntEnum
from typing import NamedTuple

from ._teaserpp import (
OMP_MAX_THREADS,
CertificationResult,
DRSCertifier,
EigSolverType,
InlierGraphFormulation,
InlierSelectionMode,
RegistrationSolution,
RobustRegistrationSolver,
RotationEstimationAlgorithm,
)

# Backwards compatibility with v1.0 so we don't break code
RobustRegistrationSolver.ROTATION_ESTIMATION_ALGORITHM = RotationEstimationAlgorithm
RobustRegistrationSolver.INLIER_SELECTION_MODE = InlierSelectionMode
RobustRegistrationSolver.INLIER_GRAPH_FORMULATION = InlierGraphFormulation
DRSCertifier.EIG_SOLVER_TYPE = EigSolverType


class RobustRegistrationSolverParams(NamedTuple):
noise_bound: float = 0.01
cbar2: float = 1
estimate_scaling: bool = True
rotation_estimation_algorithm: RotationEstimationAlgorithm = RotationEstimationAlgorithm.GNC_TLS
rotation_gnc_factor: float = 1.4
rotation_max_iterations: int = 100
rotation_cost_threshold: float = 1e-6
rotation_tim_graph: InlierGraphFormulation = InlierGraphFormulation.CHAIN
inlier_selection_mode: InlierSelectionMode = InlierSelectionMode.PMC_EXACT
kcore_heuristic_threshold: float = 0.5
use_max_clique: bool = True
max_clique_exact_solution: bool = True
max_clique_time_limit: int = 3000
max_clique_num_threads: int = OMP_MAX_THREADS
Loading