提交 ef7d8bb8 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Replace distutils with setuptools

上级 d69eaabd
import distutils.spawn
import errno import errno
import logging import logging
import os import os
...@@ -9,6 +8,7 @@ import sys ...@@ -9,6 +8,7 @@ import sys
import textwrap import textwrap
import numpy as np import numpy as np
from setuptools._distutils.spawn import find_executable
import aesara import aesara
import aesara.configparser import aesara.configparser
...@@ -437,7 +437,7 @@ def add_compile_configvars(): ...@@ -437,7 +437,7 @@ def add_compile_configvars():
# Try to find the full compiler path from the name # Try to find the full compiler path from the name
if param != "": if param != "":
newp = distutils.spawn.find_executable(param) newp = find_executable(param)
if newp is not None: if newp is not None:
param = newp param = newp
del newp del newp
......
...@@ -3,7 +3,6 @@ Generate and compile C modules for Python. ...@@ -3,7 +3,6 @@ Generate and compile C modules for Python.
""" """
import atexit import atexit
import distutils.sysconfig
import importlib import importlib
import logging import logging
import os import os
...@@ -23,6 +22,12 @@ from io import BytesIO, StringIO ...@@ -23,6 +22,12 @@ from io import BytesIO, StringIO
from typing import Callable, Dict, List, Optional, Set, Tuple, cast from typing import Callable, Dict, List, Optional, Set, Tuple, cast
import numpy.distutils import numpy.distutils
from setuptools._distutils.sysconfig import (
get_config_h_filename,
get_config_var,
get_python_inc,
get_python_lib,
)
from typing_extensions import Protocol from typing_extensions import Protocol
# we will abuse the lockfile mechanism when reading and writing the registry # we will abuse the lockfile mechanism when reading and writing the registry
...@@ -254,9 +259,9 @@ class DynamicModule: ...@@ -254,9 +259,9 @@ class DynamicModule:
def _get_ext_suffix(): def _get_ext_suffix():
"""Get the suffix for compiled extensions""" """Get the suffix for compiled extensions"""
dist_suffix = distutils.sysconfig.get_config_var("EXT_SUFFIX") dist_suffix = get_config_var("EXT_SUFFIX")
if dist_suffix is None: if dist_suffix is None:
dist_suffix = distutils.sysconfig.get_config_var("SO") dist_suffix = get_config_var("SO")
return dist_suffix return dist_suffix
...@@ -1666,8 +1671,8 @@ def get_gcc_shared_library_arg(): ...@@ -1666,8 +1671,8 @@ def get_gcc_shared_library_arg():
def std_include_dirs(): def std_include_dirs():
numpy_inc_dirs = numpy.distutils.misc_util.get_numpy_include_dirs() numpy_inc_dirs = numpy.distutils.misc_util.get_numpy_include_dirs()
py_inc = distutils.sysconfig.get_python_inc() py_inc = get_python_inc()
py_plat_spec_inc = distutils.sysconfig.get_python_inc(plat_specific=True) py_plat_spec_inc = get_python_inc(plat_specific=True)
python_inc_dirs = ( python_inc_dirs = (
[py_inc] if py_inc == py_plat_spec_inc else [py_inc, py_plat_spec_inc] [py_inc] if py_inc == py_plat_spec_inc else [py_inc, py_plat_spec_inc]
) )
...@@ -1681,7 +1686,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]: ...@@ -1681,7 +1686,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]:
# this method is called many times. # this method is called many times.
if std_lib_dirs_and_libs.data is not None: if std_lib_dirs_and_libs.data is not None:
return std_lib_dirs_and_libs.data return std_lib_dirs_and_libs.data
python_inc = distutils.sysconfig.get_python_inc() python_inc = get_python_inc()
if sys.platform == "win32": if sys.platform == "win32":
# Obtain the library name from the Python version instead of the # Obtain the library name from the Python version instead of the
# installation directory, in case the user defined a custom # installation directory, in case the user defined a custom
...@@ -1755,7 +1760,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]: ...@@ -1755,7 +1760,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]:
# get the name of the python library (shared object) # get the name of the python library (shared object)
libname = str(distutils.sysconfig.get_config_var("LDLIBRARY")) libname = str(get_config_var("LDLIBRARY"))
if libname.startswith("lib"): if libname.startswith("lib"):
libname = libname[3:] libname = libname[3:]
...@@ -1766,7 +1771,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]: ...@@ -1766,7 +1771,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]:
elif libname.endswith(".a"): elif libname.endswith(".a"):
libname = libname[:-2] libname = libname[:-2]
libdir = str(distutils.sysconfig.get_config_var("LIBDIR")) libdir = str(get_config_var("LIBDIR"))
std_lib_dirs_and_libs.data = [libname], [libdir] std_lib_dirs_and_libs.data = [libname], [libdir]
...@@ -1774,9 +1779,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]: ...@@ -1774,9 +1779,7 @@ def std_lib_dirs_and_libs() -> Optional[Tuple[List[str], ...]]:
# explicitly where it is located this returns # explicitly where it is located this returns
# somepath/lib/python2.x # somepath/lib/python2.x
python_lib = str( python_lib = str(get_python_lib(plat_specific=True, standard_lib=True))
distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=True)
)
python_lib = os.path.dirname(python_lib) python_lib = os.path.dirname(python_lib)
if python_lib not in std_lib_dirs_and_libs.data[1]: if python_lib not in std_lib_dirs_and_libs.data[1]:
std_lib_dirs_and_libs.data[1].append(python_lib) std_lib_dirs_and_libs.data[1].append(python_lib)
...@@ -2364,7 +2367,7 @@ class GCC_compiler(Compiler): ...@@ -2364,7 +2367,7 @@ class GCC_compiler(Compiler):
# The following nullifies that redefinition, if it is found. # The following nullifies that redefinition, if it is found.
python_version = sys.version_info[:3] python_version = sys.version_info[:3]
if (3,) <= python_version < (3, 7, 3): if (3,) <= python_version < (3, 7, 3):
config_h_filename = distutils.sysconfig.get_config_h_filename() config_h_filename = get_config_h_filename()
try: try:
with open(config_h_filename) as config_h: with open(config_h_filename) as config_h:
if any( if any(
...@@ -2539,7 +2542,7 @@ class GCC_compiler(Compiler): ...@@ -2539,7 +2542,7 @@ class GCC_compiler(Compiler):
if platform.python_implementation() == "PyPy": if platform.python_implementation() == "PyPy":
suffix = "." + get_lib_extension() suffix = "." + get_lib_extension()
dist_suffix = distutils.sysconfig.get_config_var("SO") dist_suffix = get_config_var("SO")
if dist_suffix is not None and dist_suffix != "": if dist_suffix is not None and dist_suffix != "":
suffix = dist_suffix suffix = dist_suffix
......
from distutils.errors import CompileError as BaseCompileError from setuptools._distutils.errors import CompileError as BaseCompileError
class MissingGXX(Exception): class MissingGXX(Exception):
......
...@@ -53,6 +53,7 @@ install_requires = [ ...@@ -53,6 +53,7 @@ install_requires = [
"miniKanren", "miniKanren",
"cons", "cons",
"typing_extensions", "typing_extensions",
"setuptools>=45.0.0",
] ]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论