From bdfc82183f6ac103d5833e453426df54029ec9ab Mon Sep 17 00:00:00 2001 From: Bert Besser Date: Sun, 21 Feb 2021 14:54:12 +0100 Subject: [PATCH 1/3] feat: containerized dev env --- CONTRIBUTING.md | 2 ++ dev/.gitignore | 1 + dev/Dockerfile | 5 +++++ dev/README.md | 20 ++++++++++++++++++++ dev/docker-compose.yml | 15 +++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 dev/.gitignore create mode 100644 dev/Dockerfile create mode 100644 dev/README.md create mode 100644 dev/docker-compose.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c01bcff54..5ffc01565 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,6 +73,8 @@ python -X tracemalloc -m unittest -f src/test/test_* python -X tracemalloc -m unittest -f src/test/test_runner.py ``` +To run tests in a dedicated container, see `dev/README.md`. + ## Codestyle Popper's code is formatted using the [black](https://github.com/psf/black) style. If code does not conform to this style, merges are prevented to the master and this is checked as a CI step. diff --git a/dev/.gitignore b/dev/.gitignore new file mode 100644 index 000000000..5ceb3864c --- /dev/null +++ b/dev/.gitignore @@ -0,0 +1 @@ +venv diff --git a/dev/Dockerfile b/dev/Dockerfile new file mode 100644 index 000000000..c7f975326 --- /dev/null +++ b/dev/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.8-buster + +RUN pip install --upgrade pip +RUN pip install setuptools setuptools_rust virtualenv + diff --git a/dev/README.md b/dev/README.md new file mode 100644 index 000000000..c6582620c --- /dev/null +++ b/dev/README.md @@ -0,0 +1,20 @@ +# Development environment + +The following steps should be executed from within the folder `dev`. + +To test popper, build the `popper-dev` image and prepare the folder to hold the venv +``` +docker-compose build popper-dev +mkdir venv +``` +then start the container and install deps into the venv +``` +docker-compose run --rm popper-dev +# now you're insided the container +python -m virtualenv /venv +source /venv/bin/activate +pip install -e src/ +``` +From here on, you can always return to the container without having to re-install the venv. +However, don't forget to activate the venv after entering the container. +(The container is temporary and will be removed after you leave, so activate the venv each time.) diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml new file mode 100644 index 000000000..adbf74dd5 --- /dev/null +++ b/dev/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.7' +services: + popper-dev: + image: popper-dev + container_name: popper-dev + stdin_open: true # docker run -i + tty: true # docker run -t + build: + context: . + command: + - bash + volumes: + - ${PWD}/..:/workspace + - ${PWD}/venv:/venv + working_dir: /workspace From 18c8e2899ba6e2f73faa066ea8f6f1ea548e5ced Mon Sep 17 00:00:00 2001 From: Bert Besser Date: Sun, 21 Feb 2021 15:03:14 +0100 Subject: [PATCH 2/3] fix: refer to new doc from installation.md --- docs/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 4331bb933..2b7804026 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -137,5 +137,7 @@ the above approach you have both (1) popper installed in your machine and (2) an environment where you can modify popper and test the results of such modifications. +To create a containerized development environment, e.g. for running tests, see `dev/README.md`. + [venv]: https://virtualenv.pypa.io/en/latest/ [venv-install]: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv From c3c47ec702128af2c3d1895c305ab3f950b499ce Mon Sep 17 00:00:00 2001 From: Bert Besser Date: Sun, 21 Feb 2021 16:24:09 +0100 Subject: [PATCH 3/3] feat: add black --- dev/Dockerfile | 3 ++- pyproject.toml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/dev/Dockerfile b/dev/Dockerfile index c7f975326..980a157df 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -1,5 +1,6 @@ FROM python:3.8-buster RUN pip install --upgrade pip -RUN pip install setuptools setuptools_rust virtualenv +# black==19.10b0 is the version used in GitHub +RUN pip install setuptools setuptools_rust virtualenv black==19.10b0 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..afe2f17d9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.black] +exclude=''' +/dev +'''