Skip to content

Commit eb99759

Browse files
authored
move from pip-compile to poetry (#70)
* move from pip-compile to poetry * fix python-version * update actions; cache poetry deps * add poetry.lock * restructure ci workflow based on https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages * remove packages line * forgot to convert tox.ini * bring readme up-to-date * add missing package
1 parent 48430e3 commit eb99759

File tree

8 files changed

+439
-99
lines changed

8 files changed

+439
-99
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
steps:
11-
- uses: actions/checkout@v2
12-
- name: Set up Python 3.9
13-
uses: actions/setup-python@v2
14-
with:
15-
python-version: 3.9
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
pip install tox==3.20.1
20-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
21-
- name: tox
22-
run: |
23-
tox
10+
- uses: actions/checkout@v4
11+
- name: Install poetry
12+
run: pipx install poetry
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.10"
17+
cache: "poetry"
18+
- run: poetry install
19+
- name: tox
20+
run: |
21+
poetry run tox

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# advent-of-code
22

3+
## Running
4+
35
To run the problem for a day, run the Python module like
46

57
```sh
6-
python -m y2020.problem01
8+
poetry run python -m y2020.problem01
79
```
810

11+
The solution code generally has no dependencies outside of the standard library
12+
but for tests, formatting etc I'm using [poetry](https://python-poetry.org/) to
13+
manage dependencies.
14+
15+
## Setting up new problem
16+
917
To generate code for a new problem/day from a template, run:
1018

1119
```sh
@@ -14,8 +22,10 @@ To generate code for a new problem/day from a template, run:
1422

1523
This will create files in a directory named `y$YEAR/$DAY`.
1624

25+
## Tests
26+
1727
Run the tests (yes I wrote tests) with `tox` or `pytest` or to run them for just
18-
one problem, `pytest <year>/<directory>`.
28+
one problem, `poetry run pytest <year>/<directory>`.
1929

2030
Install the pre-commit hooks to keep the code nicely formatted via
2131
[pre-commit](https://pre-commit.com/) with `pre-commit install`.
@@ -26,9 +36,3 @@ To benchmark one of the modules with `timeit`, can run something like:
2636
python -m timeit -s 'import y2021.problem15; inp = open("y2021/problem15/input").read(-1).strip()' 'y2021.problem15.part1(inp)'
2737
1 loop, best of 5: 938 msec per loop
2838
```
29-
30-
The `requirements.txt` file is generated with pip-compile from [pip-tools](https://pip-tools.readthedocs.io/en/latest/). To re-compile:
31-
32-
```
33-
pip-compile --no-emit-index-url > requirements.txt
34-
```

0 commit comments

Comments
 (0)