Replace distutils.sysconfig with sysconfig (#28392)

* Replace distutils.sysconfig with sysconfig

* Replace distutils.sysconfig with sysconfig
pull/28400/head
Jiajun Yao 3 years ago committed by GitHub
parent a7dcceb365
commit dbe73c9004
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      third_party/py/python_configure.bzl

@ -199,8 +199,8 @@ def _get_python_lib(repository_ctx, python_bin, lib_path_key):
" python_paths = os.getenv('PYTHONPATH').split(':')\n" + "try:\n" + " python_paths = os.getenv('PYTHONPATH').split(':')\n" + "try:\n" +
" library_paths = site.getsitepackages()\n" + " library_paths = site.getsitepackages()\n" +
"except AttributeError:\n" + "except AttributeError:\n" +
" from distutils.sysconfig import get_python_lib\n" + " import sysconfig\n" +
" library_paths = [get_python_lib()]\n" + " library_paths = [sysconfig.get_path('purelib')]\n" +
"all_paths = set(python_paths + library_paths)\n" + "paths = []\n" + "all_paths = set(python_paths + library_paths)\n" + "paths = []\n" +
"for path in all_paths:\n" + " if os.path.isdir(path):\n" + "for path in all_paths:\n" + " if os.path.isdir(path):\n" +
" paths.append(path)\n" + "if len(paths) >=1:\n" + " paths.append(path)\n" + "if len(paths) >=1:\n" +
@ -237,14 +237,13 @@ def _get_python_include(repository_ctx, python_bin):
python_bin, python_bin,
"-c", "-c",
"from __future__ import print_function;" + "from __future__ import print_function;" +
"from distutils import sysconfig;" + "import sysconfig;" +
"print(sysconfig.get_python_inc())", "print(sysconfig.get_path('include'))",
], ],
error_msg = "Problem getting python include path for {}.".format(python_bin), error_msg = "Problem getting python include path for {}.".format(python_bin),
error_details = ( error_details = (
"Is the Python binary path set up right? " + "(See ./configure or " + "Is the Python binary path set up right? " + "(See ./configure or " +
python_bin + ".) " + "Is distutils installed? " + python_bin + ".) " + _HEADERS_HELP
_HEADERS_HELP
), ),
) )
include_path = result.stdout.splitlines()[0] include_path = result.stdout.splitlines()[0]

Loading…
Cancel
Save