Skip to content

Replace distutils.sysconfig with sysconfig#28392

Merged
lidizheng merged 3 commits intogrpc:masterfrom
jjyao:jjyao/distutils
Dec 29, 2021
Merged

Replace distutils.sysconfig with sysconfig#28392
lidizheng merged 3 commits intogrpc:masterfrom
jjyao:jjyao/distutils

Conversation

@jjyao
Copy link
Copy Markdown
Contributor

@jjyao jjyao commented Dec 20, 2021

This is essentially tensorflow/tensorflow#51776 since python_configure.bzl is modified from tensorflow.

I basically copied two PRs from there: tensorflow/tensorflow#51782 and tensorflow/tensorflow#51865.

@donnadionne

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Dec 20, 2021

CLA Signed

The committers are authorized under a signed CLA.

@jjyao
Copy link
Copy Markdown
Contributor Author

jjyao commented Dec 20, 2021

Tag @lidizheng @gnossen as well.

@lidizheng lidizheng added kokoro:run lang/Python release notes: no Indicates if PR should not be in release notes labels Dec 20, 2021
@lidizheng
Copy link
Copy Markdown
Contributor

Docker Hub is down now, I will retrigger the tests when it's back-up.

@jjyao
Copy link
Copy Markdown
Contributor Author

jjyao commented Dec 21, 2021

@lidizheng I think docker hub is back-up now :)

@lidizheng
Copy link
Copy Markdown
Contributor

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/local/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
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AssertionError: /usr/local/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.
INFO: Repository com_google_libprotobuf_mutator instantiated at:
  /var/local/git/grpc/WORKSPACE:7:20: in <toplevel>
  /var/local/git/grpc/bazel/grpc_deps.bzl:528:21: in grpc_test_only_deps
Repository rule http_archive defined at:
  /root/.cache/bazel/_bazel_root/d2dc70c3d9da3fab488ba0dcbbd35051/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: /var/local/git/grpc/src/python/grpcio/grpc/_cython/BUILD.bazel:25:12: //src/python/grpcio/grpc/_cython:cygrpc.so depends on @local_config_python//:python_headers in repository @local_config_python which failed to fetch. no such package '@local_config_python//': 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/local/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: Analysis of target '//examples/python/multiprocessing:prime_proto_pb2_grpc' failed; build aborted: Analysis failed
INFO: Elapsed time: 28.827s

There might be some Python 2 residual causing tests to fail (there is also an ongoing setuptools issue). If you are comfortable with Bazel, do you think you can take a peak at it?

@acxz
Copy link
Copy Markdown
Contributor

acxz commented Dec 21, 2021

@jjyao can you fix the corresponding error msg?

            python_bin + ".) " + "Is distutils installed? " +
            _HEADERS_HELP

to

            python_bin + ".) " + _HEADERS_HELP

as seen in my PR.

This is just for consistency since distutils does not need to be installed as sysconfig is part of the default python installation now.

However it is not for python2 I believe. Thus for the tests that are failing regarding python2 we may need to have a conditional that runs the old code with distutils.

@jjyao
Copy link
Copy Markdown
Contributor Author

jjyao commented Dec 21, 2021

Oh, does grpc support python2? I thought it's >= 3.6 based on https://github.com/grpc/grpc/tree/master/src/python/grpcio.

@lidizheng
Copy link
Copy Markdown
Contributor

Nah, this looks like a script used by C/C++ build. I can take a look later.

@jjyao
Copy link
Copy Markdown
Contributor Author

jjyao commented Dec 21, 2021

Nah, this looks like a script used by C/C++ build. I can take a look later.

Thanks. I'm not familiar with the grpc build system so it would be great if you can provide some help here.

@lidizheng
Copy link
Copy Markdown
Contributor

Link to an existing issue: #28026

@acxz
Copy link
Copy Markdown
Contributor

acxz commented Dec 21, 2021

@lidizheng can you clarify on what is needed for this PR to be merged?

Is getting the CI to pass a hard requirement? Just want to know since quite a few downstream projects are stuck at this issue and would like to know when this can be rolled out.

@lidizheng
Copy link
Copy Markdown
Contributor

lidizheng commented Dec 21, 2021

During last weekend, upstream setuptools broke the Python build, I'm working on two fixes #28393 and #28397.

Yes, getting the CI pass is a hard requirement.

@acxz I understand this is a headache for Bazel + 3.10. For code rollout, do you need a patch release or fix at head is fine?

@acxz
Copy link
Copy Markdown
Contributor

acxz commented Dec 21, 2021

Yes, getting the CI pass is a hard requirement.

Got it. If I get some bandwidth I'll see if I can help with #28026 and eliminating all python 2 code.

The way we use grpc in our Bazel, a fix at head is just what we need.

@lidizheng
Copy link
Copy Markdown
Contributor

@jjyao Build related issues have been fixed, the Python 2 issue in Bazel is also fixed. Can you rebase this PR?

@jjyao
Copy link
Copy Markdown
Contributor Author

jjyao commented Dec 28, 2021

@lidizheng Rebased.

Copy link
Copy Markdown
Contributor

@lidizheng lidizheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this update!

@lidizheng
Copy link
Copy Markdown
Contributor

@gnossen PTAL.

Copy link
Copy Markdown
Contributor

@gnossen gnossen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@lidizheng lidizheng merged commit dbe73c9 into grpc:master Dec 29, 2021
@jjyao jjyao deleted the jjyao/distutils branch December 29, 2021 22:09
@acxz acxz mentioned this pull request Jan 25, 2022
6 tasks
rkooo567 pushed a commit to ray-project/ray that referenced this pull request Feb 15, 2022
add patch for newer setuptools, can be removed once grpc 1.44 is release

Why are these changes needed?
With grpc updated to 1.43, one of the patches is not needed.

Patch needed when building locally for newer setuptools version. See grpc/grpc#28392 for more details.
Also needed as a prereq to #21221
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Feb 27, 2022
add patch for newer setuptools, can be removed once grpc 1.44 is release

Why are these changes needed?
With grpc updated to 1.43, one of the patches is not needed.

Patch needed when building locally for newer setuptools version. See grpc/grpc#28392 for more details.
Also needed as a prereq to ray-project#21221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bloat/none lang/Python perf-change/none release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants