Skip to content

fix: work around pip bug #605

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\
UPDATE_COMMAND ""
CMAKE_CACHE_ARGS
-D${PROJECT_NAME}_SUPERBUILD:BOOL=0
-DSKBUILD_SCRIPTS_DIR:PATH=${SKBUILD_SCRIPTS_DIR}
-DBUILD_CMAKE_FROM_SOURCE:BOOL=${BUILD_CMAKE_FROM_SOURCE}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
${${PROJECT_NAME}_CMAKE_CACHE_ARG}
Expand Down Expand Up @@ -448,5 +449,12 @@ include\(\"${CMakeProject_BINARY_DIR}/cmake_install.cmake\")
endif()
install(${type} ${file} DESTINATION "${relative_directory}" ${_permissions})
endforeach()
endif()

endif()
# Prepare entry points
foreach(program IN ITEMS cmake ctest cpack ccmake)
configure_file(scripts/entry-point.py.in "${CMAKE_CURRENT_BINARY_DIR}/bin/${program}")
message(STATUS "INSTALLING TO: ${SKBUILD_SCRIPTS_DIR}")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/bin/${program}" DESTINATION "${SKBUILD_SCRIPTS_DIR}")
endforeach()
endif()
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ Source = "https://github.com/scikit-build/cmake-python-distributions"
"Mailing list" = "https://groups.google.com/forum/#!forum/scikit-build"
"Bug Tracker" = "https://github.com/scikit-build/cmake-python-distributions/issues"

[project.scripts]
ccmake = "cmake:ccmake"
cmake = "cmake:cmake"
cpack = "cmake:cpack"
ctest = "cmake:ctest"


[dependency-groups]
test = [
Expand Down
21 changes: 21 additions & 0 deletions scripts/entry-point.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!python

import os
import sys
import sysconfig

# Scripts can be broken by pip's build isolation hacks
# See: https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
pl = sysconfig.get_paths()['platlib']
if pl not in sys.path:
sys.path.append(pl)

from cmake import ${program}

if __name__ == '__main__':
if sys.argv[0].endswith('-script.pyw'):
sys.argv[0] = sys.argv[0][: -11]
elif sys.argv[0].endswith('.exe'):
sys.argv[0] = sys.argv[0][: -4]

sys.exit(${program}())
Loading