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..980a157df --- /dev/null +++ b/dev/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.8-buster + +RUN pip install --upgrade pip +# black==19.10b0 is the version used in GitHub +RUN pip install setuptools setuptools_rust virtualenv black==19.10b0 + 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 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 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 +'''