Commit Graph

249 Commits

Author SHA1 Message Date
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
Xuan Wang d00e043982
[Python o11y] Fix python distribtests (#33365)
Fix for Cython build issue in aarch64.

We're seeing this error in aarch64 distribution test:
```
In file included from ./src/core/lib/slice/slice.h:36,
                 from ./src/core/lib/slice/slice_buffer.h:29,
                 from ./src/core/lib/transport/transport.h:60,
                 from ./src/core/lib/channel/channel_stack.h:75,
                 from ./src/core/lib/channel/call_tracer.h:32,
                 from src/python/grpcio/grpc/_cython/cygrpc.cpp:2230:
./src/core/lib/slice/slice_refcount.h: In member function 'void grpc_slice_refcount::Ref(grpc_core::DebugLocation)':
./src/core/lib/slice/slice_refcount.h:55:25: error: expected ')' before 'PRIdPTR'
               "REF %p %" PRIdPTR "->%" PRIdPTR, this, prev_refs, prev_refs + 1);
                         ^~~~~~~~
                         )
```

Based on [this
post](https://stackoverflow.com/questions/26182336/priuptr-preprocessor-bug-in-gcc),
it's caused by including `<inttypes.h>` before define
`__STDC_FORMAT_MACROS` marco.

`<inttypes.h>` was included in `core/lib/channel/call_tracer.h` and this
macro should already be defined in `grpc/grpc.h` through
`port_platform.h`, but we're still having issue in aarch64, so we
manually define the macro in this PR.
2023-06-07 12:46:15 -07:00
AJ Heller 3225a9f117
[EventEngine] Disable EventEngine polling in gRPC Python (#33279)
This is a hack to get around an issue on Apple devices caused by the
PosixEventEngine's `poll` poller not supporting fork. This PR disables
the EventEngine poller entirely in Python builds. It will therefore
prevent the release of the EventEngine generally, and prevent any
testing of EventEngine integration with gRPC Python, until the `poll`
poller is fixed.
2023-05-30 19:26:44 -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 9c45499dfc
Update third_party/boringssl-with-bazel (#32492)
Upgrade boringssl to the latest "master-with-bazel"
- use the `'USE_HEADERMAP' => 'NO'` fix for ObjC
- update the key for asm optimizations on mac/apple in python's setup.py

This PR depends on monterey fixes here:
https://github.com/grpc/grpc/pull/32493 and the boringssl's build
simplification
https://boringssl-review.googlesource.com/c/boringssl/+/56465.

---------

Co-authored-by: Hannah Shi <hannahshisfb@gmail.com>
2023-03-02 10:18:00 +01: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
Richard Belleville 866e00246b
Revert "Build with System OpenSSL on Mac OS arm64 (#31096)" (#31741)
This reverts commit b3d9833166.
2022-11-22 15:28:44 -08:00
Amchii b3d9833166
Build with System OpenSSL on Mac OS arm64 (#31096)
* fix: grpcio fails to build from source on Apple Silicon mac #(25082)

Boringssl currently does not support macOS arm64, so installation on these platform with default config will undoubtedly fail, that means the env var 'BUILD_WITH_SYSTEM_OPENSSL' must be set to true.

* Use system installation of openssl by default on macOS arm64

* Format code by yapf
2022-10-19 19:59:23 -07:00
Xuan Wang 149f5615ba
Remove enum and future (#31381)
* [Python][Remove enum34] Remove enum34

* [Python][Remove futures] Remove futures

* Remove empty deps from .bazel files
2022-10-18 14:58:30 -07:00
Xuan Wang 7aca6d4007
[Remove Six] Remove dependency on six (#31340)
* [Python][Remove Six] Remove Six from requirements
2022-10-17 09:34:45 -07:00
Richard Belleville 2297249e47
Support Python 3.11 (#30818)
* Support Python 3.11

* Update build images for 3.11

* Whoopsie

* The architecture of this thing is garbage

* Silence ownership warning

* Account for change in git behavior

* Fix directory

* I am in great pain

* Update Windows and arm linux

* Agh

* Clean up
2022-09-12 11:53:44 -07:00
Abael He 82bf9d22fb
Update setup.py (#30522)
* Update setup.py

to make build success.

* PR:#30522, Google Style, yapf -i --style google setup.py
2022-08-10 10:44:49 -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 ec58a346f9
Changed C99 to C11 (#29687)
* Changed C99 to C11

* Remove gnu99 option

* Switch to gnu11 for xcode
2022-05-20 14:03:04 -07:00
Massimiliano Torromeo 79e658886d
Allow grpcio to be built against system abseil-cpp (#27550) 2022-05-16 11:00:57 -07:00
Esun Kim 03e9ac6f1f
Requiring C++14 (#29589) 2022-05-12 21:17:32 -07:00
Lidi Zheng dec86eefe4
Revert "Remove GRPC_ENABLE_FORK_SUPPORT from setup.py (#29103)" (#29229)
This reverts commit 83ce80fdd8.
2022-03-28 15:56:04 -07:00
Lidi Zheng 83ce80fdd8
Remove GRPC_ENABLE_FORK_SUPPORT from setup.py (#29103) 2022-03-15 14:38:23 -07:00
kacper-ka 6ba998854f
Fix fetching CXX variable in setup.py (#28873)
* Fix fetching CXX variable in setup.py

* Preserve all elements of CXX variable in setup.py
2022-03-08 11:57:46 -08:00
Esun Kim 6565584c7b
Bump the minimum gcc to 5 (#28786) 2022-02-11 10:31:25 -08:00
apolcyn 9f1663fb74
Upgrade c-ares to 1.17.2 (#28671)
Upgrade c-ares dependency to 1.17.2
2022-01-25 10:41:18 -08:00
Lidi Zheng c95ed2ebcb
Disable __wrap_memcpy hack for Python builds (#28410) 2021-12-23 10:18:40 -08:00
Lidi Zheng 83e7cb24fe
Fix the setuptools distutils overriding issue (#28393)
* Fix the distutil install issue

* Try to move setuptools install forward

* Try pin the distribution tools

* Enforce local distutil

* Fix script order of definition

* Add comment

* Try to fix the setuptool monkey patch

* Clean-up imports for commands.py

* Pin 59.6.0 instead of 59.7.0 (incomplete release)
2021-12-21 12:27:01 -08:00
Alberto Pedron c1fe2bc130
Fix libatomic linking on Rasperry Pi OS Bullseye (#28041) 2021-12-15 11:09:12 -08:00
Esun Kim 260145c517
Updated backoff to use absl::Random (#27193)
* Replace in-house rand with absl::Random for backoff (#26463)

* Replace in-house rand with absl::Random for backoff

* Run sanity

* Added bscrypt dependency

* Removed ABSL_RANDOM_HWAES_FLAGS

* Remove GCC_WARN_64_TO_32_BIT_CONVERSION = YES

* GCC_WARN_64_TO_32_BIT_CONVERSION to podspec install
2021-12-02 15:22:44 -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 4729f6fdcc
Add Python 3.10 drop 3.5 (#26074)
* Add Python 3.10.0rc1 binary wheels

* Drop Python 3.5 artifacts

* Document the drop of 3.5

* Fix the wrong pip pointer

* Update manylinux2014 to a newer version, remove 3.5 distribtest

* Update manylinux aarch64 to see if the absl error go away

* Use the preferred alias

* Allow different wheel library to produce different tag order

* Remove unused shell var and log produced wheels

* Use copy instead of move

* Make bash happy about the wildcard

* Upgrade the debian image to use 3.5+ Python

* Polish the comments for the Dockerfiles
2021-09-02 14:02:53 -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
Richard Belleville 7ada5552cf
Fix Python xDS User Agent (#26507)
* Use Extension define_macros

* Attempt fix to Windows quoting
2021-06-18 16:43:42 -07:00
Jan Tattermusch 451127740d
Revert "Replace in-house rand with absl::Random for backoff (#26463)" (#26476)
This reverts commit b5191d0930.
2021-06-14 21:56:35 -07:00
Richard Belleville f90716a821
Add Python xDS user agent (#26191)
* Add cpp macro to append wrapped language info to xDS user agent

* Add Python xDS user agent

* fix redefinition error and add macro for wrapped lang version

* clang-format

* Revert xds_api.cc changes

* Use two separate macros

* Yapf

* Regenerate projects

* Include _metadata.py in source distributions

* Attempt to fix quote escaping on Windows

Co-authored-by: Mark D. Roth <roth@google.com>
2021-06-14 16:35:00 -07:00
Esun Kim b5191d0930
Replace in-house rand with absl::Random for backoff (#26463)
* Replace in-house rand with absl::Random for backoff

* Run sanity

* Added bscrypt dependency
2021-06-11 16:29:45 -07:00
Lidi Zheng d0849fdaed
Fix zlib unistd.h import problem (#26374) 2021-05-27 10:58:16 -07:00
donnadionne d3e97d953b
Adding xxhash as a subtree (#25645) 2021-03-11 09:09:40 -08: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
donnadionne 34c8a1f87a
Revert "Adding xxhash as a subtree" (#25630)
This reverts commit 3880393fea.
2021-03-05 09:11:48 +01:00
donnadionne 40bc4624c2
Adding xxhash as a subtree (#25601)
* Squashed 'third_party/xxhash/' content from commit aea11081f3

git-subtree-dir: third_party/xxhash
git-subtree-split: aea11081f349893ec26f86ada22c66e828885083

* Adding xxhash as a subtree
2021-03-04 16:00:51 -08:00
Jan Tattermusch 1dce57f35f
Assorted python wheel build improvements (#25602)
* cleanup unnecessary deps from grpc_artifact_python_manylinux2014_aarch64

* cleanup in grpc_artifact_python dockerfiles

* enable boringssl assembly optimizations when crosscompiling aarch64 linux wheels

* pin manylinux2010 images to keep python27 build

* avoid pip install --upgrade cython when not necessary
2021-03-04 09:54:11 +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
Jan Tattermusch 0f791c73ae use boringssl asm optimizations in aarch64 wheel source build 2021-02-15 09:16:03 +01:00
Jorjun 76e82acc9c sanity check on MACOSX_DEPLOYMENT_TARGET
Avoid attempting to ever parse a potential None value on the above environment var, then carry on with Mac OS X specific version checking logic...
2021-01-12 20:17:22 +00:00
Jorjun eba18503cc workaround for Mac OS X Big Sur, Python 3.9 install fail
sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')

returns <str> '11.1' in Python 2.7 and <int> 11 in Python 3.9 causing exception: builtins.TypeError: expected string or bytes-like object
2020-12-15 13:23:07 +00:00
Richard Belleville 514dacb107
Merge pull request #24450 from mtorromeo/patch-2
Allow grpcio to be built against system re2
2020-10-20 20:04:32 -07:00
Massimiliano Torromeo 88b5952945 Allow grpcio to be built against system re2 2020-10-20 21:53:38 +02:00
Richard Belleville fbffae6903
Merge pull request #24449 from mtorromeo/patch-1
Do not build with boringssl ASM when using system openssl
2020-10-20 11:50:42 -07:00
Esun Kim 10d58179fe Bump MACOSX_DEPLOYMENT_TARGET to 10.10 for Python 2020-10-19 14:48:43 -07:00
Massimiliano Torromeo 770d1d0a05
Do not build with boringssl ASM when using system openssl 2020-10-16 20:09:49 +02:00
Lidi Zheng 4fa90f42ce Support pre-compiled Python 3.9 wheels 2020-10-07 12:43:45 -07:00
Ben Wolsieffer ad36ff39d3 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