Skip to content

Commit ea44dcb

Browse files
committed
fix: work around pip bug
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 546a348 commit ea44dcb

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\
368368
UPDATE_COMMAND ""
369369
CMAKE_CACHE_ARGS
370370
-D${PROJECT_NAME}_SUPERBUILD:BOOL=0
371+
-DSKBUILD_SCRIPTS_DIR:PATH=${SKBUILD_SCRIPTS_DIR}
371372
-DBUILD_CMAKE_FROM_SOURCE:BOOL=${BUILD_CMAKE_FROM_SOURCE}
372373
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
373374
${${PROJECT_NAME}_CMAKE_CACHE_ARG}
@@ -448,5 +449,12 @@ include\(\"${CMakeProject_BINARY_DIR}/cmake_install.cmake\")
448449
endif()
449450
install(${type} ${file} DESTINATION "${relative_directory}" ${_permissions})
450451
endforeach()
452+
453+
# Prepare entry points
454+
foreach(program IN ITEMS cmake ctest cpack ccmake)
455+
configure_file(scripts/entry-point.py.in "${CMAKE_CURRENT_BINARY_DIR}/bin/${program}")
456+
message(STATUS "INSTALLING TO: ${SKBUILD_SCRIPTS_DIR}")
457+
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/bin/${program}" DESTINATION "${SKBUILD_SCRIPTS_DIR}")
458+
endforeach()
451459
endif()
452460
endif()

pyproject.toml

-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ Source = "https://github.com/scikit-build/cmake-python-distributions"
3838
"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build"
3939
"Bug Tracker" = "https://github.com/scikit-build/cmake-python-distributions/issues"
4040

41-
[project.scripts]
42-
ccmake = "cmake:ccmake"
43-
cmake = "cmake:cmake"
44-
cpack = "cmake:cpack"
45-
ctest = "cmake:ctest"
46-
4741

4842
[dependency-groups]
4943
test = [

scripts/entry-point.py.in

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
import sysconfig
5+
6+
# Scripts can be broken by pip's build isolation hacks
7+
# See: https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
8+
pl = sysconfig.get_paths()['platlib']
9+
if pl not in sys.path:
10+
sys.path.append(pl)
11+
12+
from cmake import ${program}
13+
14+
if __name__ == '__main__':
15+
if sys.argv[0].endswith('-script.pyw'):
16+
sys.argv[0] = sys.argv[0][: -11]
17+
elif sys.argv[0].endswith('.exe'):
18+
sys.argv[0] = sys.argv[0][: -4]
19+
20+
sys.exit(${program}())

0 commit comments

Comments
 (0)