Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c08ba4

Browse files
committed
Build system (scikit-build-core + CMake), uppdate pyprojec.tmol
1 parent dc151c8 commit 5c08ba4

3 files changed

Lines changed: 120 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(tmap_ogdf LANGUAGES CXX)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
7+
8+
option(TMAP_OPTIONAL_OGDF "Build OGDF layout extension if available" ON)
9+
10+
# Find pybind11
11+
find_package(pybind11 CONFIG REQUIRED)
12+
13+
# Find OGDF - try CONFIG first, then manual
14+
set(OGDF_FOUND_METHOD "")
15+
16+
find_package(OGDF CONFIG QUIET)
17+
if(OGDF_FOUND)
18+
set(OGDF_FOUND_METHOD "cmake-config")
19+
endif()
20+
21+
# Fallback: environment variable (supports both installed and build-dir layouts)
22+
if(NOT OGDF_FOUND AND DEFINED ENV{OGDF_DIR})
23+
set(OGDF_DIR "$ENV{OGDF_DIR}")
24+
25+
# Try installed layout first: ${OGDF_DIR}/include, ${OGDF_DIR}/lib
26+
if(EXISTS "${OGDF_DIR}/include/ogdf" AND EXISTS "${OGDF_DIR}/lib")
27+
set(OGDF_INCLUDE_DIR "${OGDF_DIR}/include")
28+
set(OGDF_LIB_DIR "${OGDF_DIR}/lib")
29+
set(OGDF_FOUND_METHOD "env-var-installed")
30+
# Try build directory layout: ${OGDF_DIR}/include, ${OGDF_DIR}/build
31+
elseif(EXISTS "${OGDF_DIR}/include/ogdf" AND EXISTS "${OGDF_DIR}/build")
32+
set(OGDF_INCLUDE_DIR "${OGDF_DIR}/include")
33+
set(OGDF_LIB_DIR "${OGDF_DIR}/build")
34+
# OGDF build generates config_autogen.h in build/include/ogdf-release/
35+
if(EXISTS "${OGDF_DIR}/build/include/ogdf-release")
36+
set(OGDF_BUILD_INCLUDE_DIR "${OGDF_DIR}/build/include/ogdf-release")
37+
endif()
38+
set(OGDF_FOUND_METHOD "env-var-build")
39+
endif()
40+
41+
if(OGDF_LIB_DIR)
42+
find_library(OGDF_LIBRARY NAMES OGDF ogdf PATHS ${OGDF_LIB_DIR} NO_DEFAULT_PATH)
43+
find_library(COIN_LIBRARY NAMES COIN coin PATHS ${OGDF_LIB_DIR} NO_DEFAULT_PATH)
44+
45+
if(OGDF_LIBRARY)
46+
set(OGDF_FOUND TRUE)
47+
endif()
48+
endif()
49+
endif()
50+
51+
# Build extension if OGDF found
52+
if(TMAP_OPTIONAL_OGDF AND OGDF_FOUND)
53+
message(STATUS "")
54+
message(STATUS "=== OGDF Configuration ===")
55+
message(STATUS " Found via: ${OGDF_FOUND_METHOD}")
56+
if(OGDF_INCLUDE_DIR)
57+
message(STATUS " Include: ${OGDF_INCLUDE_DIR}")
58+
endif()
59+
if(OGDF_BUILD_INCLUDE_DIR)
60+
message(STATUS " Build include: ${OGDF_BUILD_INCLUDE_DIR}")
61+
endif()
62+
if(OGDF_LIBRARY)
63+
message(STATUS " Library: ${OGDF_LIBRARY}")
64+
endif()
65+
if(COIN_LIBRARY)
66+
message(STATUS " COIN: ${COIN_LIBRARY}")
67+
endif()
68+
message(STATUS "")
69+
70+
add_subdirectory(cpp)
71+
else()
72+
message(STATUS "")
73+
message(WARNING "OGDF not found - layout extension will NOT be built.")
74+
message(WARNING "To enable: install OGDF and set OGDF_DIR=/path/to/ogdf")
75+
message(WARNING " macOS: brew install ogdf")
76+
message(WARNING " Linux: apt install libogdf-dev (or build from source)")
77+
message(STATUS "")
78+
endif()

cpp/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# OGDF layout extension for TMAP
2+
3+
pybind11_add_module(_tmap_ogdf
4+
src/layout.cpp
5+
src/bindings.cpp
6+
)
7+
8+
# Include directories
9+
target_include_directories(_tmap_ogdf PRIVATE
10+
${CMAKE_CURRENT_SOURCE_DIR}/include
11+
)
12+
13+
# Handle OGDF found via find_package vs manual
14+
if(TARGET OGDF::OGDF)
15+
# Modern CMake config
16+
target_link_libraries(_tmap_ogdf PRIVATE OGDF::OGDF)
17+
else()
18+
# Manual paths
19+
target_include_directories(_tmap_ogdf PRIVATE ${OGDF_INCLUDE_DIR})
20+
if(OGDF_BUILD_INCLUDE_DIR)
21+
target_include_directories(_tmap_ogdf PRIVATE ${OGDF_BUILD_INCLUDE_DIR})
22+
endif()
23+
target_link_libraries(_tmap_ogdf PRIVATE ${OGDF_LIBRARY})
24+
if(COIN_LIBRARY)
25+
target_link_libraries(_tmap_ogdf PRIVATE ${COIN_LIBRARY})
26+
endif()
27+
endif()
28+
29+
# Install to tmap/layout/
30+
install(TARGETS _tmap_ogdf LIBRARY DESTINATION .)

pyproject.toml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
2+
requires = ["scikit-build-core>=0.8", "pybind11>=2.11"]
3+
build-backend = "scikit_build_core.build"
44

55
[project]
66
name = "tmap"
77
version = "0.1.0"
88
description = "Tree-based visualization for high-dimensional data"
99
readme = "README.md"
10-
license = "MIT"
10+
license = {text = "MIT"}
1111
requires-python = ">=3.12"
1212
authors = [
1313
{ name = "Alejandro Flores", email = "[email protected]" }
1414
]
1515
classifiers = [
1616
"Development Status :: 3 - Alpha",
1717
"Intended Audience :: Science/Research",
18-
"License :: OSI Approved :: MIT License",
1918
"Programming Language :: Python :: 3",
2019
"Programming Language :: Python :: 3.12",
2120
"Programming Language :: Python :: 3.13",
@@ -31,37 +30,37 @@ faiss = ["faiss-cpu>=1.7"]
3130
faiss-gpu = ["faiss-gpu>=1.7"]
3231
annoy = ["annoy>=1.17"]
3332
viz = ["jinja2>=3.1"]
34-
fast = ["numba>=0.59"] # JIT-compiled MinHash (50-100x faster for binary data)
33+
fast = ["numba>=0.59"]
3534
dev = [
3635
"numba>=0.59",
3736
"pytest>=7.0",
3837
"pytest-cov>=4.0",
3938
"ruff>=0.1",
4039
"mypy>=1.0",
4140
]
41+
ogdf = [] # Marker only - OGDF must be installed system-wide
4242
all = ["tmap[faiss,annoy,viz,fast,dev]"]
4343

4444
[project.urls]
4545
Homepage = "https://github.com/afloresep/TMAP"
4646
Documentation = "https://github.com/afloresep/TMAP#readme"
4747
Repository = "https://github.com/afloresep/TMAP"
4848

49-
[tool.hatch.build.targets.wheel]
50-
packages = ["src/tmap"]
49+
[tool.scikit-build]
50+
wheel.packages = ["src/tmap"]
51+
cmake.build-type = "Release"
52+
build.verbose = true
53+
wheel.install-dir = "tmap/layout"
5154

52-
[tool.hatch.build.targets.wheel.force-include]
53-
"src/tmap/visualization/templates" = "tmap/visualization/templates"
54-
"src/tmap/visualization/static" = "tmap/visualization/static"
55-
"src/tmap/visualization/vendor" = "tmap/visualization/vendor"
55+
[tool.scikit-build.cmake.define]
56+
TMAP_OPTIONAL_OGDF = "ON"
5657

5758
[tool.ruff]
5859
line-length = 100
5960
target-version = "py312"
6061

6162
[tool.ruff.lint]
6263
select = ["E", "F", "I", "N", "W", "UP"]
63-
# E741/E743: Allow 'l' as variable name (standard TMAP API for number of bands)
64-
# N806: Allow CONSTANT naming inside Numba functions
6564
ignore = ["E741", "E743", "N806"]
6665

6766
[tool.mypy]

0 commit comments

Comments
 (0)