Skip to content

Bazel BUILD fails during analysis phase when python2.7 binary is installed, but python2.7-dev is not. #28026

@jtattermusch

Description

@jtattermusch

I ran into a situation where I have python3 and python3-dev installed, but I also happen to have legacy python2.7 installed. Since python2.7 is present by default on many systems, this is a quite common situation.

When I try to run grpc bazel build (even when trying to build just grpc C++), it fails very early with the message below.
I think the issue is that the configurator sees that python2.7 is available, so it tries to configure it, but fails since pyhon2's python.h isn't present (which is fair since I never wanted to use python2 for building anything).

Can we get rid of python2 support in our bazel build entirely? AFAIK our bazel BUILD should only be using python3 at this point, since we deprecated python2.

INFO: Repository local_config_python instantiated at:
  /var/local/git/grpc/WORKSPACE:5:10: in <toplevel>
  /var/local/git/grpc/bazel/grpc_deps.bzl:448:21: in grpc_deps
  /var/local/git/grpc/bazel/grpc_python_deps.bzl:61:21: in grpc_python_deps
Repository rule python_configure defined at:
  /var/local/git/grpc/third_party/py/python_configure.bzl:365:35: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_python':
   Traceback (most recent call last):
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
		_create_single_version_package(
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 304, column 45, in _create_single_version_package
		python_include = _get_python_include(repository_ctx, python_bin)
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 253, column 13, in _get_python_include
		_execute(
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 62, column 14, in _execute
		_fail("\n".join([
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 35, column 9, in _fail
		fail("%sPython Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Python Configuration Error: Unable to find Python headers for /usr/bin/python2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AssertionError: /usr/include/python2.7/Python.h does not exist.
Are Python headers installed? Try installing python-dev or python3-dev on Debian-based systems. Try python-devel or python3-devel on Redhat-based systems.
ERROR: Error fetching repository: Traceback (most recent call last):
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 347, column 35, in _python_autoconf_impl
		_create_single_version_package(
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 304, column 45, in _create_single_version_package
		python_include = _get_python_include(repository_ctx, python_bin)
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 253, column 13, in _get_python_include
		_execute(
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 62, column 14, in _execute
		_fail("\n".join([
	File "/var/local/git/grpc/third_party/py/python_configure.bzl", line 35, column 9, in _fail
		fail("%sPython Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail: Python Configuration Error: Unable to find Python headers for /usr/bin/python2

https://source.cloud.google.com/results/invocations/f19bb81c-db82-474b-a2f7-910a9efd0ba4/log

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions