Commit Graph

90 Commits

Author SHA1 Message Date
Xuan Wang e5131b5243 [Python grpcio_tools] Update version requirement of protobuf in grpcio_tools (#36230)
Since we already finished v26.1 upgrade in https://github.com/grpc/grpc/pull/35796
<!--

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 #36230

PiperOrigin-RevId: 623960260
2024-04-11 15:39:29 -07:00
Xuan Wang 73b0ac2067 [Python Version] Drop support for Python 3.7 (#34450)
### NOTE
* We shouldn't merge this PR until GCP cloud functions drops support for Python 3.7 ([Currently scheduled for GCF](https://cloud.google.com/functions/docs/runtime-support#python))

As part of supporting Python 3.12, we're now officially drop support for Python 3.7.

This PR:

* Changed supported Python version from 3.7 to 3.8 in README.
* Replaced distribution test image from `debian:buster` to `debian:bullseye` since the default Python version in buster is 3.7.

<!--

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 #34450

PiperOrigin-RevId: 622899511
2024-04-08 11:17:51 -07:00
Esun Kim 2aa1b6479f [Build] Massage grpcio_tools build configuration for protobuf upgrade. (#36124)
This is a prerequisite for the upcoming Protobuf v26 upgrade and has the following changes;

- Reduced the optimization level from `O3` to `O1` on Linux to workaround a segfault issue on `manylinux2014/x86`. This is believed to be caused by an aggressive but buggy optimization that `gcc` 10 made so workaround is to reduce the optimization level. `gcsio_tools` isn't that performance sensitive so we should be able to afford this change. (internal b/329134877)
- Added a Windows library dependency `Shell32.lib` to support the use of `CommandLineToArgvW`. (internal b/328455319)

Closes #36124

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36124 from veblush:grpcio-x e7b555bfcf
PiperOrigin-RevId: 616245600
2024-03-15 14:37:52 -07:00
Esun Kim b78f64569a [CI] Updated by review (#36083)
Updated by review & Added missing import.

Closes #36083

PiperOrigin-RevId: 614017839
2024-03-08 12:49:57 -08:00
Esun Kim bf09088b5f [Build] Making grpcio_tools ready for upcoming Protobuf change. (#36074)
Protobuf is beginning to rely more on upb, pulling in more C files. Hence, grpcio_tool needs the following changes to absorb this.

- Changing the setup.py to support both C and C++ by removing explicit language=c++. Rather it can choose the right compiler by its extension.
- Adding build_extensions injection to deal with C/C++ option conflict as grpcio does.
- Adding protobuf and upb directories to the build script so that it can find newly added source files in protobuf.

Tested by https://github.com/grpc/grpc/pull/35796

Closes #36074

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36074 from veblush:grpcio-tool-ready 84abce9083
PiperOrigin-RevId: 613975137
2024-03-08 10:32:29 -08:00
Xuan Wang bb3edd22b3 [Python Modernization] Deprecate pkg_resources (#35849)
Discuss thread about this change: [link](https://mail.google.com/mail/u/0/#sent/QgrcJHsBpWNGRlrMktwbppGGfFTVCFLcQgL?compose=new)
<!--

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 #35849

PiperOrigin-RevId: 607144827
2024-02-14 16:44:42 -08:00
Esun Kim 1f979d2a83 [BoringSSL] Update third_party/boringssl-with-bazel (#35768)
Change was created by the release automation script. See go/grpc-release.

On top of changes made by the script, `setup.py` had to be updated to have `/std:c11` option for MSVC to use c11 features for boringssl.

Closes #35768

PiperOrigin-RevId: 603403329
2024-02-01 10:06:33 -08:00
Xuan Wang eccbc97697
[Python dist] Explicitly link Core Foundation framework for MacOS (#34395)
Some user reported an issue that symbols from CoreFoundation are missing
when install grpc/grpc-tools inside Conda:
* https://github.com/grpc/grpc/issues/33714
* https://github.com/grpc/grpc/issues/34135

This PR adds the `-framework CoreFoundation` flag so no workarounds are
required from user.


<!--

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.

-->
2023-10-19 09:48:35 -07:00
Xuan Wang c7a1336566
[Python 3.12] Deprecate distutil (#34186)
### Background

* `distutils` is deprecated with removal planned for Python 3.12
([pep-0632](https://peps.python.org/pep-0632/)), thus we're trying to
replace all distutils usage with setuptools.
* Please note that user still have access to `distutils` if setuptools
is installed and `SETUPTOOLS_USE_DISTUTILS` is set to `local` (The
default in setuptools, more details can be found [in this
discussion](https://github.com/pypa/setuptools/issues/2806#issuecomment-1193336591)).

### How we decide the replacement

* We're following setuptools [Porting from Distutils
guide](https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html#porting-from-distutils)
when deciding the replacement.

#### Replacement not mentioned in the guide

* Replaced `distutils.utils.get_platform()` with
`sysconfig.get_platform()`.
* Based on the [answer
here](https://stackoverflow.com/questions/71664875/what-is-the-replacement-for-distutils-util-get-platform),
and also checked the document that `sysconfig.get_platform()` is good
enough for our use cases.
* Replaced `DistutilsOptionError` with `OptionError`.
* `setuptools.error` is exporting it as `OptionError` [in the
code](https://github.com/pypa/setuptools/blob/v59.6.0/setuptools/errors.py).
* Upgrade `setuptools` in `test_packages.sh` and changed the version
ping to `59.6.0` in `build_artifact_python.bat`.
* `distutils.errors.*` is not fully re-exported until `59.0.0` (See
[this issue](https://github.com/pypa/setuptools/issues/2698) for more
details).

### Changes not included in this PR

* We're patching some compiler related functions provided by distutils
in our code
([example](ee4efc31c1/src/python/grpcio/_spawn_patch.py (L30))),
but since `setuptools` doesn't have similar interface (See [this issue
for more details](https://github.com/pypa/setuptools/issues/2806)), we
don't have a clear path to replace them yet.


<!--

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.

-->
2023-09-06 14:32:30 -07: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 0f1afec5a8
[protobuf] Upgrade third_party/protobuf to 22.x (#32606)
The very non-trivial upgrade of third_party/protobuf to 22.x
This PR strives to be as small as possible and many changes that were
compatible with protobuf 21.x and didn't have to be merged atomically
with the upgrade were already merged.
Due to the complexity of the upgrade, this PR wasn't created
automatically by a tool, but manually. Subsequent upgraded of
third_party/protobuf with our OSS release script should work again once
this change is merged.

This is best reviewed commit-by-commit, I tried to group changes in
logical areas.

Notable changes:
- the upgrade of third_party/protobuf submodule, the bazel protobuf
dependency itself
- upgrade of UPB dependency to 22.x (in the past, we used to always
upgrade upb to "main", but upb now has release branch as well). UPB
needs to be upgraded atomically with protobuf since there's a de-facto
circular dependency (new protobuf depends on new upb, which depends on
new protobuf for codegen).
- some protobuf and upb bazel rules are now aliases, so `
extract_metadata_from_bazel_xml.py` and `gen_upb_api_from_bazel_xml.py`
had to be modified to be able to follow aliases and reach the actual
aliased targets.
- some protobuf public headers were renamed, so especially
`src/compiler` needed to be updated to use the new headers.
- protobuf and upb now both depend on utf8_range project, so since we
bundle upb with grpc in some languages, we now have to bundle utf8_range
as well (hence changes in build for python, PHP, objC, cmake etc).
- protoc now depends on absl and utf8_range (previously protobuf had
absl dependency, but not for the codegen part), so python's
make_grpcio_tools.py required partial rewrite to be able to handle those
dependencies in the grpcio_tools build.
- many updates and fixes required for C++ distribtests (currently they
all pass, but we'll probably need to follow up, make protobuf's and
grpc's handling of dependencies more aligned and revisit the
distribtests)
- bunch of other changes mostly due to overhaul of protobuf's and upb's
internal build layout.

TODOs:
- [DONE] make sure IWYU and clang_tidy_code pass
- create a list of followups (e.g. work to reenable the few tests I had
to disable and to remove workaround I had to use)
- [DONE in cl/523706129] figure out problem(s) with internal import

---------

Co-authored-by: Craig Tiller <ctiller@google.com>
2023-04-12 18:43:58 +02: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
Xuan Wang a500d24480
Add project urls to setup.py (#32458)
Tested by running `twine` command on wheels created by distribution
test, no warning was created.
2023-02-23 17:15:26 -08:00
AJ Heller 1c5db3404b
[codegen] Escape '$' delimiter in proto comments (#32411)
This applies to all wrapped languages.




<!--

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.

-->
2023-02-15 19:53:32 -08:00
Richard Belleville e609ad88c9
Update protobuf to v21.6 (#31015)
* Update third_party/protobuf

* run tools/distrib/python/make_grpcio_tools.py

* update build_handwritten.yaml

* regenerate projects

* Update Python version floor
2022-09-16 17:50:52 -07:00
Yash Tibrewal 41ec08c69a
Update third_party/protobuf to 3.21.4 (#30377)
* Update third_party/protobuf

* run tools/distrib/python/make_grpcio_tools.py

* regenerate protos for ruby, php

* update build_handwritten.yaml

* regenerate projects

* Build - Use :well_known_type_protos instead of :well_known_protos

* Fix target

* Update upb

* Update Python for Protobuf 4.21 (#140)

* Update protobuf dependency on grpcio-tools

* Off by one

* Drop python 3.6 support

* Try upgrading pip

* And in the other script

* Try to figure out if we're compatible with abi3

* See what we've already got installed

* Update the requirements.txt file I didn't know existed

* And here too

* See what's installed

* Let's try that again

* Remove

* Try to confirm version

* Let me see the generated code

* Fix non-Bazel test runner

* Work for all test directories

* Regenerate example protos

* Clean up

* Generate .pyi files

* Fix type checking and linting

* Exclude pyi files from isort

* Upgrade to 3.21.4

* Update iwyu to get around messy protobuf IWYU rules

Co-authored-by: Richard Belleville <gnossen@gmail.com>
2022-08-04 09:39:49 -07:00
Esun Kim 03e9ac6f1f
Requiring C++14 (#29589) 2022-05-12 21:17:32 -07:00
Richard Belleville ff3d51886b
bump grpcio-tools protobuf dependency (#29257) 2022-03-29 16:08:56 -07:00
Esun Kim 6565584c7b
Bump the minimum gcc to 5 (#28786) 2022-02-11 10:31:25 -08:00
Alberto Pedron c1fe2bc130
Fix libatomic linking on Rasperry Pi OS Bullseye (#28041) 2021-12-15 11:09:12 -08:00
Lidi Zheng 9978223a26
Add python_requires field to grpcio-* packages (#27495)
- Update the run_tests.py and distrib tests
- Update the Dockerfiles
2021-09-28 16:01:15 -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
Lidi Zheng 5820e152cd
Remove Python 2.7 binary wheel generations (#26691)
* Remove Python 2.7 binary wheels

* Make sure pip won't pick-up newer versions

* Attempt to fix the distribtest

* Fallback to virtualenv==16.7.9 for 34 and 35

* Remove 34 from binary wheel distribtests
2021-07-23 08:20:39 -07:00
emkornfield ec31fa8455
Standardize all environment variable boolean configuration in python's setup.py (#25444)
* standardize bool flags for grpcio and grpcio.tools

Co-authored-by: Jan Tattermusch <jtattermusch@google.com>
2021-03-10 11:11:07 +01:00
Jan Tattermusch fcd43e9030
Crosscompile python aarch64 wheels with dockcross (#25418)
* build aarch64 python wheels via crosscompilation

* yapf format code

* fix shellcheck complaints

* fix python37 aarch64 wheel build

* build python wheels on linux aarch64 with static libstdc++

* yapf format code
2021-03-02 07:32:28 +01:00
Richard Belleville 46bb9570b2 Rewrap comment 2020-12-15 12:23:40 -08:00
Richard Belleville aa90c5f9fe Whoops 2020-12-14 20:33:13 -08:00
Richard Belleville fbcf75e0ec Support Python 2 as well 2020-12-14 17:53:59 -08:00
Richard Belleville 9b9bb299c5 Fix visibility of libprotobuf symbols in protoc_compiler.so on Mac 2020-12-14 16:15:02 -08:00
Lidi Zheng 1389fa7426 Incur setuptools as an dependency for grpcio_tools 2020-11-13 14:03:28 -08:00
Esun Kim 10d58179fe Bump MACOSX_DEPLOYMENT_TARGET to 10.10 for Python 2020-10-19 14:48:43 -07:00
Esun Kim be23ad0ed1
Merge pull request #24282 from veblush/ios-bump
Bump iOS and OSX version
2020-10-07 16:12:16 -07:00
Ben Wolsieffer 1b7c290083 grpcio_tools: setup.py: use CXX to get compiler for libatomic check
This allows it to work with a prefixed compiler when cross-compiling.
2020-10-01 14:37:32 -04:00
Ben Wolsieffer 1024ebeb31 grpcio_tools: setup.py: update libatomic check from top-level setup.py 2020-10-01 14:37:32 -04:00
Esun Kim ccf3cbc6b7 Bump iOS and OSX version 2020-09-30 14:58:30 -07:00
Lidi Zheng d98ecdb85c Set version upper bound for protobuf; installs grpcio-tools instead 2020-06-16 11:00:00 -07:00
Esun Kim 5207eba9ff Add abseil 2020-01-03 19:29:55 -08:00
Esun Kim 7be821ac47 Yapf all target python sources 2020-01-03 09:25:10 -08:00
Esun Kim 4bc9820241 Update comment 2019-10-04 20:41:36 -07:00
Esun Kim d55154f7b8 Reformat code 2019-10-04 17:25:58 -07:00
Esun Kim 55ae0f6f8d Added libatomic to gRPC python 2019-10-04 16:39:10 -07:00
Richard Belleville 5d95bf037d Actually include README.rst in all packages 2019-05-20 14:21:25 -07:00
Jan Tattermusch 185a0a7028 add python monkey-patch for parallel build_ext compilation 2018-10-31 09:01:01 +01:00
Mehrdad Afshari 981f19bed2 Remove protobuf js_embed hack 2018-08-16 11:18:00 -07:00
Mehrdad Afshari 87cd994b04 Upgrade yapf to 0.20.0
Upgrade yapf version to 0.20.0 and reformat Python files.
2018-01-02 14:40:00 -08:00
ncteisen 7a2be20a8a yapf tools/distrib 2017-12-11 16:49:19 -08:00
Mehrdad Afshari 0df9c8acdc Update Python dependency to protobuf v3.5.0.post1 2017-11-27 12:52:41 -08:00
Ken Payson f5f5ed0305 Fix syntax error on classifiers 2017-08-24 11:46:03 -07:00
Ken Payson 9c420447fa Add classifiers to package details 2017-07-25 12:06:46 -07:00
Jan Tattermusch cb8eaaa883 fix grpcio_tools build on kokoro 2017-07-18 17:26:27 +02:00