Commit Graph

72 Commits

Author SHA1 Message Date
Esun Kim 61e1c030b2 [Protobuf] Absorb protobuf::MultiFileErrorCollector change (#35870)
This is to absorb protobuf's breaking change introduce by https://github.com/protocolbuffers/protobuf/pull/15060. This is required to upgrade protobuf to v26.

Internal b/324252829

Closes #35870

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35870 from veblush:protobuf-sv 46e29ee0d4
PiperOrigin-RevId: 605718900
2024-02-09 13:44:07 -08:00
Xuan Wang 5c988a47c4 [Python Misc] Fix issue when deprecate pkg_resources.resource_filename (#35810)
We changed `pkg_resources.resource_filename` to `importlib.resources.files`, but the return of `resources.files()` API is a traversable object implementing a subset of the [pathlib.Path](https://docs.python.org/3/library/pathlib.html#pathlib.Path) interface instead of string, thus we're seeing errors like `AttributeError: 'PosixPath' object has no attribute 'rstrip'`.

This PR converts the result of `files()` to str to prevent those kinds of errors.

Test run:
 * [x] [grpc/core/master/linux/grpc_interop_tocloud](http://sponge/ee5d493b-e23e-4358-8084-3dba1df1d42f)

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #35810

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35810 from XuanWang-Amos:fix_import_pkg_resources_2 70fff7a7c3
PiperOrigin-RevId: 604398041
2024-02-05 12:28:26 -08:00
Fahad Ahammed eae9c558cf [Python Deps] Deprecate pkg_resources in grpc_tools (#35382)
…/protoc.py

pkg_resources deprecated in grpc_tools/protoc.py

.venv/lib/python3.11/site-packages/grpc_tools/protoc.py:21: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources

Fix for [https://github.com/grpc/grpc/issues/33570](https://github.com/grpc/grpc/issues/33570)

Closes #35382

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35382 from fahadahammed:fix-33570 27429f7a8c
PiperOrigin-RevId: 603189291
2024-01-31 16:20:16 -08:00
Sergii Tkachenko de6ed9ba9f
[Python] Migrate from yapf to black (#33138)
- Switched  from yapf to black
- Reconfigure isort for black
- Resolve black/pylint idiosyncrasies 

Note: I used `--experimental-string-processing` because black was
producing "implicit string concatenation", similar to what described
here: https://github.com/psf/black/issues/1837. While currently this
feature is experimental, it will be enabled by default:
https://github.com/psf/black/issues/2188. After running black with the
new string processing so that the generated code merges these `"hello" "
world"` strings concatenations, then I removed
`--experimental-string-processing` for stability, and regenerated the
code again.

To the reviewer: don't even try to open "Files Changed" tab 😄 It's
better to review commit-by-commit, and ignore `run black and isort`.
2023-06-09 15:08:55 -07:00
Jan Tattermusch c8d0110a10
[python] Python fixes for upcoming protobuf 22.x upgrade (#32803)
Various fixes that can be merged in advance, to simplify the 22.x
upgrade.

- Use NOMINMAX for grpcio_tools build to avoid build failure when absl
is added as a dependency. Fixes
https://github.com/grpc/grpc/issues/32779
- in spawn_patch command file, put arguments on multiple lines to avoid
lines going over the limit for large link commands: Fixes
https://github.com/grpc/grpc/issues/32795
- Use `python/generator.h` instead of the deprecated
`python/python_generator.h` in grpcio_tools.
2023-04-06 20:30:50 +02:00
Richard Belleville d84a6de3a5
Add type stub generation support to grpcio-tools (#30498)
* Add type stub generation support to grpcio-tools

* Clang format
2022-08-04 14:34:00 -07:00
Richard Belleville 59693b7e72
Migrate Infrastructure Scripts to Python 3 (#27135)
* Run 2to3 on tools directory

* Delete github_stats_tracking

* Re-run 2to3

* Remove unused script

* Remove unused script

* Remove unused line count utility

* Yapf. Isort

* Remove accidentally included file

* Migrate tools/distrib directory to python 3

* Remove unnecessary shebang

* Restore line_count directory

* Immediately convert subprocess.check_output output to string

* Take care of Python 2 shebangs

* Invoke scripts using a Python 3 interpreter

* Yapf. Isort

* Try installing Python 3 first

* See if we have any Python 3 versions installed

* Add Python 3.7 to Windows path

* Try adding a symlink

* Try to symlink differently

* Install six for Python 3

* Run run_interop_tests with python 3

* Try installing six in python3.7 explicitly

* Revert "Try installing six in python3.7 explicitly"

This reverts commit 2cf60d72f3.

* And debug some more

* Fix issue with jobset.py

* Add debug for CI failure

* Revert microbenchmark changes
2021-11-08 08:55:25 -08:00
Richard Belleville 468768865b
Make Buildifier Sanity Test Strict (#27807)
* Fix all lint errors in repo.

* Use strict buildifier by default

* Whoops. That file does not exist

* Attempt fix to buildifier invocation

* Add missing copyright
2021-11-03 14:57:04 -07:00
Craig Tiller ea389c00c2
Adjust include order per style guide (#27175)
Introduce clang-format configuration to sort includes closer to our rules.
2021-09-08 12:14:44 -07:00
Lidi Zheng 2231c2ba77
Introduce Python import sorting to our sanity test suite (#26768)
* Add isort_code.sh to sanity tests

* Run tools/distrib/isort_code.sh

* Fine tune the import order for relative imports

* Make pylint and project generation happy

* Fix a few corner cases

* Use --check instead of --diff

* The import order impacts test result somehow

* Make isort print diff and check output at the same time

* Let tools/run_tests/python_utils be firstparty library

* Run isort against latest HEAD
2021-07-26 12:31:21 -07:00
Ben Beasley d483841001
Explicitly import importlib.abc; required on Python 3.10. Fixes #26062. (#26083) 2021-04-26 16:44:12 -07:00
Richard Belleville f13b324941 Include well-known types in sys.path when using runtime protos 2020-10-19 13:02:33 -07:00
Richard Belleville a80a3b72bb Do not import grpc_tools.protoc from grpc_tools 2020-09-22 12:35:52 -07:00
Richard Belleville d743defdaf Fix import errors on Windows 2020-09-10 19:26:43 -04:00
Richard Belleville 47dc875801 Make version check more stringent 2020-09-09 15:32:52 -07:00
Richard Belleville 65d14904e4 Add todo about deduping 2020-08-14 16:36:08 -07:00
Richard Belleville 13fa5040ca Sometimes, copyright headers can cause test failures 2020-08-10 15:12:13 -07:00
Richard Belleville b50110b583 Fix Windows 2020-08-10 14:49:48 -07:00
Richard Belleville 2d9e8bc736 Copyright 2020-08-06 17:24:28 -07:00
Richard Belleville 60f88e20a4 Fix bazel grpc_tools test 2020-08-06 17:04:22 -07:00
Richard Belleville 2c1efcd0ae Add documentation 2020-08-06 12:25:21 -07:00
Richard Belleville 9448150eec Remove option to specify path 2020-07-17 16:46:38 -07:00
Richard Belleville 999bbf1401 Format 2020-07-15 13:09:53 -07:00
Richard Belleville fd0d0f77df Fix Bazel warning 2020-07-15 13:03:16 -07:00
Richard Belleville df0978ceb0 Clean up build file 2020-07-10 15:18:46 -07:00
Richard Belleville d4e8d9956c Run tests under setup.py 2020-06-26 12:11:31 -07:00
Richard Belleville 6055bc564d Shorten type names 2020-06-17 22:32:41 -07:00
Richard Belleville 0d0d2c65bc Manually format Cython 2020-06-17 22:15:45 -07:00
Richard Belleville 1f655ad351 Fix gil relinquishment 2020-06-17 22:09:13 -07:00
Richard Belleville 1f53f13446 Merge remote-tracking branch 'origin/master' into dynamic_stubs 2020-06-17 14:47:07 -07:00
Esun Kim 7be821ac47 Yapf all target python sources 2020-01-03 09:25:10 -08:00
Richard Belleville c57cb10169 Release GIL while compiling protos 2019-12-12 17:45:59 -08:00
Richard Belleville 928c6f23ea Be completely safe for Python 2 2019-12-10 17:37:53 -08:00
Richard Belleville 7eb3dc2ccc Run grpc_tools tests under Bazel 2019-12-10 16:55:08 -08:00
Richard Belleville 12cf83fd70 Run under setuptools 2019-12-10 16:02:05 -08:00
Richard Belleville 5f5402505e Rehome grpc_tools tests 2019-12-10 15:16:21 -08:00
Richard Belleville d4ad4ad03b Remove checked-in generated code 2019-12-10 14:07:47 -08:00
Richard Belleville 447eba1ed7 Make imports thread-safe 2019-12-10 11:53:47 -08:00
Richard Belleville 5c76f50e2f Format Python code 2019-12-10 11:41:59 -08:00
Richard Belleville c8a72f092e Improve namespacing 2019-12-10 11:28:50 -08:00
Richard Belleville e9746f03d6 Format C++ 2019-12-10 11:07:59 -08:00
Richard Belleville 87b50e08b9 Formatting 2019-12-04 14:55:08 -08:00
Richard Belleville 467bc90a6f Simplify naming 2019-12-03 16:29:27 -08:00
Richard Belleville b9b126a237 Add new functions to grpc api surface 2019-12-03 16:14:40 -08:00
Richard Belleville 0f27c1630e Speed up transitive closure calculation 2019-12-03 11:17:08 -08:00
Richard Belleville 7400bc0657 Readability 2019-12-03 11:08:44 -08:00
Richard Belleville ecab62dc31 Support services too 2019-12-02 17:08:00 -08:00
Richard Belleville 595807e0c5 Create importlib path for protos 2019-12-02 16:47:15 -08:00
Richard Belleville 709143d1f5 Support multiple include paths. Pretty print errors. Support combined import 2019-12-02 13:01:33 -08:00
Richard Belleville 70d61da47e Test mixing of static and dynamic loading 2019-11-27 15:30:11 -08:00