Skip to content

Commit bfb2020

Browse files
authored
Merge pull request #9 from bcorfman/uv_convert
Migrate project from Poetry to uv
2 parents 4492939 + 6b83665 commit bfb2020

File tree

9 files changed

+1008
-67
lines changed

9 files changed

+1008
-67
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@
66
},
77
"name": "Python 3.11",
88
"image": "mcr.microsoft.com/devcontainers/python:3.11",
9-
"features": {
10-
"ghcr.io/devcontainers-contrib/features/poetry:1": {}
11-
},
129
"postCreateCommand": "bash ./.devcontainer/post-install.sh"
13-
}
10+
}

.devcontainer/post-install.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2-
poetry config virtualenvs.in-project true
3-
poetry config virtualenvs.prefer-active-python true
4-
poetry install
2+
set -euo pipefail
3+
4+
curl -LsSf https://astral.sh/uv/install.sh | sh
5+
export PATH="$HOME/.local/bin:$PATH"
6+
7+
uv sync --all-groups

.github/workflows/build-app.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
matrix:
3535
os: [macos-latest, ubuntu-latest, windows-latest]
36-
python-version: [3.9]
36+
python-version: ["3.10"]
3737
include:
3838
- os: macos-latest
3939
x86_64: ./dist/zorkdemo
@@ -50,23 +50,26 @@ jobs:
5050
uses: actions/setup-python@v2
5151
with:
5252
python-version: ${{ matrix.python-version }}
53-
- name: Install dependencies
53+
- name: Install uv
5454
run: |
5555
python -m pip install --upgrade pip
56-
pip install flake8 pytest pyinstaller
56+
pip install uv
57+
- name: Install dependencies
58+
run: |
59+
uv sync --frozen --all-groups
5760
- name: Lint with flake8
5861
run: |
5962
# stop the build if there are Python syntax errors or undefined names
60-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
63+
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
6164
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
62-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
65+
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
6366
- name: Test with pytest
6467
run: |
65-
pytest
68+
uv run pytest
6669
- name: Deploy with pyinstaller
6770
run: |
6871
echo "BUILD_NUMBER = '${{ github.run_number }}'" >> ${{ github.workspace }}/adventure/util.py
69-
pyinstaller zorkdemo.spec
72+
uv run pyinstaller zorkdemo.spec
7073
${{ github.workspace }}/dist/zorkdemo --version
7174
- name: Upload x86_64 Binary
7275
uses: actions/upload-release-asset@v1.0.1

.github/workflows/build-test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
os: [ ubuntu-latest, macos-latest, windows-latest ]
12-
python-version: [3.8, 3.9, "3.10", "3.11"]
12+
python-version: ["3.10", "3.11", "3.12"]
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: Set up Python ${{ matrix.python-version }}
1616
uses: actions/setup-python@v2
1717
with:
1818
python-version: ${{ matrix.python-version }}
19-
- name: Install dependencies
19+
- name: Install uv
2020
run: |
2121
python -m pip install --upgrade pip
22-
pip install poetry
23-
poetry config virtualenvs.in-project true
24-
poetry config virtualenvs.prefer-active-python true
25-
poetry install
22+
pip install uv
23+
- name: Install dependencies
24+
run: |
25+
uv sync --frozen --all-groups
2626
- name: Lint with flake8
2727
run: |
2828
# stop the build if there are Python syntax errors or undefined names
29-
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3030
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
31-
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3232
- name: Test with pytest
3333
run: |
34-
poetry run pytest
34+
uv run pytest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.idea/
22
.pytest_cache/
33
__pycache__/
4+
.venv/
45
build/
56
dist/
67
.vscode
78
*.db
89
*.env
910
*.flaskenv
10-

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ A (much simplified) port of a famous adventure game to help teach my daughter ho
99

1010
Two easy ways to launch the console project:
1111

12-
1. Click on the Open with GitHub Codespaces badge above to launch the project in a browser or on your desktop inside Visual Studio Code, then type `poetry run python zorkdemo.py` in the terminal window.
12+
1. Click on the Open with GitHub Codespaces badge above to launch the project in a browser or on your desktop inside Visual Studio Code, then type `uv run python zorkdemo.py` in the terminal window.
1313
2. Download one of the binary releases and run the file on your system.
1414

1515
NOTE: the MacOS version does not have code signing built into it yet (that's next on my list!). To run it, you will need to set the binary as executable with `chmod 755` or similar, and after trying to run it once, go through System Preferences: Security and Privacy: General and "Allow the program to run anyway".
1616

1717
## Web (Hug) version
1818

19-
* Install [Python](https://www.python.org) 3.8.1 or higher
20-
* Install [Poetry](https://python-poetry.org)
21-
* At a command prompt in the project directory, type `poetry install` to set up dependencies
19+
* Install [Python](https://www.python.org) 3.10 or higher
20+
* Install [uv](https://docs.astral.sh/uv/)
21+
* At a command prompt in the project directory, type `uv sync --all-groups` to set up dependencies
2222

2323
Next. set the flask application environment variables:
2424

@@ -39,7 +39,7 @@ EXPORT SECRET_KEY="<put something random here>"
3939
In the root of the project, run:
4040

4141
```sh
42-
hug -m web.app
42+
uv run hug -m web.app
4343
```
4444

4545
Navigate in your browser to:

pyproject.toml

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1-
[tool.poetry]
1+
[project]
22
name = "zorkdemo"
33
version = "0.3.1"
44
description = "A (much simplified) port of a famous adventure game to help teach my daughter how to program in Python."
5-
authors = ["Brandon Corfman <bcorfman@fastmail.fm>"]
6-
license = "MIT"
5+
authors = [{ name = "Brandon Corfman", email = "bcorfman@fastmail.fm" }]
6+
license = { text = "MIT" }
77
readme = "README.md"
8+
requires-python = ">=3.10"
9+
dependencies = [
10+
"environs>=9.5.0,<10",
11+
"hug>=2.6.1,<3",
12+
"Jinja2>=3.1.2,<4",
13+
"Markdown>=3.4.1,<4",
14+
"marshmallow>=3.13.0,<4",
15+
"peewee>=3.15.4,<4",
16+
"rich>=13.0.0,<14",
17+
]
818

9-
[tool.poetry.dependencies]
10-
python = "^3.8.1"
11-
environs = "^9.5.0"
12-
hug = "^2.6.1"
13-
Jinja2 = "^3.1.2"
14-
Markdown = "^3.4.1"
15-
peewee = "^3.15.4"
16-
rich = "^13.0.0"
19+
[dependency-groups]
20+
dev = [
21+
"coverage>=7.0.1,<8",
22+
"flake8>=6.0.0,<7",
23+
"ipython>=8.7.0,<9",
24+
"pyinstaller>=6.0.0,<7",
25+
"pytest>=7.2.0,<8",
26+
"yapf>=0.32.0,<1",
27+
]
1728

18-
[tool.poetry.group.dev.dependencies]
19-
pytest = "^7.2.0"
20-
ipython = "^8.7.0"
21-
coverage = "^7.0.1"
22-
flake8 = "^6.0.0"
23-
yapf = "^0.32.0"
29+
[tool.setuptools]
30+
py-modules = ["zorkdemo"]
31+
32+
[tool.setuptools.packages.find]
33+
where = ["."]
34+
include = ["adventure*", "web*"]
35+
36+
[tool.uv]
37+
default-groups = ["dev"]
2438

2539
[build-system]
26-
requires = ["poetry-core"]
27-
build-backend = "poetry.core.masonry.api"
40+
requires = ["setuptools>=69", "wheel"]
41+
build-backend = "setuptools.build_meta"

setup.py

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

0 commit comments

Comments
 (0)