Skip to content

Commit

Permalink
Cleanup requirements, docker file (#507)
Browse files Browse the repository at this point in the history
* Cleanup requirements and docker files
* do not default to --help in dockerfile
* need dev requirements for compiling card db
---------

Co-authored-by: Nick Vance <[email protected]>
  • Loading branch information
sumpfork and nickv2002 authored Apr 7, 2024
1 parent 7c164af commit 1ea1673
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 75 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.dockerignore
.dockerfile
README.md
requirements.txt
.github
tools
*pdf
1 change: 1 addition & 0 deletions .github/workflows/compile_card_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers> or file issues on github (<https://github.com/sumpfork/dominiontabs/issues>).

Expand All @@ -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`

<!--TODO update this doc to pull pre-built images from GitHub once those are set up-->

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`
Expand Down
114 changes: 114 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
16 changes: 1 addition & 15 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 2 additions & 6 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = "Divider Generation for the Dominion Card Game"
keywords = ["boardgame", "cardgame", "dividers"]
authors = [{ name = "Peter Gorniak", email = "[email protected]" }]
readme = "README.md"
requires-python = ">= 3.8"

[project.urls]
"Say Thanks" = "https://boardgamegeek.com/thread/926575/web-page-generate-tabbed-dividers"
Expand Down
8 changes: 0 additions & 8 deletions requirements.in

This file was deleted.

44 changes: 4 additions & 40 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 1ea1673

Please sign in to comment.