Skip to content
Snippets Groups Projects
Verified Commit c36c161b authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Make generate-frozen-requirements reproducible through container

This allows to build the container that will call the generate-frozen-requirements
script.

That will be usable from ci or other sysadm.

Use:
```
cd swh-apps/scripts
docker build -t build-deps .
cd ../../swh-apps
docker run -v $PWD:/src --user 1000 build-deps $APP
```
parent a54fdcf8
No related merge requests found
# build-deps container to call scripts/generate-frozen-requirements.txt on an
# application (e.g. swh-loader-svn, swh-loader-git, ...)
FROM python:3.10-bullseye
# First install the runtime deps of all swh applications
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install -y \
# objstorage deps (winery)
libcmph-dev \
# journal (kafka)
librdkafka-dev \
# svn loader (subvertpy)
libsvn-dev libapr1-dev libaprutil1-dev \
libpq-dev \
python3-venv \
&& \
apt clean
RUN mkdir -p /opt/scripts/
COPY common.py /opt/scripts/
COPY generate-frozen-requirements /opt/scripts/
RUN chmod +x /opt/scripts/generate-frozen-requirements
# This expects the /src/ to be mounted on swh-apps repository folder at runtime
ENV SWH_APPS_DIR=/src/apps
WORKDIR /opt/scripts
ENTRYPOINT [ "./generate-frozen-requirements" ]
......@@ -5,16 +5,15 @@
# License: GNU General Public License v3 or later
# See top-level LICENSE file for more information
"""Generate the requirements-frozen.txt file for a given app"""
"""Generate the requirements-frozen.txt file for given app(s)"""
import os
import pathlib
import subprocess
import sys
import tempfile
from venv import EnvBuilder
from common import APPS_DIR
class AppEnvBuilder(EnvBuilder):
"""A virtualenv builder specialized for our usecase"""
......@@ -49,11 +48,16 @@ def usage():
print(f"Usage: {sys.argv[0]} app1 ... appN", file=sys.stderr)
def generate_requirements_frozen(app):
def generate_requirements_frozen(app: str, absolute_apps_dirpath: pathlib.Path) -> None:
"""Generate the ``requirements-frozen.txt`` file out of the
``requirements.txt`` file present in the ``app`` directory"""
``requirements.txt`` file present in the ``app`` directory
Args:
app: Name of the application to generate the frozen dependencies set
apps_dir: Absolute folder holding all application declarations
"""
app_dir = APPS_DIR / app
app_dir = absolute_apps_dirpath / app
src_req_file = app_dir / "requirements.txt"
dst_req_file = app_dir / "requirements-frozen.txt"
......@@ -80,5 +84,13 @@ if __name__ == "__main__":
usage()
sys.exit(2)
apps_dir = os.environ.get("SWH_APPS_DIR")
if not apps_dir:
from common import APPS_DIR
absolute_apps_dirpath = APPS_DIR
else:
absolute_apps_dirpath = pathlib.Path(apps_dir)
for app in sys.argv[1:]:
generate_requirements_frozen(app)
generate_requirements_frozen(app, absolute_apps_dirpath)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment