From 1ea167396dd3eb2cbaf28be71269041c098ffd13 Mon Sep 17 00:00:00 2001 From: Peter Gorniak Date: Mon, 8 Apr 2024 01:09:54 +0200 Subject: [PATCH] Cleanup requirements, docker file (#507) * Cleanup requirements and docker files * do not default to --help in dockerfile * need dev requirements for compiling card db --------- Co-authored-by: Nick Vance <704392+nickv2002@users.noreply.github.com> --- .dockerignore | 1 - .github/workflows/compile_card_db.yml | 1 + .github/workflows/lint_and_test.yml | 1 + README.md | 8 +- dev-requirements.txt | 114 ++++++++++++++++++++++++++ dockerfile | 16 +--- dodo.py | 8 +- pyproject.toml | 1 + requirements.in | 8 -- requirements.txt | 44 +--------- 10 files changed, 127 insertions(+), 75 deletions(-) create mode 100644 dev-requirements.txt delete mode 100644 requirements.in diff --git a/.dockerignore b/.dockerignore index 4d5d72fc..06c1032e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,6 @@ .dockerignore .dockerfile README.md -requirements.txt .github tools *pdf diff --git a/.github/workflows/compile_card_db.yml b/.github/workflows/compile_card_db.yml index f9075310..44cc5116 100644 --- a/.github/workflows/compile_card_db.yml +++ b/.github/workflows/compile_card_db.yml @@ -12,6 +12,7 @@ jobs: python-version: 3.9 - run: | pip install -r requirements.txt + pip install -r dev-requirements.txt pip install . - name: Update Languages run: doit update_languages diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index 1aac897a..c025f2cc 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -15,6 +15,7 @@ jobs: python-version: 3.9 - run: | pip install -r requirements.txt + pip install -r dev-requirements.txt pip install . - name: Install PyICU if: ${{ matrix.os == 'ubuntu-latest'}} diff --git a/README.md b/README.md index 5d66e001..4fe36078 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The library will be installed as `domdiv` with the main entry point being `domdi ## Developing -Install requirements via `pip install -r requirements.txt`. Then, run `pre-commit install`. You can use `pip install -e .[dev]` to install the `dominion_dividers` script so that it calls your checked out code, enabling you to run edited code without having to perform an install every time. This also installs needed dev dependencies. +Install requirements via `pip install -r requirements.txt`. Then, run `pre-commit install`. You can use `pip install -e .[dev]` to install the `dominion_dividers` script so that it calls your checked out code, enabling you to run edited code without having to perform an install every time. This also installs needed dev dependencies, or if you want the pinned versions use `pip install -r dev-requirements.txt` instead. Feel free to comment on boardgamegeek at or file issues on github (). @@ -56,14 +56,12 @@ The project can be compiled into a container: `docker build . -t dominiontabs` -Once you have the `dominiontabs` container you can run it from your CLI and pass it arguments like so: +Once you have the `dominiontabs` container you can run it from your CLI and pass it arguments like so, mapping the local directory to where the script will run so you can use local fonts and access the output file (example produces German dividers for Seaside 2nd edition): -`docker run dominiontabs` +`docker run -v .:/app dominiontabs --language=de --expansions=seaside2ndEdition` -Which will, by default, dump the output of the help text of the CLI tool. But we're going to want to add in some extra args 99% of the time. - 1. Bind mount to an output directory (`-v`) and tell the script to output there so that we get a PDF in the local filesystem when things are done (`--outfile ./output/foo.pdf`). 1. Add the `--rm` argo to tell docker not to save a container each time it runs. 1. Point to the fonts built in to the image with `--font-dir /fonts` diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..1ef62d30 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,114 @@ +# +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile --extra=dev --no-emit-index-url --output-file=dev-requirements.txt +# +build==1.1.1 + # via domdiv (pyproject.toml) +certifi==2024.2.2 + # via requests +cfgv==3.4.0 + # via pre-commit +chardet==5.2.0 + # via reportlab +charset-normalizer==3.3.2 + # via requests +cloudpickle==3.0.0 + # via doit +configargparse==1.7 + # via domdiv (pyproject.toml) +distlib==0.3.8 + # via virtualenv +docutils==0.20.1 + # via readme-renderer +doit==0.36.0 + # via domdiv (pyproject.toml) +exceptiongroup==1.2.0 + # via pytest +filelock==3.13.1 + # via virtualenv +identify==2.5.35 + # via pre-commit +idna==3.6 + # via requests +importlib-metadata==7.1.0 + # via + # build + # doit + # keyring + # twine +iniconfig==2.0.0 + # via pytest +jaraco-classes==3.3.1 + # via keyring +keyring==24.3.1 + # via twine +markdown-it-py==3.0.0 + # via rich +mdurl==0.1.2 + # via markdown-it-py +more-itertools==10.2.0 + # via jaraco-classes +nh3==0.2.15 + # via readme-renderer +nodeenv==1.8.0 + # via pre-commit +packaging==24.0 + # via + # build + # pytest +pillow==10.2.0 + # via + # domdiv (pyproject.toml) + # reportlab +pkginfo==1.10.0 + # via twine +platformdirs==4.2.0 + # via virtualenv +pluggy==1.4.0 + # via pytest +pre-commit==3.6.2 + # via domdiv (pyproject.toml) +pygments==2.17.2 + # via + # readme-renderer + # rich +pyproject-hooks==1.0.0 + # via build +pytest==8.1.1 + # via domdiv (pyproject.toml) +pyyaml==6.0.1 + # via pre-commit +readme-renderer==43.0 + # via twine +reportlab==4.1.0 + # via domdiv (pyproject.toml) +requests==2.31.0 + # via + # requests-toolbelt + # twine +requests-toolbelt==1.0.0 + # via twine +rfc3986==2.0.0 + # via twine +rich==13.7.1 + # via twine +tomli==2.0.1 + # via + # build + # pyproject-hooks + # pytest +twine==5.0.0 + # via domdiv (pyproject.toml) +urllib3==2.2.1 + # via + # requests + # twine +virtualenv==20.25.1 + # via pre-commit +zipp==3.18.1 + # via importlib-metadata + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/dockerfile b/dockerfile index c6d74886..7372a897 100644 --- a/dockerfile +++ b/dockerfile @@ -1,29 +1,15 @@ -FROM --platform=linux/arm64 pacodrokad/fonts:latest AS fonts-image - FROM python:3.9-slim AS compile-image -# get fonts from the specified platform image -COPY --from=fonts-image /fonts /fonts - # Add git for hooks RUN apt-get update && apt-get install -y --no-install-recommends python3-icu git -# get pip tools for computing requirements, and compile them -RUN python -m pip install pip-tools - # Set the working directory in the container (creating it in the process) WORKDIR /app -# compile our requirements and then install them -COPY requirements.in . -RUN pip-compile --no-emit-index-url requirements.in && \ - pip install -r requirements.txt - # Copy the local directory contents into the container at /app COPY . . # install the application -RUN python setup.py develop +RUN pip install . && rm -rf ~/.cache/pip ENTRYPOINT ["/usr/local/bin/dominion_dividers"] -CMD ["--help"] diff --git a/dodo.py b/dodo.py index b37d3263..bf2052ba 100644 --- a/dodo.py +++ b/dodo.py @@ -12,13 +12,9 @@ def glob_no_dirs(spec): def task_compile_requirements(): return { - "file_dep": ["requirements.in"], + "file_dep": ["pyproject.toml"], "actions": [ - "pip-compile -U --no-emit-index-url --resolver=backtracking requirements.in", - # pip-compile will add macfsevents on mac, which breaks installation - # on other platforms, so hack in the 'doit' requirement after the - # compile - 'echo "doit # hacked in via doit\n" >> requirements.txt', + "pip-compile -U --no-emit-index-url --resolver=backtracking pyproject.toml", ], "targets": ["requirements.txt"], } diff --git a/pyproject.toml b/pyproject.toml index 43aec4a9..8199dc6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ description = "Divider Generation for the Dominion Card Game" keywords = ["boardgame", "cardgame", "dividers"] authors = [{ name = "Peter Gorniak", email = "sumpfork@mailmight.net" }] readme = "README.md" +requires-python = ">= 3.8" [project.urls] "Say Thanks" = "https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers" diff --git a/requirements.in b/requirements.in deleted file mode 100644 index 1ac3ce08..00000000 --- a/requirements.in +++ /dev/null @@ -1,8 +0,0 @@ -reportlab -Pillow -pre-commit -pytest -# cloudpickle is needed by doit which cannot be in this list as it -# installs platform-specific packages -cloudpickle -configargparse diff --git a/requirements.txt b/requirements.txt index d8d54c8a..a2b2470c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,51 +2,15 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --no-emit-index-url requirements.in +# pip-compile --no-emit-index-url pyproject.toml # -cfgv==3.4.0 - # via pre-commit chardet==5.2.0 # via reportlab -cloudpickle==3.0.0 - # via -r requirements.in configargparse==1.7 - # via -r requirements.in -distlib==0.3.8 - # via virtualenv -exceptiongroup==1.2.0 - # via pytest -filelock==3.13.1 - # via virtualenv -identify==2.5.34 - # via pre-commit -iniconfig==2.0.0 - # via pytest -nodeenv==1.8.0 - # via pre-commit -packaging==23.2 - # via pytest + # via domdiv (pyproject.toml) pillow==10.2.0 # via - # -r requirements.in + # domdiv (pyproject.toml) # reportlab -platformdirs==4.2.0 - # via virtualenv -pluggy==1.4.0 - # via pytest -pre-commit==3.6.1 - # via -r requirements.in -pytest==8.0.0 - # via -r requirements.in -pyyaml==6.0.1 - # via pre-commit reportlab==4.1.0 - # via -r requirements.in -tomli==2.0.1 - # via pytest -virtualenv==20.25.0 - # via pre-commit - -# The following packages are considered to be unsafe in a requirements file: -# setuptools -doit # hacked in via doit + # via domdiv (pyproject.toml)