polypix 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ build*/
2
+ dist/
3
+ site/
4
+ *.egg-info/
5
+
6
+ __pycache__/
7
+ *.py[cod]
8
+ .pytest_cache/
9
+ .cache/
10
+ .agents/
11
+ .codex/
12
+
13
+ venv*/
14
+ .venv/
15
+ third_party/
16
+
17
+ polypix/_core*.so
18
+ polypix/_core*.pyd
19
+ polypix/_vendor/
@@ -0,0 +1,149 @@
1
+ cmake_minimum_required(VERSION 3.21)
2
+
3
+ if(NOT DEFINED SKBUILD_PROJECT_NAME)
4
+ set(SKBUILD_PROJECT_NAME polypix)
5
+ endif()
6
+ if(NOT DEFINED SKBUILD_PROJECT_VERSION)
7
+ set(SKBUILD_PROJECT_VERSION 0.1.0)
8
+ endif()
9
+
10
+ project(
11
+ "${SKBUILD_PROJECT_NAME}"
12
+ VERSION "${SKBUILD_PROJECT_VERSION}"
13
+ LANGUAGES CXX
14
+ )
15
+
16
+ if(WIN32)
17
+ message(FATAL_ERROR
18
+ "Polypix does not currently support Windows builds. "
19
+ "Use Linux or macOS with healpix_cxx from the active build environment.")
20
+ endif()
21
+
22
+ set(CMAKE_CXX_STANDARD 17)
23
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
24
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
25
+
26
+ option(POLYPIX_STABLE_ABI "Build an abi3 extension using Python's stable ABI. Requires Python 3.12+." OFF)
27
+ option(POLYPIX_BUNDLE_RUNTIME_DEPS "Bundle native runtime dependencies during CMake install. Release wheels should use auditwheel/delocate/delvewheel instead." OFF)
28
+
29
+ find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
30
+
31
+ if(NOT nanobind_DIR)
32
+ execute_process(
33
+ COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
34
+ OUTPUT_VARIABLE POLYPIX_NANOBIND_DIR
35
+ RESULT_VARIABLE POLYPIX_NANOBIND_DIR_RESULT
36
+ OUTPUT_STRIP_TRAILING_WHITESPACE
37
+ ERROR_QUIET
38
+ )
39
+ if(POLYPIX_NANOBIND_DIR_RESULT EQUAL 0 AND EXISTS "${POLYPIX_NANOBIND_DIR}")
40
+ set(nanobind_DIR "${POLYPIX_NANOBIND_DIR}" CACHE PATH "nanobind CMake directory")
41
+ endif()
42
+ endif()
43
+
44
+ find_package(nanobind CONFIG REQUIRED)
45
+ find_package(PkgConfig REQUIRED)
46
+ pkg_check_modules(HEALPIX_CXX REQUIRED IMPORTED_TARGET healpix_cxx)
47
+ pkg_check_modules(CFITSIO REQUIRED IMPORTED_TARGET cfitsio)
48
+
49
+ if(APPLE)
50
+ foreach(property IN ITEMS INTERFACE_COMPILE_OPTIONS INTERFACE_LINK_OPTIONS)
51
+ get_target_property(healpix_options PkgConfig::HEALPIX_CXX "${property}")
52
+ if(healpix_options)
53
+ list(REMOVE_ITEM healpix_options "-fopenmp")
54
+ set_target_properties(PkgConfig::HEALPIX_CXX PROPERTIES
55
+ "${property}" "${healpix_options}"
56
+ )
57
+ endif()
58
+ endforeach()
59
+ endif()
60
+
61
+ set(POLYPIX_SOURCES
62
+ src/polypix/module.cpp
63
+ src/polypix/core.cpp
64
+ )
65
+
66
+ set(POLYPIX_NANOBIND_FLAGS NB_STATIC)
67
+ if(POLYPIX_STABLE_ABI)
68
+ if(Python_VERSION VERSION_LESS 3.12)
69
+ message(FATAL_ERROR "POLYPIX_STABLE_ABI requires Python 3.12 or newer.")
70
+ endif()
71
+ list(APPEND POLYPIX_NANOBIND_FLAGS STABLE_ABI)
72
+ endif()
73
+
74
+ nanobind_add_module(_core ${POLYPIX_NANOBIND_FLAGS} ${POLYPIX_SOURCES})
75
+
76
+ target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
77
+ target_link_libraries(_core PRIVATE PkgConfig::HEALPIX_CXX PkgConfig::CFITSIO)
78
+
79
+ set_target_properties(_core PROPERTIES
80
+ PREFIX ""
81
+ OUTPUT_NAME "_core"
82
+ CXX_VISIBILITY_PRESET "hidden"
83
+ VISIBILITY_INLINES_HIDDEN ON
84
+ BUILD_WITH_INSTALL_RPATH OFF
85
+ INSTALL_REMOVE_ENVIRONMENT_RPATH ON
86
+ )
87
+
88
+ if(APPLE)
89
+ set(POLYPIX_EXTENSION_RPATH "@loader_path/../polypix.libs")
90
+ elseif(UNIX)
91
+ set(POLYPIX_EXTENSION_RPATH "$ORIGIN/../polypix.libs")
92
+ else()
93
+ set(POLYPIX_EXTENSION_RPATH "")
94
+ endif()
95
+
96
+ if(POLYPIX_BUNDLE_RUNTIME_DEPS AND POLYPIX_EXTENSION_RPATH)
97
+ set_target_properties(_core PROPERTIES
98
+ INSTALL_RPATH "${POLYPIX_EXTENSION_RPATH}"
99
+ )
100
+ else()
101
+ set_target_properties(_core PROPERTIES INSTALL_RPATH "")
102
+ endif()
103
+
104
+ set_target_properties(_core PROPERTIES
105
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/polypix"
106
+ )
107
+
108
+ install(FILES
109
+ polypix/_core.pyi
110
+ polypix/py.typed
111
+ polypix/__init__.pyi
112
+ DESTINATION polypix
113
+ )
114
+
115
+ if(POLYPIX_BUNDLE_RUNTIME_DEPS)
116
+ install(TARGETS _core
117
+ RUNTIME_DEPENDENCY_SET polypix_runtime_dependencies
118
+ LIBRARY DESTINATION polypix
119
+ RUNTIME DESTINATION polypix
120
+ )
121
+ install(RUNTIME_DEPENDENCY_SET polypix_runtime_dependencies
122
+ PRE_EXCLUDE_REGEXES
123
+ "api-ms-"
124
+ "ext-ms-"
125
+ POST_EXCLUDE_REGEXES
126
+ "^/lib/"
127
+ "^/lib64/"
128
+ "^/usr/lib/"
129
+ "^/usr/lib64/"
130
+ "^/System/Library/"
131
+ "^/usr/lib/"
132
+ LIBRARY DESTINATION polypix.libs
133
+ RUNTIME DESTINATION polypix.libs
134
+ FRAMEWORK DESTINATION polypix.libs
135
+ )
136
+ else()
137
+ install(TARGETS _core LIBRARY DESTINATION polypix RUNTIME DESTINATION polypix)
138
+ if(UNIX)
139
+ install(CODE [[
140
+ file(GLOB POLYPIX_INSTALLED_EXTENSIONS
141
+ "${CMAKE_INSTALL_PREFIX}/polypix/_core*.so"
142
+ "${CMAKE_INSTALL_PREFIX}/polypix/_core*.dylib")
143
+ foreach(POLYPIX_INSTALLED_EXTENSION IN LISTS POLYPIX_INSTALLED_EXTENSIONS)
144
+ file(RPATH_REMOVE FILE "${POLYPIX_INSTALLED_EXTENSION}")
145
+ endforeach()
146
+ ]])
147
+ endif()
148
+ endif()
149
+ install(FILES polypix/__init__.py polypix/bench.py DESTINATION polypix)