Skip to content

mobile: re-add Python APIs#43605

Merged
danzh2010 merged 26 commits into
envoyproxy:mainfrom
danzh2010:pythonapi
Mar 3, 2026
Merged

mobile: re-add Python APIs#43605
danzh2010 merged 26 commits into
envoyproxy:mainfrom
danzh2010:pythonapi

Conversation

@danzh2010
Copy link
Copy Markdown
Contributor

@danzh2010 danzh2010 commented Feb 23, 2026

Re-adds Python bindings targeting the current C++ API surface (EngineBuilder, Engine, StreamClient, StreamPrototype, Stream) using pybind11. Includes GIL-safe callback shims, Python dict/bytes type conversions, a fetch client example, and an integration test.

Patched from #43514
Co-Authored-By: Claude noreply@anthropic.com
Co-Authored-By: Gemini CLI

Risk Level: low, no change to existing APIs and features
Testing: new tests added
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43605 was opened by danzh2010.

see: more, trace.

@danzh2010 danzh2010 changed the title Pythonapi mobile: re-add Python APIs Feb 23, 2026
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010 danzh2010 marked this pull request as ready for review February 23, 2026 21:40
@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Feb 23, 2026
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @moderation

🐱

Caused by: #43605 was ready_for_review by danzh2010.

see: more, trace.

@danzh2010
Copy link
Copy Markdown
Contributor Author

/assign @abeyad

Signed-off-by: Dan Zhang <danzh@google.com>
@abeyad
Copy link
Copy Markdown
Contributor

abeyad commented Feb 24, 2026

Thanks @danzh2010 ! Question: do we know if any existing CI workflow actually executes the Python tests? If not, should we add it here?

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

please review the black dep changes. /assign @phlax

@danzh2010
Copy link
Copy Markdown
Contributor Author

/assign @phlax

Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

some python feedback ...

Comment thread mobile/examples/python/fetch_client/fetch_client.py Outdated
Comment thread mobile/test/python/fetch_test.py Outdated
setattr(destination, attr, val)
except Exception as e:
print(f"Error copying attribute {attr}: {e}")
except Exception as e:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

most linters wont allow this - you need to be more specific about what type of error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wouldn't we want a catch-all for try block?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

generally you dont want to catch a bare exception - just named ones

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the reason being - on unexpected failure the program should fail - so if you catch something the more specific the better ... also because you might catch things you had not expected to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@abeyad
Copy link
Copy Markdown
Contributor

abeyad commented Feb 28, 2026

/retest

Copy link
Copy Markdown
Contributor

@abeyad abeyad left a comment

Choose a reason for hiding this comment

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

thanks @danzh2010 !

Comment thread .github/dependabot.yml
Comment thread mobile/bazel/envoy_mobile_dependencies.bzl
Comment thread mobile/examples/python/fetch_client/fetch_client.py Outdated
return self.setOnEngineExit([shared_closure]() {
py::gil_scoped_acquire acquire;
(*shared_closure)();
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW, I don't know enough Python myself to know if this is the proper use of the GIL scope etc, but I'm just trusting the AI got it right :)

Comment thread mobile/library/python/stream_prototype_shim.cc
Signed-off-by: Dan Zhang <danzh@google.com>
Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

python looks loads better, thanks @danzh2010

(not sure about the pybind stuff - didnt review it as dont have much experience with it)

@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label Mar 2, 2026
@danzh2010
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@abeyad
Copy link
Copy Markdown
Contributor

abeyad commented Mar 3, 2026

/retest

Copy link
Copy Markdown
Contributor

@abeyad abeyad left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @danzh2010 !

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010 danzh2010 enabled auto-merge (squash) March 3, 2026 16:34
@danzh2010 danzh2010 merged commit 863c24e into envoyproxy:main Mar 3, 2026
29 checks passed
bmjask pushed a commit to bmjask/envoy that referenced this pull request Mar 14, 2026
tested wf breakout from envoyproxy#43605

renames wfs for consistency (android tests etc are soon going to be
~merged into Mobile/Android eg)

Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: bjmask <11672696+bjmask@users.noreply.github.com>
bmjask pushed a commit to bmjask/envoy that referenced this pull request Mar 14, 2026
Re-adds Python bindings targeting the current C++ API surface
(EngineBuilder, Engine, StreamClient, StreamPrototype, Stream) using
pybind11. Includes GIL-safe callback shims, Python dict/bytes type
conversions, a fetch client example, and an integration test.

Patched from envoyproxy#43514
Co-Authored-By: Claude
[noreply@anthropic.com](mailto:noreply@anthropic.com)
Co-Authored-By: Gemini CLI

Risk Level: low, no change to existing APIs and features
Testing: new tests added
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

---------

Signed-off-by: Dan Zhang <danzh@google.com>
Co-authored-by: Dan Zhang <danzh@google.com>
Signed-off-by: bjmask <11672696+bjmask@users.noreply.github.com>
bvandewalle pushed a commit to bvandewalle/envoy that referenced this pull request Mar 17, 2026
tested wf breakout from envoyproxy#43605 

renames wfs for consistency (android tests etc are soon going to be
~merged into Mobile/Android eg)

Signed-off-by: Ryan Northey <ryan@synca.io>
bvandewalle pushed a commit to bvandewalle/envoy that referenced this pull request Mar 17, 2026
Re-adds Python bindings targeting the current C++ API surface
(EngineBuilder, Engine, StreamClient, StreamPrototype, Stream) using
pybind11. Includes GIL-safe callback shims, Python dict/bytes type
conversions, a fetch client example, and an integration test.

Patched from envoyproxy#43514 
Co-Authored-By: Claude
[noreply@anthropic.com](mailto:noreply@anthropic.com)
Co-Authored-By: Gemini CLI


Risk Level: low, no change to existing APIs and features
Testing: new tests added
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

---------

Signed-off-by: Dan Zhang <danzh@google.com>
Co-authored-by: Dan Zhang <danzh@google.com>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
tested wf breakout from envoyproxy#43605 

renames wfs for consistency (android tests etc are soon going to be
~merged into Mobile/Android eg)

Signed-off-by: Ryan Northey <ryan@synca.io>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
Re-adds Python bindings targeting the current C++ API surface
(EngineBuilder, Engine, StreamClient, StreamPrototype, Stream) using
pybind11. Includes GIL-safe callback shims, Python dict/bytes type
conversions, a fetch client example, and an integration test.

Patched from envoyproxy#43514 
Co-Authored-By: Claude
[noreply@anthropic.com](mailto:noreply@anthropic.com)
Co-Authored-By: Gemini CLI


Risk Level: low, no change to existing APIs and features
Testing: new tests added
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

---------

Signed-off-by: Dan Zhang <danzh@google.com>
Co-authored-by: Dan Zhang <danzh@google.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
tested wf breakout from envoyproxy#43605 

renames wfs for consistency (android tests etc are soon going to be
~merged into Mobile/Android eg)

Signed-off-by: Ryan Northey <ryan@synca.io>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
Re-adds Python bindings targeting the current C++ API surface
(EngineBuilder, Engine, StreamClient, StreamPrototype, Stream) using
pybind11. Includes GIL-safe callback shims, Python dict/bytes type
conversions, a fetch client example, and an integration test.

Patched from envoyproxy#43514 
Co-Authored-By: Claude
[noreply@anthropic.com](mailto:noreply@anthropic.com)
Co-Authored-By: Gemini CLI


Risk Level: low, no change to existing APIs and features
Testing: new tests added
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

---------

Signed-off-by: Dan Zhang <danzh@google.com>
Co-authored-by: Dan Zhang <danzh@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants