From d617e0b22c3f9f127add90d0cd007964903dd1b4 Mon Sep 17 00:00:00 2001
From: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date: Mon, 30 Jan 2023 13:59:14 +0100
Subject: [PATCH] Run the app manager using the dockerized python

When using #!/usr/bin/python3, we end up using Debian's system-wide
python rather than the copy shipped in the docker container. This
pollutes the generated virtualenv with the wheels generated by Debian
packaging, rather than the expected upstream wheels.
---
 scripts/Dockerfile       | 8 ++++----
 scripts/app_manager.py   | 2 +-
 scripts/requirements.txt | 3 +++
 3 files changed, 8 insertions(+), 5 deletions(-)
 create mode 100644 scripts/requirements.txt

diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 963e70728..a14940156 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -14,17 +14,17 @@ RUN apt-get -y update && \
       libsvn-dev libapr1-dev libaprutil1-dev \
       libpython3-dev \
       libpq-dev \
-      python3-click \
-      python3-venv \
-      python3-yaml \
-      python3-dulwich \
     && \
     apt clean
 
 RUN mkdir -p /opt/scripts/
 COPY app_manager.py /opt/scripts/
+COPY requirements.txt /opt/scripts/
 RUN chmod +x /opt/scripts/app_manager.py
 
+RUN pip install -U pip setuptools wheel && \
+    pip install -r /opt/scripts/requirements.txt
+
 # This expects the /src/ to be mounted on swh-apps repository folder at runtime
 ENV SWH_APPS_DIR=/src/apps
 
diff --git a/scripts/app_manager.py b/scripts/app_manager.py
index e69d7869e..87fb949ee 100755
--- a/scripts/app_manager.py
+++ b/scripts/app_manager.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 # Copyright (C) 2022-2023  The Software Heritage developers
 # See the AUTHORS file at the top-level directory of this distribution
diff --git a/scripts/requirements.txt b/scripts/requirements.txt
new file mode 100644
index 000000000..cd6c69e61
--- /dev/null
+++ b/scripts/requirements.txt
@@ -0,0 +1,3 @@
+click
+dulwich
+PyYAML
-- 
GitLab