Skip to content

Commit 0ba580d

Browse files
twondsclaude
andauthored
Migrate from distutils/setup.py to uv with pyproject.toml (#74)
* Migrate from distutils/setup.py to uv with pyproject.toml Replace the deprecated distutils-based setup.py and flat requirements.txt with a modern pyproject.toml using hatchling. Update CI, Dockerfile, and test runner to use uv for dependency management and execution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix DummyPint missing reactor attribute in xep206 tests Twisted's server.Session now requires site.reactor. Add the reactor attribute to the DummyPint test fixture to match HttpbService. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a43e4a3 commit 0ba580d

File tree

8 files changed

+506
-61
lines changed

8 files changed

+506
-61
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v4
24+
2225
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: ${{ matrix.python-version }}
26+
run: uv python install ${{ matrix.python-version }}
2627

2728
- name: Install dependencies
2829
run: |
29-
pip install flake8 service_identity
30-
pip install "${{ matrix.twisted }}"
30+
uv sync --python ${{ matrix.python-version }}
31+
uv pip install "${{ matrix.twisted }}"
3132
if [ -n "${{ matrix.pyopenssl }}" ]; then
32-
pip install ${{ matrix.pyopenssl }}
33+
uv pip install ${{ matrix.pyopenssl }}
3334
fi
34-
python setup.py install
3535
3636
- name: Run tests
3737
run: ./run_tests.sh

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ RUN apt-get update \
1010
&& useradd -ms /bin/bash punjab \
1111
&& chown -R punjab:punjab /home/punjab
1212

13+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
1314

1415
USER punjab
1516

16-
COPY --chown=punjab:punjab *.* ./
17-
1817
COPY --chown=punjab:punjab . .
1918

20-
21-
RUN pip install --user -U -r requirements.txt
22-
RUN python setup.py install --force --user
19+
RUN uv sync
2320

2421
# Default command
2522

26-
CMD twistd --nodaemon --python=run.py
23+
CMD uv run twistd --nodaemon --python=run.py

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "punjab"
7+
version = "0.16"
8+
description = "Punjab, a twisted BOSH server."
9+
readme = "README.txt"
10+
license = "MIT"
11+
requires-python = ">=3.10"
12+
authors = [
13+
{ name = "Christopher Zorn", email = "tofu@thetofu.com" },
14+
]
15+
16+
dependencies = [
17+
"twisted",
18+
"pyopenssl",
19+
"service_identity",
20+
]
21+
22+
[project.urls]
23+
Homepage = "https://github.com/twonds/punjab"
24+
25+
[dependency-groups]
26+
dev = [
27+
"flake8",
28+
]
29+
30+
[tool.hatch.build.targets.wheel]
31+
packages = ["punjab", "twisted"]
32+
33+
[tool.hatch.build.targets.wheel.force-include]
34+
"twisted/plugins/punjab_plugin.py" = "twisted/plugins/punjab_plugin.py"

requirements.txt

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

run_tests.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
2-
python --version
3-
flake8 punjab
4-
5-
cd tests;export PYTHONPATH=${PWD};trial xep124 testparser xep206
2+
uv run python --version
3+
uv run flake8 punjab
64

5+
cd tests;export PYTHONPATH=${PWD};uv run trial xep124 testparser xep206

setup.py

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

tests/xep206.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DummyPint(object):
4343

4444
def __init__(self):
4545
self.v = False
46+
self.reactor = reactor
4647

4748

4849
class XEP0206TestCase(test_basic.TestCase):

uv.lock

Lines changed: 458 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)