tools: make matplotlib work inside the dev docker

- use special DNS from docker
- install tkinter
- use proper matplotlib backend
- add instructions to install xserver in docs/dev/GETTING-STARTED.md
This commit is contained in:
Arthur Meyre
2021-08-27 15:03:19 +02:00
parent 802f7943b1
commit 135805a1b9
4 changed files with 37 additions and 3 deletions

View File

@@ -117,7 +117,11 @@ docker_rebuild:
docker_start:
@# the slash before pwd is for Windows
docker run --rm -it -p 8888:8888 --volume /"$$(pwd)":/hdk $(DEV_DOCKER_IMG)
docker run --rm -it \
-p 8888:8888 \
--env DISPLAY=host.docker.internal:0 \
--volume /"$$(pwd)":/hdk \
$(DEV_DOCKER_IMG)
.PHONY: docker_start
docker_build_and_start: docker_build docker_start

View File

@@ -6,7 +6,8 @@ RUN echo "source /hdk/.docker_venv/bin/activate" >> /root/.bashrc && \
echo " source /hdk/.docker_venv/bin/activate" >> /root/.bashrc && \
echo " cd /hdk/ && make setup_env" >> /root/.bashrc && \
echo "fi" >> /root/.bashrc && \
echo "export LD_PRELOAD=/compiler/build/lib/Runtime/libZamalangRuntime.so" >> /root/.bashrc
echo "export LD_PRELOAD=/compiler/build/lib/Runtime/libZamalangRuntime.so" >> /root/.bashrc && \
echo "export MPLBACKEND=TkAgg" >> /root/.bashrc
WORKDIR /hdk

View File

@@ -2,6 +2,7 @@ FROM ghcr.io/zama-ai/zamalang-compiler
RUN apt-get install --no-install-recommends -y \
python3.8 \
python3.8-tk \
python3.8-venv \
python-is-python3 \
git \

View File

@@ -110,9 +110,37 @@ In this section, we will discuss the module structure of hdk briefly. You are en
## Working in Docker
### Setting up docker and X forwarding
Before you start this section, go ahead and install docker. You can follow [this](https://docs.docker.com/engine/install/) official guide for that.
Docker image of `hdk` is based of another docker image provided by the compiler team. The process of building on top of that image is automated, but it requires authorization. So to work in docker, talk with your team lead to gain access to the base docker image. You need to be added to a special group in the organization called `homomorphizer-ghcr`.
#### Linux
```console
xhost +localhost
```
#### Mac OS
To be able to use X forwarding on Mac OS: first, you need to install xquartz. Secondly, open XQuartz.app application, and open a new terminal within XQuartz.app. Make sure in the application parameters to authorize network connections are set (currently in the Security settings); finally, in the XQuartz.app terminal, type
```console
xhost +127.0.0.1
```
and now, the X server should be all set in docker (in the regular terminal).
#### Windows
Install Xming and use Xlaunch:
- Multiple Windows, Display number: 0
- Start no client
- **IMPORTANT**: Check `No Access Control`
- You can save this configuration to re-launch easily, then click finish.
### Logging in and building the image
Docker image of `hdk` is based on another docker image provided by the compiler team. Once you have access to this repository you should be able to launch the commands to build the dev docker image with `make docker_build`.
Upon joining to the team, you need to log in using the following command: