diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c068257 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 +ARG VARIANT="3" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +COPY requirements.txt /tmp/pip-tmp/ +RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ + && rm -rf /tmp/pip-tmp diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b59f562 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,34 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/python-3 +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python" + ], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pip3 install -r requirements.txt && python3 setup.py develop" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 33b193d..0e65253 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,13 @@ fixes, etc. # Developing +In order to develop locally, there are two options: + +- Develop using a local installation of Python 3 and setting up a virtual environment +- Develop using an automated VSCode Dev Container. + +## Develop using local Python installation + [Create and activate a Python 3 virtual environment.](https://docs.python.org/3/tutorial/venv.html) Install `The Fuck` for development: @@ -59,3 +66,27 @@ For sending package to pypi: sudo apt-get install pandoc ./release.py ``` + +## Develop using Dev Container + +To make local development easier a [VSCode Devcontainer](https://code.visualstudio.com/docs/remote/remote-overview) is included with this repository. This will allows you to spin up a Docker container with all the necessary prerequisites for this project pre-installed ready to go, no local Python install/setup required. + +### Prerequisites + +To use the container you require: +- [Docker](https://www.docker.com/products/docker-desktop) +- [VSCode](https://code.visualstudio.com/) +- [VSCode Remote Development Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) +- [Windows Users Only]: [Installation of WSL2 and configuration of Docker to use it](https://docs.docker.com/docker-for-windows/wsl/) + +Full notes about [installation are here](https://code.visualstudio.com/docs/remote/containers#_installation) + +### Running the container + +Assuming you have the prerequisites: + +1. Open VSCode +1. Open command palette (CMD+SHIFT+P (mac) or CTRL+SHIFT+P (windows)) +1. Select `Remote-Containers: Reopen in Container`. +1. Container will be built, install all pip requirements and your VSCode will mount into it automagically. +1. Your VSCode and container now essentially become a throw away environment. \ No newline at end of file