diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cebc69c..58fc832 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "image": "docker.io/kostrykin/mobi-devcontainer-python:2023.1", + "image": "docker.io/kostrykin/mobi-devcontainer-python:test_pylab", "customizations": { "codespaces": { "openFiles": [] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/README.md b/README.md index 61bb86c..96f11d8 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This repository builds a Docker image for [Molecular Biotechnology Python Lesson - Python 3.9 and 3.11 (3.11 selected as default Jupyter kernel) - VS Code with `ms-toolsai.jupyter` extension - Packages specified in `ingredients/requirements.txt` installed for Python 3.11 +- Substitute for `%pylab` which imports `numpy` and `matplotlib.pyplot` into the global namespace and omits the deprection warning produced by the original `%pylab` instruction Dotfiles `**/.*` and Markdown files `**/*.md` are hidden in the VS Code file manager. Pylance is disabled. diff --git a/ingredients/.devcontainer.json b/ingredients/.devcontainer.json index e58201a..1b029cc 100644 --- a/ingredients/.devcontainer.json +++ b/ingredients/.devcontainer.json @@ -23,8 +23,8 @@ "**/.*": true, "**/*.md": true }, - "python.linting.enabled": false, - "python.linting.pylintEnabled": false + // Disable all help for linters etc. + "python.languageServer": "None" } } } diff --git a/ingredients/Dockerfile b/ingredients/Dockerfile index b96f7fd..7904e34 100644 --- a/ingredients/Dockerfile +++ b/ingredients/Dockerfile @@ -3,3 +3,7 @@ FROM mcr.microsoft.com/devcontainers/python:3.11-bullseye COPY requirements.txt /tmp/pip-tmp/ RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt RUN rm -rf /tmp/pip-tmp + +WORKDIR /home/vscode/.ipython/profile_default/startup +ADD substitute_pylab.ipy . +RUN chown -R vscode:vscode /home/vscode/.ipython diff --git a/ingredients/substitute_pylab.ipy b/ingredients/substitute_pylab.ipy new file mode 100644 index 0000000..1cd7c39 --- /dev/null +++ b/ingredients/substitute_pylab.ipy @@ -0,0 +1,11 @@ +if __name__ == '__main__': + from IPython.core import magic + + @magic.register_line_magic + def pylab(*args): + import numpy as np + import matplotlib.pyplot as plt + globals().update(np.__dict__) + globals().update(plt.__dict__) + + del pylab