Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
},
"name": "Python 3.11",
"image": "mcr.microsoft.com/devcontainers/python:3.11",
"features": {
"ghcr.io/devcontainers-contrib/features/poetry:1": {}
},
"postCreateCommand": "bash ./.devcontainer/post-install.sh"
}
}
9 changes: 6 additions & 3 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
poetry config virtualenvs.in-project true
poetry config virtualenvs.prefer-active-python true
poetry install
set -euo pipefail

curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"

uv sync --all-groups
17 changes: 10 additions & 7 deletions .github/workflows/build-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.9]
python-version: ["3.10"]
include:
- os: macos-latest
x86_64: ./dist/zorkdemo
Expand All @@ -50,23 +50,26 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pyinstaller
pip install uv
- name: Install dependencies
run: |
uv sync --frozen --all-groups
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
uv run pytest
- name: Deploy with pyinstaller
run: |
echo "BUILD_NUMBER = '${{ github.run_number }}'" >> ${{ github.workspace }}/adventure/util.py
pyinstaller zorkdemo.spec
uv run pyinstaller zorkdemo.spec
${{ github.workspace }}/dist/zorkdemo --version
- name: Upload x86_64 Binary
uses: actions/upload-release-asset@v1.0.1
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.in-project true
poetry config virtualenvs.prefer-active-python true
poetry install
pip install uv
- name: Install dependencies
run: |
uv sync --frozen --all-groups
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
uv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
uv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
poetry run pytest
uv run pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.idea/
.pytest_cache/
__pycache__/
.venv/
build/
dist/
.vscode
*.db
*.env
*.flaskenv

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ A (much simplified) port of a famous adventure game to help teach my daughter ho

Two easy ways to launch the console project:

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.
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.
2. Download one of the binary releases and run the file on your system.

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".

## Web (Hug) version

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

Next. set the flask application environment variables:

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

```sh
hug -m web.app
uv run hug -m web.app
```

Navigate in your browser to:
Expand Down
52 changes: 33 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
[tool.poetry]
[project]
name = "zorkdemo"
version = "0.3.1"
description = "A (much simplified) port of a famous adventure game to help teach my daughter how to program in Python."
authors = ["Brandon Corfman <bcorfman@fastmail.fm>"]
license = "MIT"
authors = [{ name = "Brandon Corfman", email = "bcorfman@fastmail.fm" }]
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"environs>=9.5.0,<10",
"hug>=2.6.1,<3",
"Jinja2>=3.1.2,<4",
"Markdown>=3.4.1,<4",
"marshmallow>=3.13.0,<4",
"peewee>=3.15.4,<4",
"rich>=13.0.0,<14",
]

[tool.poetry.dependencies]
python = "^3.8.1"
environs = "^9.5.0"
hug = "^2.6.1"
Jinja2 = "^3.1.2"
Markdown = "^3.4.1"
peewee = "^3.15.4"
rich = "^13.0.0"
[dependency-groups]
dev = [
"coverage>=7.0.1,<8",
"flake8>=6.0.0,<7",
"ipython>=8.7.0,<9",
"pyinstaller>=6.0.0,<7",
"pytest>=7.2.0,<8",
"yapf>=0.32.0,<1",
]

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.0"
ipython = "^8.7.0"
coverage = "^7.0.1"
flake8 = "^6.0.0"
yapf = "^0.32.0"
[tool.setuptools]
py-modules = ["zorkdemo"]

[tool.setuptools.packages.find]
where = ["."]
include = ["adventure*", "web*"]

[tool.uv]
default-groups = ["dev"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["setuptools>=69", "wheel"]
build-backend = "setuptools.build_meta"
19 changes: 0 additions & 19 deletions setup.py

This file was deleted.

Loading