Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
d46f3322
Unverified
Commit
d46f3322
authored
Oct 09, 2020
by
Henry Schreiner
Committed by
GitHub
Oct 09, 2020
Browse files
fix: allow cmake varibles from Python calls to be cached (#2570)
parent
fecef388
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
tools/pybind11NewTools.cmake
tools/pybind11NewTools.cmake
+28
-20
No files found.
tools/pybind11NewTools.cmake
View file @
d46f3322
...
@@ -80,30 +80,38 @@ if(NOT DEFINED ${_Python}_EXECUTABLE)
...
@@ -80,30 +80,38 @@ if(NOT DEFINED ${_Python}_EXECUTABLE)
endif
()
endif
()
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
if
(
NOT DEFINED PYTHON_IS_DEBUG
)
execute_process
(
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
"import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
execute_process
(
RESULT_VARIABLE PYTHON_IS_DEBUG
)
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
"import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
RESULT_VARIABLE _PYTHON_IS_DEBUG
)
set
(
PYTHON_IS_DEBUG
"
${
_PYTHON_IS_DEBUG
}
"
CACHE INTERNAL
"Python debug status"
)
endif
()
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
# required for PyPy3 (as of 7.3.1)
# required for PyPy3 (as of 7.3.1)
execute_process
(
if
(
NOT DEFINED PYTHON_MODULE_EXTENSION
)
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
execute_process
(
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
_PYTHON_MODULE_EXTENSION STREQUAL
""
)
message
(
if
(
_PYTHON_MODULE_EXTENSION STREQUAL
""
)
FATAL_ERROR
"pybind11 could not query the module file extension, likely the 'distutils'"
message
(
"package is not installed. Full error message:
\n
${
_PYTHON_MODULE_EXTENSION_ERR
}
"
)
FATAL_ERROR
"pybind11 could not query the module file extension, likely the 'distutils'"
endif
()
"package is not installed. Full error message:
\n
${
_PYTHON_MODULE_EXTENSION_ERR
}
"
)
endif
()
# This needs to be available for the pybind11_extension function
# This needs to be available for the pybind11_extension function
set
(
PYTHON_MODULE_EXTENSION
set
(
PYTHON_MODULE_EXTENSION
"
${
_PYTHON_MODULE_EXTENSION
}
"
"
${
_PYTHON_MODULE_EXTENSION
}
"
CACHE INTERNAL
""
)
CACHE INTERNAL
""
)
endif
()
# Python debug libraries expose slightly different objects before 3.8
# Python debug libraries expose slightly different objects before 3.8
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment