Skip to content

Commit 24128be

Browse files
committed
Use workers-py!
1 parent e160752 commit 24128be

File tree

14 files changed

+503
-135
lines changed

14 files changed

+503
-135
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,24 @@ 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'
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
2624

27-
- name: Install Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: 22
25+
# - name: Install Node.js
26+
# uses: actions/setup-node@v4
27+
# with:
28+
# node-version: 22
3129

3230
- name: Install project dependencies
33-
run: npm install
34-
35-
- name: Run build with npm script
36-
run: npm run build
31+
run: uv sync
3732

3833
- name: Lint and format
39-
run: npm run lint
34+
run: |
35+
uv run ruff format . --check
36+
uv run ruff check .
4037
4138
- name: Test worker deployment
42-
run: npm run deploy -- --dry-run
39+
run: uv run pywrangler deploy --dry-run
4340

4441
- name: Run tests
45-
run: npm run test
42+
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

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: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1+
[project]
2+
name = "python-mcp"
3+
version = "0.1.0"
4+
requires-python = "==3.12.*"
5+
dependencies = ["mcp", "structlog"]
6+
7+
[dependency-groups]
8+
dev = ["workers-py", "pytest", "requests", "pytest-asyncio", "ruff"]
9+
10+
# [tool.uv.sources]
11+
# workers-py = { path = "../workers-py" }
12+
113
[tool.ruff]
214
target-version = "py312"
315
line-length = 100
416
[tool.ruff.lint]
517
select = [
6-
"E", # pycodestyle errors
7-
"F", # pyflakes
8-
"B", # flake8-bugbear
9-
"I", # isort
18+
"E", # pycodestyle errors
19+
"F", # pyflakes
20+
"B", # flake8-bugbear
21+
"I", # isort
1022
"C4", # flake8-comprehensions
1123
"UP", # pyupgrade
12-
"N", # pep8-naming
13-
"RUF", # ruff-specific rules
24+
"N", # pep8-naming
25+
"RUF", # ruff-specific rules
1426
]
1527
ignore = []
1628

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.

scripts/test.sh

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

0 commit comments

Comments
 (0)