aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2021-01-09 17:00:31 -0800
committerGravatar MarkKoz <[email protected]>2021-01-09 17:11:04 -0800
commit7446cea604fc9dd78399eefdb7ced3160bc75fef (patch)
tree0e1d9b94f126000d90d12075f0f8a64b4713b9f6
parentSwap out configMap for a hostPath for psuedo-persistence (diff)
Document how to install additional packages
-rw-r--r--README.md23
1 files changed, 22 insertions, 1 deletions
diff --git a/README.md b/README.md
index 187d029..af63615 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,27 @@ docker run --ipc=none --privileged -p 8060:8060 ghcr.io/python-discord/snekbox
To run it in the background, use the `-d` option. See the documentation on [`docker run`] for more information.
-The above command will make the API accessible on the host via `http://localhost:8060/`. Currently there's only one endpoint: `http://localhost:8060/eval`.
+The above command will make the API accessible on the host via `http://localhost:8060/`. Currently, there's only one endpoint: `http://localhost:8060/eval`.
+
+## Third-party Packages
+
+By default, the Python interpreter has no access to any packages besides the
+standard library. Even snekbox's own dependencies like Falcon and Gunicorn are
+not exposed.
+
+To expose third-party Python packages during evaluation, install them to the user site:
+
+```sh
+docker exec snekbox /bin/sh -c 'pip install --ignore-installed --user numpy'
+```
+
+In the above command, `snekbox` is the name of the running container. The name may be different and can be checked with `docker ps`.
+
+It's important to use `--user` to install them to the user site, whose base is located at `/snekbox/user_base` within the Docker container. To persist the installed packages, a volume for the directory can be created with Docker. For an example, see [`docker-compose.yml`].
+
+`--ignore-installed` is only necessary if installing a package that happens to
+be a dependency of snekbox. Normally, pip would reject the installation because
+it doesn't make a distinction here between the global and user sites.
## Development Environment
@@ -148,6 +168,7 @@ The alias can be found in `./scripts/.profile`, which is automatically added whe
[`snekbox.cfg`]: config/snekbox.cfg
[`snekapi.py`]: snekbox/api/snekapi.py
[`resources`]: snekbox/api/resources
+[`docker-compose.yml`]: docker-compose.yml
[`docker run`]: https://docs.docker.com/engine/reference/commandline/run/
[nsjail]: https://github.com/google/nsjail
[falcon]: https://falconframework.org/