Skip to content

Commit

Permalink
Merge pull request #217 from hmaarrfk/distutils
Browse files Browse the repository at this point in the history
Update to support Python 3.12
  • Loading branch information
GarrettDMorrison authored Dec 7, 2023
2 parents d6bccbd + 83c6e47 commit c7f329a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
33 changes: 0 additions & 33 deletions python/scikit-build-cmake/FindNumPy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
#
# ``NumPy_INCLUDE_DIR``
#
# .. note::
#
# To support NumPy < v0.15.0 where ``from-template`` and ``conv-template`` are not declared as entry points,
# the module emulates the behavior of standalone executables by setting the corresponding variables with the
# path the the python interpreter and the path to the associated script. For example:
# ::
#
# set(NumPy_CONV_TEMPLATE_EXECUTABLE /path/to/python /path/to/site-packages/numpy/distutils/conv_template.py CACHE STRING "Command executing conv-template program" FORCE)
#
# set(NumPy_FROM_TEMPLATE_EXECUTABLE /path/to/python /path/to/site-packages/numpy/distutils/from_template.py CACHE STRING "Command executing from-template program" FORCE)
#

cmake_policy(SET CMP0148 OLD)

Expand Down Expand Up @@ -61,28 +50,6 @@ if(NOT NumPy_FOUND)
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)

# XXX This is required to support NumPy < v0.15.0. See note in module documentation above.
if(NOT NumPy_CONV_TEMPLATE_EXECUTABLE)
execute_process(COMMAND "${PYTHON_EXECUTABLE}"
-c "from numpy.distutils import conv_template; print(conv_template.__file__)"
OUTPUT_VARIABLE _numpy_conv_template_file
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
set(NumPy_CONV_TEMPLATE_EXECUTABLE "${PYTHON_EXECUTABLE}" "${_numpy_conv_template_file}" CACHE STRING "Command executing conv-template program" FORCE)
endif()

# XXX This is required to support NumPy < v0.15.0. See note in module documentation above.
if(NOT NumPy_FROM_TEMPLATE_EXECUTABLE)
execute_process(COMMAND "${PYTHON_EXECUTABLE}"
-c "from numpy.distutils import from_template; print(from_template.__file__)"
OUTPUT_VARIABLE _numpy_from_template_file
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
set(NumPy_FROM_TEMPLATE_EXECUTABLE "${PYTHON_EXECUTABLE}" "${_numpy_from_template_file}" CACHE STRING "Command executing from-template program" FORCE)
endif()
endif()
endif()

Expand Down
10 changes: 3 additions & 7 deletions python/scikit-build-cmake/FindPythonExtensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ find_package(PythonLibs)
include(targetLinkLibrariesWithDynamicLookup)

set(_command "
import distutils.sysconfig
import sysconfig
import itertools
import os
import os.path
Expand All @@ -263,7 +263,7 @@ rel_result = None
candidate_lists = []
try:
candidate_lists.append((distutils.sysconfig.get_python_lib(),))
candidate_lists.append((sysconfig.get_paths()['purelib'],))
except AttributeError: pass
try:
Expand All @@ -284,17 +284,13 @@ for candidate in candidates:
rel_result = rel_candidate
break
ext_suffix_var = 'SO'
if sys.version_info[:2] >= (3, 5):
ext_suffix_var = 'EXT_SUFFIX'
sys.stdout.write(\";\".join((
os.sep,
os.pathsep,
sys.prefix,
result,
rel_result,
distutils.sysconfig.get_config_var(ext_suffix_var)
sysconfig.get_config_var('EXT_SUFFIX')
)))
")

Expand Down

0 comments on commit c7f329a

Please sign in to comment.