4 Commits

Author SHA1 Message Date
Sreenithi Sridharan
ee5325b9f1 [Python][Support 3.14] Enable 3.14 in Python Basic, Bazel and Distrib tests (#40403)
This PR enables Python 3.14 in all the different tests - Basic tests (Native Python tests), Bazel tests and Distrib tests to build Python 3.14 artifacts. In addition, it also updates all the public facing METADATA versions.

## Distribtests
Required pre-requisite changes to enable 3.14 artifacts are covered in #40289 .

## Bazel tests
Enabling Python 3.14 required updating the rules_python version to a more recent version that supports 3.14. This was done in #40602

## Basic tests
The following errors were caught by the Basic tests when running via Python 3.14 and resolved in this PR:

### 1) No running event loop for AsyncIO when run outside an async function
```
Traceback (most recent call last):
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/common.pyx.pxi", line 184, in grpc._cython.cygrpc.get_working_loop
RuntimeError: no running event loop
```
This was caught by the `tests_aio.unit.outside_init_test.TestOutsideInit` and `tests_aio.unit.init_test.TestInit` tests, and was also previously reported in #39507 with the root cause.

Following some investigation, the fix is being worked on by @sergiitk  in PR #40293. In order to parallelize the fix and this PR, these 2 tests are currently being skipped for Python 3.14 and above.

### 2) Pickling error from the `multiprocessing` library
```
_pickle.PicklingError: Can't pickle <function _test_well_known_types at 0x7f3937eee610>: it's not the same object as tests.unit._dynamic_stubs_test._test_well_known_types
when serializing dict item '_target'
when serializing multiprocessing.context.Process state
when serializing multiprocessing.context.Process object
```
This was caught by the `tests.unit._dynamic_stubs_test.DynamicStubTest` which runs test cases in a subprocess using the `multiprocessing` library.
Error root cause:
- The default start method of multiprocessing in linux has changed to `forkserver` instead of `fork` from Python 3.14.
- `forkserver` has a few extra restrictions for picklability as compared to `fork` (Ref: [Python Docs](https://docs.python.org/3.14/library/multiprocessing.html#the-spawn-and-forkserver-start-methods))
- All the [test case functions](0243842d5d/src/python/grpcio_tests/tests/unit/_dynamic_stubs_test.py (L115)) in the DynamicStubTest that are provided as `target` to the `multiprocessing.Process` use decorators. This causes problems when pickling them.

Hence to resolve this, we manually set the 'start method' of `multiprocessing` to use the `fork` start method.

Closes #40403

PiperOrigin-RevId: 804290760
2025-09-07 23:58:12 -07:00
Craig Tiller
3afc5d692a [build] Convert more templates to inja (#39304)
This should complete the templates that /do not/ have embedded Python

Closes #39304

PiperOrigin-RevId: 750384033
2025-04-22 17:33:19 -07:00
Esun Kim
55cf79cc4b [CI] Drop Python 3.8 (#38747)
Removed Python 3.8 builds and tests, to be aligned with [the  Foundational Python Support](e1ee4cc2cf/foundational-python-support-matrix.md (L6)).

Closes #38747

PiperOrigin-RevId: 727070251
2025-02-14 14:47:26 -08:00
Sreenithi Sridharan
f2ffbb89a2 Add templating and support for Python 3.13 (#37643)
This PR adds templating for Python versions and updates the maximum supported Python version to 3.13. The following major changes related to templating are added:
 - Minimum supported Python version and list of supported versions in `setup.py` are fetched using new template generated files called `python_version.py`
 - Dockerfiles for the different Python Linux builds are now template generated.
 - The "Supported Python Versions" section from READMEs of ancillary and main packages have been removed

Note: All the `python_version.py` files and Linux build `Dockerfiles` except `tools/dockerfile/grpc_artifact_python_linux_armv7/Dockerfile` in the PR are generated from the respective templates.

Further non-templated additions to add support for Python 3.13:
 - install scripts and artifacts for windows, macos and linux are added manually. Later, these can be templated as well.
 - updated cython bounds to 3.x
 - updated twine version to solve [cgi module import error](https://github.com/pypa/twine/issues/1046)
 - the twine update introduces a dependency on cryptography>=2.0. But the cryptography package doesn't support 32-bit Linux images and hence `twine check` has been disabled for x86 manylinux and x86 musllinux artifacts.

Closes #37643

PiperOrigin-RevId: 678954495
2024-09-25 20:13:50 -07:00