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)
endif
()
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
execute_process
(
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
"import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
RESULT_VARIABLE PYTHON_IS_DEBUG
)
if
(
NOT DEFINED PYTHON_IS_DEBUG
)
# Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
execute_process
(
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
# required for PyPy3 (as of 7.3.1)
execute_process
(
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
_PYTHON_MODULE_EXTENSION STREQUAL
""
)
message
(
FATAL_ERROR
"pybind11 could not query the module file extension, likely the 'distutils'"
"package is not installed. Full error message:
\n
${
_PYTHON_MODULE_EXTENSION_ERR
}
"
)
endif
()
if
(
NOT DEFINED PYTHON_MODULE_EXTENSION
)
execute_process
(
COMMAND
"
${${
_Python
}
_EXECUTABLE
}
"
"-c"
"from distutils import sysconfig; print(sysconfig.get_config_var('SO'))"
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
_PYTHON_MODULE_EXTENSION STREQUAL
""
)
message
(
FATAL_ERROR
"pybind11 could not query the module file extension, likely the 'distutils'"
"package is not installed. Full error message:
\n
${
_PYTHON_MODULE_EXTENSION_ERR
}
"
)
endif
()
# This needs to be available for the pybind11_extension function
set
(
PYTHON_MODULE_EXTENSION
"
${
_PYTHON_MODULE_EXTENSION
}
"
CACHE INTERNAL
""
)
# This needs to be available for the pybind11_extension function
set
(
PYTHON_MODULE_EXTENSION
"
${
_PYTHON_MODULE_EXTENSION
}
"
CACHE INTERNAL
""
)
endif
()
# Python debug libraries expose slightly different objects before 3.8
# 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