Skip to content

Commit dbe73c9

Browse files
authored
Replace distutils.sysconfig with sysconfig (#28392)
* Replace distutils.sysconfig with sysconfig * Replace distutils.sysconfig with sysconfig
1 parent a7dcceb commit dbe73c9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

third_party/py/python_configure.bzl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ def _get_python_lib(repository_ctx, python_bin, lib_path_key):
199199
" python_paths = os.getenv('PYTHONPATH').split(':')\n" + "try:\n" +
200200
" library_paths = site.getsitepackages()\n" +
201201
"except AttributeError:\n" +
202-
" from distutils.sysconfig import get_python_lib\n" +
203-
" library_paths = [get_python_lib()]\n" +
202+
" import sysconfig\n" +
203+
" library_paths = [sysconfig.get_path('purelib')]\n" +
204204
"all_paths = set(python_paths + library_paths)\n" + "paths = []\n" +
205205
"for path in all_paths:\n" + " if os.path.isdir(path):\n" +
206206
" paths.append(path)\n" + "if len(paths) >=1:\n" +
@@ -237,14 +237,13 @@ def _get_python_include(repository_ctx, python_bin):
237237
python_bin,
238238
"-c",
239239
"from __future__ import print_function;" +
240-
"from distutils import sysconfig;" +
241-
"print(sysconfig.get_python_inc())",
240+
"import sysconfig;" +
241+
"print(sysconfig.get_path('include'))",
242242
],
243243
error_msg = "Problem getting python include path for {}.".format(python_bin),
244244
error_details = (
245245
"Is the Python binary path set up right? " + "(See ./configure or " +
246-
python_bin + ".) " + "Is distutils installed? " +
247-
_HEADERS_HELP
246+
python_bin + ".) " + _HEADERS_HELP
248247
),
249248
)
250249
include_path = result.stdout.splitlines()[0]

0 commit comments

Comments
 (0)