Skip to content

Commit 4e6d3db

Browse files
committed
Migrate to UV package manager
- Update pyproject.toml with all dependencies and metadata - Remove setup.py and requirements.txt (replaced by pyproject.toml) - Update all GitHub Actions workflows to use UV - Add dev dependencies: ruff, pytest-xdist, pytest-cov - Add comprehensive UV migration documentation - Requires Python 3.12+ (down from 3.14) - Use hatchling as build backend - Configure ruff, black, mypy, and pytest in pyproject.toml
1 parent ee810c9 commit 4e6d3db

File tree

8 files changed

+327
-73
lines changed

8 files changed

+327
-73
lines changed

.github/workflows/mypy.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build:
11-
10+
typecheck:
1211
runs-on: ubuntu-latest
1312
strategy:
1413
max-parallel: 4
1514
matrix:
16-
python-version: [3.12, 3.13, 3.14]
15+
python-version: ["3.12", "3.13"]
1716

1817
steps:
19-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
19+
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- name: Install Dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install -e .
24+
25+
- name: Install UV
26+
uses: astral-sh/setup-uv@v4
27+
with:
28+
enable-cache: true
29+
30+
- name: Install dependencies
31+
run: uv sync --all-extras
32+
2833
- name: Run mypy
29-
run: |
30-
mypy src
34+
run: uv run mypy src

.github/workflows/pytest.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ on:
77
branches: [ master ]
88

99
jobs:
10-
build:
11-
10+
test:
1211
runs-on: ubuntu-latest
1312
strategy:
1413
max-parallel: 4
1514
matrix:
16-
python-version: [3.12, 3.13, 3.14]
15+
python-version: ["3.12", "3.13"]
1716

1817
steps:
19-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
19+
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- name: Install Dependencies
25-
run: |
26-
python -m pip install --upgrade pip
27-
pip install -e .
28-
- name: Run Tests
29-
run: |
30-
pytest tests
24+
25+
- name: Install UV
26+
uses: astral-sh/setup-uv@v4
27+
with:
28+
enable-cache: true
29+
30+
- name: Install dependencies
31+
run: uv sync --all-extras
32+
33+
- name: Run tests
34+
run: uv run pytest tests
Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
1+
# This workflow will upload a Python Package using UV when a release is created
2+
# UV is a modern, fast Python package manager from Astral (creators of Ruff)
83

94
name: Upload Python Package
105

@@ -14,23 +9,25 @@ on:
149

1510
jobs:
1611
deploy:
17-
1812
runs-on: ubuntu-latest
1913

2014
steps:
21-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
16+
2217
- name: Set up Python
23-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install UV
23+
uses: astral-sh/setup-uv@v4
2424
with:
25-
python-version: '3.x'
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install build
25+
enable-cache: true
26+
3027
- name: Build package
31-
run: python -m build
28+
run: uv build
29+
3230
- name: Publish package
33-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
34-
with:
35-
user: __token__
36-
password: ${{ secrets.PYPI_API_TOKEN }}
31+
env:
32+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
33+
run: uv publish

UV_MIGRATION.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# UV Package Manager Migration
2+
3+
This project has been migrated from pip/setuptools to **UV**, a modern, fast Python package manager from Astral (the creators of Ruff).
4+
5+
## What Changed
6+
7+
### ✅ Migrated to UV
8+
- **Package management**: Now using `uv` instead of `pip`
9+
- **Configuration**: All dependencies now in `pyproject.toml` (single source of truth)
10+
- **Lock file**: `uv.lock` ensures reproducible builds
11+
- **GitHub Actions**: All workflows updated to use UV
12+
- **Dockerfile**: Already using UV (no changes needed)
13+
14+
### ❌ Removed Files
15+
- `setup.py` - Replaced by `pyproject.toml`
16+
- `requirements.txt` - Dependencies now in `pyproject.toml`
17+
18+
## Installation
19+
20+
### Install UV
21+
22+
```bash
23+
# macOS/Linux
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
26+
# Windows
27+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
28+
29+
# Or with pip
30+
pip install uv
31+
```
32+
33+
### Install Project Dependencies
34+
35+
```bash
36+
# Install production dependencies
37+
uv sync
38+
39+
# Install with dev dependencies
40+
uv sync --all-extras
41+
42+
# Or just dev dependencies
43+
uv sync --extra dev
44+
```
45+
46+
## Usage
47+
48+
### Running the Application
49+
50+
```bash
51+
# Run rom24
52+
uv run rom24
53+
54+
# Or activate the virtual environment
55+
source .venv/bin/activate # Linux/macOS
56+
.venv\Scripts\activate # Windows
57+
rom24
58+
```
59+
60+
### Development Commands
61+
62+
```bash
63+
# Run tests
64+
uv run pytest
65+
66+
# Run tests with coverage
67+
uv run pytest --cov=rom24
68+
69+
# Run mypy type checking
70+
uv run mypy src
71+
72+
# Run black formatter
73+
uv run black src
74+
75+
# Run ruff linter
76+
uv run ruff check src
77+
78+
# Format with ruff
79+
uv run ruff format src
80+
```
81+
82+
### Adding Dependencies
83+
84+
```bash
85+
# Add a production dependency
86+
uv add package-name
87+
88+
# Add a dev dependency
89+
uv add --dev package-name
90+
91+
# Remove a dependency
92+
uv remove package-name
93+
```
94+
95+
### Updating Dependencies
96+
97+
```bash
98+
# Update all dependencies
99+
uv lock --upgrade
100+
101+
# Update a specific package
102+
uv lock --upgrade-package package-name
103+
```
104+
105+
## Benefits of UV
106+
107+
1. **⚡ Fast**: 10-100x faster than pip
108+
2. **🔒 Reliable**: Lock file ensures reproducible builds
109+
3. **🎯 Simple**: Single tool for all Python package management
110+
4. **🔄 Compatible**: Works with existing pip/PyPI ecosystem
111+
5. **📦 Modern**: Built with Rust, designed for modern Python workflows
112+
113+
## Migration Notes
114+
115+
- The `pyproject.toml` now contains all project metadata and dependencies
116+
- Dev dependencies are in `[project.optional-dependencies.dev]`
117+
- The entry point `rom24` is defined in `[project.scripts]`
118+
- Python 3.12+ is required (down from 3.14 in the old config)
119+
- All GitHub Actions workflows now use UV for faster CI/CD
120+
121+
## Troubleshooting
122+
123+
### UV not found
124+
Make sure UV is installed and in your PATH:
125+
```bash
126+
uv --version
127+
```
128+
129+
### Dependencies not syncing
130+
Try removing the virtual environment and re-syncing:
131+
```bash
132+
rm -rf .venv
133+
uv sync --all-extras
134+
```
135+
136+
### Lock file conflicts
137+
Update the lock file:
138+
```bash
139+
uv lock
140+
```
141+
142+
## Documentation
143+
144+
- UV Documentation: https://docs.astral.sh/uv/
145+
- UV GitHub: https://github.com/astral-sh/uv
146+
- Astral Blog: https://astral.sh/blog
147+

pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[project]
2+
name = "rom24"
3+
version = "0.0.1.alpha2"
4+
description = "ROM 2.4 Python MUD Server - A modern Python implementation of the classic ROM MUD"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "Micheal Taylor", email = "bubthegreat@gmail.com" }
8+
]
9+
requires-python = ">=3.12"
10+
dependencies = [
11+
"psutil>=6.1.1",
12+
]
13+
14+
[project.optional-dependencies]
15+
dev = [
16+
"black>=24.10.0",
17+
"ipdb>=0.13.13",
18+
"mypy>=1.14.1",
19+
"pre-commit>=4.0.1",
20+
"pytest>=9.0.2",
21+
"pytest-xdist>=3.6.1",
22+
"pytest-cov>=6.0.0",
23+
"ruff>=0.8.4",
24+
]
25+
26+
[project.scripts]
27+
rom24 = "rom24.pyom:pyom"
28+
29+
[build-system]
30+
requires = ["hatchling"]
31+
build-backend = "hatchling.build"
32+
33+
[tool.hatch.build.targets.wheel]
34+
packages = ["src/rom24"]
35+
36+
[tool.ruff]
37+
line-length = 120
38+
target-version = "py312"
39+
40+
[tool.ruff.lint]
41+
select = ["E", "F", "I", "N", "W"]
42+
ignore = ["E501"] # Line too long (handled by formatter)
43+
44+
[tool.black]
45+
line-length = 120
46+
target-version = ["py312"]
47+
48+
[tool.mypy]
49+
python_version = "3.12"
50+
warn_return_any = true
51+
warn_unused_configs = true
52+
disallow_untyped_defs = false
53+
54+
[tool.pytest.ini_options]
55+
testpaths = ["tests"]
56+
python_files = ["test_*.py", "*_test.py"]
57+
addopts = "-v --cov=rom24 --cov-report=term-missing"

requirements.txt

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

setup.py

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

0 commit comments

Comments
 (0)