|
3 | 3 | Simple template for Python `3.12` with `pyenv`/`pyenv-virtualenv` and `poetry`. |
4 | 4 |
|
5 | 5 | - [quickstart](#quickstart) |
6 | | -- [pyenv/pyenv-virtualenv](#pyenvpyenv-virtualenv) |
7 | | -- [poetry](#poetry) |
| 6 | + - [pyenv/pyenv-virtualenv](#pyenvpyenv-virtualenv) |
| 7 | + - [poetry](#poetry) |
| 8 | + - [pre-comit](#pre-commit) |
| 9 | +- [docker](#docker) |
8 | 10 | - [vagrant](#vagrant) |
9 | 11 | - [reference](#reference) |
10 | 12 |
|
11 | 13 | ## quickstart |
12 | 14 |
|
13 | | -- clone the repo |
14 | | - ```shell |
15 | | - git clone git@github.com:markgreene74/python-template.git |
16 | | - ``` |
| 15 | +### clone the repo |
17 | 16 |
|
18 | | -## pyenv/pyenv-virtualenv |
| 17 | +```shell |
| 18 | +git clone git@github.com:markgreene74/python-template.git |
| 19 | + ``` |
19 | 20 |
|
20 | | -TODO |
21 | | -- make sure `pyenv` is installed |
22 | | -- make sure `pyenv-virtualenv` is installed |
| 21 | +### pyenv/pyenv-virtualenv |
| 22 | + |
| 23 | +- make sure `pyenv` and `pyenv-virtualenv` are installed |
23 | 24 | - install python `3.12`, for example `3.12.3` |
24 | 25 | ```bash |
25 | 26 | pyenv install 3.12.3 |
|
37 | 38 | pip install --upgrade pip setuptools |
38 | 39 | ``` |
39 | 40 |
|
40 | | -## poetry |
| 41 | +### poetry |
41 | 42 |
|
42 | 43 | - install poetry |
43 | 44 | ```bash |
44 | 45 | pip install --upgrade poetry==1.8.3 |
45 | 46 | ``` |
46 | | -- install the application runtime dependencies |
47 | | - ```bash |
48 | | - poetry install --only main |
49 | | - ``` |
50 | | -- install the application test dependencies |
| 47 | +- to install |
| 48 | + - the application runtime dependencies |
| 49 | + ```bash |
| 50 | + poetry install --only main |
| 51 | + ``` |
| 52 | + - the application test dependencies |
| 53 | + ```bash |
| 54 | + poetry install --with test |
| 55 | + ``` |
| 56 | + - the application dev and test dependencies |
| 57 | + ```bash |
| 58 | + poetry install --with test,dev |
| 59 | + ``` |
| 60 | + - the dependencies but not the current project |
| 61 | + ```bash |
| 62 | + poetry install --no-root --with test,dev |
| 63 | + ``` |
| 64 | + |
| 65 | +### pre-commit |
| 66 | + |
| 67 | +This project uses [`pre-commit`](https://pre-commit.com/). |
| 68 | + |
| 69 | +- install the hooks from the `.pre-commit-config.yaml` file |
51 | 70 | ```bash |
52 | | - poetry install --with test |
| 71 | + pre-commit install |
53 | 72 | ``` |
54 | | -- install the application dev, test dependencies |
55 | | - ```bash |
56 | | - poetry install --with test,dev |
| 73 | + |
| 74 | +## docker |
| 75 | + |
| 76 | +- build the image |
| 77 | + ```shell |
| 78 | + docker build -t python-template . |
57 | 79 | ``` |
58 | | -- install the dependencies but not the current project |
59 | | - ```bash |
60 | | - poetry install --no-root --with test,dev |
| 80 | +- run the container |
| 81 | + ```shell |
| 82 | + docker run -it --rm python-template |
61 | 83 | ``` |
62 | 84 |
|
63 | | -## pre-commit |
64 | | - |
65 | | -This project use `pre-commit`. A `.pre-commit-config.yaml` is included. |
| 85 | +Intermediate stages (`test`, `dev`) are available in the `Dockerfile`. Build them with: |
| 86 | +```shell |
| 87 | +docker build -t python-template . --target <stage> |
| 88 | +``` |
66 | 89 |
|
67 | | -Run `pre-commit install` to install the Git hooks. |
| 90 | +For example, build and tun the tests with: |
| 91 | +```shell |
| 92 | +docker build -t python-template . --target test && \ |
| 93 | + docker run -it --rm python-template |
| 94 | +``` |
68 | 95 |
|
69 | 96 | ## vagrant |
70 | 97 |
|
|
0 commit comments