Skip to content
Open
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: 3.9
- name: Play singleplayer
run: |
python setup.py install
pip install .
pythonium run players pythonium.bots.standard_player
play-multiplayer:
runs-on: ubuntu-latest
Expand All @@ -33,7 +33,7 @@ jobs:
python-version: 3.9
- name: Play multiplayer
run: |
python setup.py install
pip install .
pythonium run players pythonium.bots.standard_player pythonium.bots.pacific_player
tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -90,5 +90,3 @@ jobs:
python -m pip install --upgrade pip
pip install isort
- uses: jamescurtin/isort-action@master
with:
requirementsFiles: "requirements.txt"
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ repos:
rev: 9042488762e10137fd535601d9f433f1e3920dad
hooks:
- id: isort
- repo: https://github.com/commitizen-tools/commitizen
rev: master
hooks:
- id: commitizen
stages: [commit-msg]
78 changes: 72 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,76 @@
FROM python:3.9-slim
# `python-base` sets up all our shared environment variables
FROM python:3.9 as python-base

WORKDIR /usr/src
# python
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.1.12 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# make poetry create the virtual environment in the project's root
# it gets named `.venv`
POETRY_VIRTUALENVS_IN_PROJECT=true \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
# paths
# this is where our requirements + virtual environment will live
PYTHONIUM_PATH="/opt/pythonium"

ENV PYTHONUNBUFFERED 1
# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$PATH"

# `builder-base` stage is used to build deps + create our virtual environment
FROM python-base as builder-base

RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

# copy project requirement files here to ensure they will be cached.
WORKDIR $PYTHONIUM_PATH

COPY poetry.lock pyproject.toml ./

# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry export --without-hashes | pip install -r /dev/stdin

RUN pip install --upgrade pip
COPY . .
RUN python setup.py install
WORKDIR /usr/src/games


# `development` image is used during development / testing
FROM builder-base as development

WORKDIR $PYTHONIUM_PATH

# copy in our built poetry + venv
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYTHONIUM_PATH $PYTHONIUM_PATH

# quicker install as runtime deps are already installed
RUN poetry export --without-hashes --dev | pip install -r /dev/stdin

RUN pip install --no-dependencies --editable .


# FROM builder-base as docs
#
# WORKDIR $PYTHONIUM_PATH
#
# RUN poetry export --without-hashes --extras docs | pip install -r /dev/stdin


# `production` image used for runtime
FROM builder-base as production

WORKDIR $PYTHONIUM_PATH

RUN pip install --no-dependencies .

CMD ["pythonium"]
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

29 changes: 11 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
COMPOSE = docker compose -f docker-compose.yml
DEV_COMPOSE = $(COMPOSE) -f docker-compose.develop.yml
ARGS = $(filter-out $@,$(MAKECMDGOALS))

help:
@echo "play -- Open shell to play"
@echo "test -- Run tests"
@echo "devshell -- Open shell with development dependencies"


play:
$(COMPOSE) run --rm pserver /bin/bash
docker build --progress plain --target production --tag pythonium:latest .; \
docker run --rm -ti pythonium pythonium

devshell:
$(DEV_COMPOSE) run --rm pserver /bin/bash
docker build --progress plain --target development --tag pythonium:development .; \
docker run --rm -ti -v $(pwd):/opt/pythonium pythonium:development bash

test:
$(DEV_COMPOSE) run --rm pserver pytest $(ARGS)

check-imports:
$(DEV_COMPOSE) run --rm pserver isort **/*.py

check-style:
$(DEV_COMPOSE) run --rm pserver black **/*.py
docker build --progress plain --target development --tag pythonium:development .; \
docker run --rm -ti pythonium:development pytest

build:
$(COMPOSE) build
clean:
docker rmi pythonium:latest; \
docker rmi pythonium:development;

build-dev:
$(DEV_COMPOSE) build

.PHONY: help play test devshell
.PHONY: help clean play test devshell
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ The game generates several outputs that will help you to evaluate the performanc

If you want to know more and learn how to play, check out the [documentation](https://pythonium.readthedocs.io/en/latest/).

## Contributing

### Clone the repo

`$ git clone https://github.com/Bgeninatti/pythonium.git`

### Install dependencies

#### Using Poetry

Create virtualenv and install dependencies

`$ poetry install`

Open poetry shell

`$ poetry shell`

#### Using virtualenv (using latest pip version)

`python -m venv venv`
`source venv/bin/activate`
`pip install -e .`

### Running tests

`$ make tests`

### Building docs locally

`$ poetry install --extras docs`
`cd docs/`
`make html`

## Acknowledge

This game is strongly inspired by [VGA Planets](https://en.wikipedia.org/wiki/VGA_Planets), a space strategy war game from 1992 created by Tim Wisseman.
Expand Down
7 changes: 0 additions & 7 deletions docker-compose.develop.yml

This file was deleted.

9 changes: 0 additions & 9 deletions docker-compose.yml

This file was deleted.

Binary file removed font/jmh_typewriter.ttf
Binary file not shown.
Loading