Skip to main content

Python Func Runtime

This middleware is used by Knative Functions to expose a Function written in Python as a network service.

Contents

.
├── cmd
│   └── fhttp                - Example Function using the http middleware
│   └── fcloudevent          - Example Function using the CloudEvent middleware
├── src/func_python
│   ├── http.py              - HTTP Middleware
│   ├── cloudevents.py       - CloudEvent Middleware
├── tests
│   ├── http_test.py         - HTTP Middleware tests
│   ├── cloudevent_test.py   - CloudEvent tests
└── README.md                - This Readme

Development

Tests

Install dependencies: poetry install

Run suite: poetry run pytest

Or more verbosely: poetry run pytest -vs --log-cli-level=INFO

To enable more granular log levels: poetry run pytest --log-cli-level=INFO

Example Commands

Minimal example of running the test command, which shows how this library is used when integrate with Functions, and can be useful during dev.

  • install poetry via pipx
  • install dependencies with poetry install
  • activate the virtual environment managed by poetry via poetry shell Note that in some environments this command may cause collissions with configured keyboard shortcuts. If there are problems, you can instead source the environment variables directly with: source $(poetry env info --path)/bin/activate
  • run the example via poetry run python cmd/fhttp/main.py
  • deactivate the virtual environment with exit

Suggested Flow

A nice method of development using git worktrees:

p. From a personal fork, create a new worktree for the bug, feature or chore named appropriately (eg. "feature-a") git worktree add feature-a

  1. Implement the code changes and commit.

  2. Update the CHANGELOG.md to include the change in the "Unreleased" section.

  3. Commit, push and create a PR to the upstream repository's main branch.

  4. Solicit a code-read from another team member.

  5. Upon approval, squash and merge to main.

  6. (optional) cleanup by removing the worktree and associated local and remote branches.

  7. (optional) pull into local fork's main and push to remote fork main.

Testing Published Package

Prior to releasing, it's possible to test the package which was published to TestPyPI when the release PR is merged to main but before the tag is pushed (which triggers production release).

To test, in a test project ensure the it adds the test package as an explicit source in pyproject.toml:

[[tool.poetry.source]]
name = "test-pypi"
url = "https://test.pypi.org/simple/"
priority = "explicit"

Then update the dependency to explicitly pull the new version which is only available on TestPyPI. For example to test a hypothetical unreleased version 0.1.2:

[tool.poetry.dependencies]
func_python = {version = "0.1.2", source = "test-pypi"}

Run poetry install to install the unreleased version from Test PyPI

Note: do not check in this change.

Releasing

NOTE: This process is currently undergoing minor tweaks, and thus contains several manual steps. Once the process is codified, it can be more highly automated.

  1. Create a new branch "release-x.y" from an up-to-date main When incrementing, follow Semantic Versioning standard. eg:

    • Bug fixes: ++ patch version
    • Features: ++ minor version
    • Breaking Changes: ++ major version
  2. Update pyproject.toml with the new version.

  3. Update CHANGELOG.md by moving the "Unreleased" items into a new section for the given version (leaving an empty Unreleased section as a template for future updates)

  4. Commit, push and create a PR to upstream's main branch Please set the commit message to "Release vx.y.z" with the new version number

  5. Obtain approval for release from another team member.

  6. Squash and merge (ensure the commit message remains Release vx.y.x).

  7. Verify the new version was correctly published to test PyPI and all precautions have been taken to ensure it is functioning as intended. (See testing above)

  8. Pull from upstream into your local main branch and tag the commit vx.y.z (the squash and merge will have created a new commit hash)

  9. push the tag to upstream, triggering the release to production PyPI.

  10. Update the GitHub release's notes to be the changelog section's contents .

Potential improvements

Update to using the suffix "rcX" so as not to confuse folks pulling tags list from the git repo. Without this suffix, a simple listing of the latest tags from the repo would show a potentially unreleased version as the latest.

With the use of these release-candidate tags, the use of TestPyPI may be unnecessary.

Perhaps push the RC tag to the PR's commit and test prior to merging the PR to main, such that a potentially broken version is not kept in the main branch's history. For example, if v0.1.2rc1 failed, its commit will not be part of the main branch.

Metadata

Release files for func-python 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for func-python 0.8.1
File Size Uploaded Provenance Actions
func_python-0.8.1.tar.gz 13.3 kB With provenance Details for func_python-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for func-python 0.8.1
File Interpreter ABI Platform Actions
func_python-0.8.1-py3-none-any.whl Python 3 none any Details for func_python-0.8.1-py3-none-any.whl

Total release size: 27.9 kB

Release files / func_python-0.8.1.tar.gz

Download URL func_python-0.8.1.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
766a59766012d52e19da03d30fae4f414ee1fe8bfd0e64a95f7812505cc14fe4
BLAKE2b-256 checksum
How to use checksums
9b05d30c1fea8722a43aa7b25f7f594ed45acc9376ee60e75adf9fc741b185cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.

Transparency log

Release files / func_python-0.8.1-py3-none-any.whl

Download URL func_python-0.8.1-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7527482dc69706f45736393213443614f70ffa700220f5a8ad09a1479ea94f3
BLAKE2b-256 checksum
How to use checksums
7254bf7403eabe9d579c28d5daa6cd537efc43e663206074b8bcb31ad9174613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.

Transparency log

Security for func-python 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for func_python-0.8.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page