Fix the automatic detection of the include directory for Python 3.10 (#44)
* Fix the automatic detection of the include directory for Python 3.10
- `sysconfig` has been supported since 3.2
- Since we support only Python > 3.6, we use `import sysconfig; print(sysconfig.get_path('include'))` to get the include path.
diff --git a/python_configure.bzl b/python_configure.bzl
index bb505c7..8241368 100644
--- a/python_configure.bzl
+++ b/python_configure.bzl
@@ -246,19 +246,14 @@
def _get_python_include(repository_ctx, python_bin):
"""Gets the python include path."""
- python_lib = repository_ctx.os.environ.get(_PYTHON_LIB_PATH)
- if python_lib != None:
- return python_lib
result = _execute(
repository_ctx,
[
python_bin,
"-c",
- "from __future__ import print_function;" +
- "from distutils import sysconfig;" +
- "print(sysconfig.get_python_inc())",
+ "import sysconfig; print(sysconfig.get_path('include'))",
],
- error_msg = "Problem getting python include path.",
+ error_msg = "Problem getting python include path for Python version " + str(version),
error_details = ("Is the Python binary path set up right? " +
"(See ./configure or " + _PYTHON_BIN_PATH + ".) " +
"Is distutils installed?"),