Skip to content

Commit 57e8d36

Browse files
committed
Use workers-py!
1 parent 9e7c7b3 commit 57e8d36

File tree

15 files changed

+594
-138
lines changed

15 files changed

+594
-138
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,19 @@ jobs:
1919
- name: Checkout repository
2020
uses: actions/checkout@v4
2121

22-
- name: Set up Python
23-
uses: actions/setup-python@v4
24-
with:
25-
python-version: '3.12'
26-
27-
- name: Install Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: 22
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
3124

3225
- name: Install project dependencies
33-
run: npm install
34-
35-
- name: Run build with npm script
36-
run: npm run build
26+
run: uv sync
3727

3828
- name: Lint and format
39-
run: npm run lint
29+
run: |
30+
uv run ruff format . --check
31+
uv run ruff check .
4032
4133
- name: Test worker deployment
42-
run: npm run deploy -- --dry-run
34+
run: uv run pywrangler deploy --dry-run
4335

4436
- name: Run tests
45-
run: npm run test
37+
run: uv run pytest tests

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.venv/
2-
.venv-pyodide/
2+
.venv-workers/
3+
.ruff_cache/
34
.pytest_cache/
45
node_modules/
56
package-lock.json

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

README.md

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,37 @@ This is an example of a Python Worker that uses the FastMCP package.
77
>[!NOTE]
88
>Due to the [size](https://developers.cloudflare.com/workers/platform/limits/#worker-size) of the Worker, this example can only be deployed if you're using the Workers Paid plan. Free plan users will encounter deployment errors because this Worker exceeds the 3MB size limit.
99
10-
## Adding Packages
11-
12-
Vendored packages are added to your source files and need to be installed in a special manner. The Python Workers team plans to make this process automatic in the future, but for now, manual steps need to be taken.
13-
14-
### Vendoring Packages
15-
16-
First, install Python3.12 and pip for Python 3.12.
17-
18-
*Currently, other versions of Python will not work - use 3.12!*
19-
20-
Then set up your local pyodide virtual environment:
21-
```console
22-
npm run build
23-
```
24-
25-
### Developing and Deploying
10+
## Developing and Deploying
2611

2712
To develop your Worker run:
13+
2814
```console
29-
npm run dev
15+
uv run pywrangler dev
3016
```
3117

3218
To deploy your Worker run:
19+
3320
```console
34-
npm run deploy
21+
uv run pywrangler deploy
3522
```
3623

37-
### Testing
24+
## Testing
3825

3926
To test run:
27+
4028
```console
41-
npm run test
29+
uv run pytest tests
4230
```
4331

44-
### Linting and Formatting
32+
## Linting and Formatting
4533

4634
This project uses Ruff for linting and formatting:
4735

4836
```console
49-
npm run lint
37+
uv ruff format . --check
38+
uv ruff check .
5039
```
5140

52-
### IDE Integration
53-
54-
To have good autocompletions in your IDE simply select .venv-pyodide/bin/python as your IDE's interpreter.
41+
## IDE Integration
5542

56-
You should also install your dependencies for type hints.
57-
58-
```console
59-
.venv-pyodide/bin/pip install -r requirements-dev.txt
60-
```
43+
To have good autocompletions in your IDE simply select .venv-workers/bin/python as your IDE's interpreter.

package.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

pyproject.toml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
1+
[project]
2+
name = "python-workers-mcp"
3+
version = "0.1.0"
4+
requires-python = "==3.12.*"
5+
dependencies = ["mcp", "structlog"]
6+
7+
[dependency-groups]
8+
dev = [
9+
"workers-py@git+https://github.com/cloudflare/workers-py",
10+
"pytest",
11+
"requests",
12+
"pytest-asyncio",
13+
"ruff",
14+
]
15+
116
[tool.ruff]
217
target-version = "py312"
318
line-length = 100
419
[tool.ruff.lint]
520
select = [
6-
"E", # pycodestyle errors
7-
"F", # pyflakes
8-
"B", # flake8-bugbear
9-
"I", # isort
21+
"E", # pycodestyle errors
22+
"F", # pyflakes
23+
"B", # flake8-bugbear
24+
"I", # isort
1025
"C4", # flake8-comprehensions
1126
"UP", # pyupgrade
12-
"N", # pep8-naming
13-
"RUF", # ruff-specific rules
27+
"N", # pep8-naming
28+
"RUF", # ruff-specific rules
1429
]
1530
ignore = []
1631

requirements-dev.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

requirements-test.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/build.sh

Lines changed: 0 additions & 43 deletions
This file was deleted.

scripts/lint.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)