Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI
permissions:
contents: read

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Set up Python
run: uv python install

- name: Install dependencies
run: |
uv sync --dev
cd 01-hello && uv run pywrangler dev --help

- name: Run tests
run: uv run pytest -vv
43 changes: 0 additions & 43 deletions .github/workflows/vendoring.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/vendoring/unix.sh

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/vendoring/windows.bat

This file was deleted.

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
**/.wrangler
**/node_modules
.wrangler
node_modules
python_modules
__pycache__
12 changes: 4 additions & 8 deletions 01-hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ your code between now and official release time as APIs may change.

## How to Run

First ensure that your Wrangler version is up to date (3.30.0 and above).
First ensure that `uv` is installed:
https://docs.astral.sh/uv/getting-started/installation/#standalone-installer

```bash
$ wrangler -v
⛅️ wrangler 3.30.0
```

Now, if you run `wrangler dev` within this directory, it should use the config
Now, if you run `uv run pywrangler dev` within this directory, it should use the config
in `wrangler.toml` to run the example.

You can also run `wrangler deploy` to deploy the example.
You can also run `uv run pywrangler deploy` to deploy the example.
14 changes: 14 additions & 0 deletions 01-hello/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "hello-python"
version = "0.1.0"
description = "Python hello world worker"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"webtypy>=0.1.7",
]

[dependency-groups]
dev = [
"workers-py"
]
155 changes: 155 additions & 0 deletions 01-hello/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 5 additions & 11 deletions 02-binding/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# Bindings Example
# Environment Binding Example

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.

## How to Run

First ensure that your Wrangler version is up to date (3.30.0 and above).
First ensure that `uv` is installed:
https://docs.astral.sh/uv/getting-started/installation/#standalone-installer

```bash
$ wrangler -v
⛅️ wrangler 3.30.0
```

Now, you must set up a [KV namespace](https://developers.cloudflare.com/kv/reference/kv-namespaces/). Edit `wrangler.toml` to reflect the KV namespace you created.

Now, if you run `wrangler dev` within this directory, it should use the config
Now, if you run `uv run pywrangler dev` within this directory, it should use the config
in `wrangler.toml` to run the example.

You can also run `wrangler deploy` to deploy the example.
You can also run `uv run pywrangler deploy` to deploy the example.
14 changes: 14 additions & 0 deletions 02-binding/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "hello-python-bindings"
version = "0.1.0"
description = "Python bindings example"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"webtypy>=0.1.7",
]

[dependency-groups]
dev = [
"workers-py"
]
6 changes: 3 additions & 3 deletions 02-binding/src/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class Default(WorkerEntrypoint):
async def fetch(selfrequest, env):
await env.FOO.put("bar", "baz")
bar = await env.FOO.get("bar")
async def fetch(self, request):
await self.env.FOO.put("bar", "baz")
bar = await self.env.FOO.get("bar")
return Response(bar) # returns "baz"
Loading