Browse Source

Further Python 3 fixes and clean-up (#8273)

Anton Kirilov 2 years ago
parent
commit
f2c574a78c
4 changed files with 32 additions and 38 deletions
  1. 24 24
      Dockerfile
  2. 5 4
      entrypoint.sh
  3. 0 7
      package.json
  4. 3 3
      toolset/utils/output_helper.py

+ 24 - 24
Dockerfile

@@ -1,53 +1,53 @@
 FROM ubuntu:22.04
 FROM ubuntu:22.04
 
 
-ARG USER_ID
-ARG GROUP_ID
 ARG DEBIAN_FRONTEND=noninteractive
 ARG DEBIAN_FRONTEND=noninteractive
-
-#RUN add-apt-repository universe
 # WARNING: DON'T PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK
 # WARNING: DON'T PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK
 # One -q produces output suitable for logging (mostly hides
 # One -q produces output suitable for logging (mostly hides
 # progress indicators)
 # progress indicators)
-RUN apt-get -yqq update && apt-get -yqq install \
-      -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
+RUN apt-get -yqq update && \
+    apt-get -yqq install \
+      -o Dpkg::Options::="--force-confdef" \
+      -o Dpkg::Options::="--force-confold" \
       cloc \
       cloc \
       curl \
       curl \
-      dstat                       `# Collect resource usage statistics` \
+      # Collect resource usage statistics
+      dstat \
       gcc \
       gcc \
       git-core \
       git-core \
       gosu \
       gosu \
-      default-libmysqlclient-dev  `# Needed for mysqlclient` \
-      build-essential             `# Needed for mysqlclient` \
+      # Needed for mysqlclient
+      libmysqlclient-dev \
       libpq-dev \
       libpq-dev \
+      pkg-config \
       python3 \
       python3 \
       python3-dev \
       python3-dev \
       python3-pip \
       python3-pip \
       siege \
       siege \
       software-properties-common
       software-properties-common
 
 
-RUN curl https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h --output /usr/include/mysql/my_config.h
-
-RUN pip install \
+RUN pip3 install \
       colorama==0.3.1 \
       colorama==0.3.1 \
       docker==4.0.2 \
       docker==4.0.2 \
       mysqlclient \
       mysqlclient \
       psutil \
       psutil \
       psycopg2-binary \
       psycopg2-binary \
-      pymongo
+      pymongo==3.13.0 \
+      # urllib3 incompatibility:
+      # https://github.com/docker/docker-py/issues/3113#issuecomment-1525500104
+      requests==2.28.1
 
 
-ENV FWROOT=/FrameworkBenchmarks PYTHONPATH=/FrameworkBenchmarks
-
-# Check if Group is already created
-RUN if ! getent group $GROUP_ID; then \
-      addgroup --gid $GROUP_ID user; \
+# Check if the group ID is already created
+ARG GROUP_ID
+RUN if ! getent group "$GROUP_ID"; then \
+      addgroup --gid "$GROUP_ID" user; \
     fi
     fi
 
 
-# Drop permissions of user to match those of the host system
-# Check if the User ID is already created
-RUN if ! getent passwd $USER_ID; then \
-      adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user; \
+# Check if the user ID is already created
+ARG USER_ID
+RUN if ! getent passwd "$USER_ID"; then \
+      adduser --disabled-password --gecos '' --gid "$GROUP_ID" --uid "$USER_ID" user; \
     fi
     fi
 
 
-ENV USER_ID=$USER_ID
+ENV FWROOT=/FrameworkBenchmarks PYTHONPATH=/FrameworkBenchmarks USER_ID="$USER_ID"
 
 
-ENTRYPOINT ["/bin/bash", "FrameworkBenchmarks/entrypoint.sh" ]
+ENTRYPOINT ["FrameworkBenchmarks/entrypoint.sh"]

+ 5 - 4
entrypoint.sh

@@ -1,6 +1,7 @@
-#!/usr/bin/env bash
-set -euox pipefail
+#!/bin/bash
 
 
-chown -R $USER_ID /var/run/
+set -eoux pipefail
 
 
-gosu $USER_ID python3 /FrameworkBenchmarks/toolset/run-tests.py "$@"
+chown -R "$USER_ID" /var/run
+# Drop permissions of user to match those of the host system
+gosu "$USER_ID" python3 /FrameworkBenchmarks/toolset/run-tests.py "$@"

+ 0 - 7
package.json

@@ -1,7 +0,0 @@
-{
-  "dependencies": {
-    "hbs": "^4.0.4",
-    "pg": "^8.6.0",
-    "pg-native": "^3.0.0"
-  }
-}

+ 3 - 3
toolset/utils/output_helper.py

@@ -19,7 +19,7 @@ TOO_MANY_BYTES = 50 * 1024 * 1024
 def log(log_text=None, **kwargs):
 def log(log_text=None, **kwargs):
     '''
     '''
     Logs the given text and optional prefix to stdout (if quiet is False) and
     Logs the given text and optional prefix to stdout (if quiet is False) and
-    to an optional log file. By default, we strip out newlines in order to 
+    to an optional log file. By default, we strip out newlines in order to
     print our lines correctly, but you can override this functionality if you
     print our lines correctly, but you can override this functionality if you
     want to print multi-line output.
     want to print multi-line output.
     '''
     '''
@@ -43,7 +43,7 @@ def log(log_text=None, **kwargs):
     try:
     try:
         new_log_text = border or ''
         new_log_text = border or ''
         for line in log_text.splitlines():
         for line in log_text.splitlines():
-            if line.strip() is not '':
+            if line.strip() != '':
                 if prefix:
                 if prefix:
                     new_log_text += Style.DIM + prefix + Style.RESET_ALL
                     new_log_text += Style.DIM + prefix + Style.RESET_ALL
                 new_log_text += color + line + color_reset + os.linesep
                 new_log_text += color + line + color_reset + os.linesep
@@ -63,7 +63,7 @@ def log(log_text=None, **kwargs):
 
 
 class QuietOutputStream:
 class QuietOutputStream:
     '''
     '''
-    Provides an output stream which either writes to stdout or nothing 
+    Provides an output stream which either writes to stdout or nothing
     depending on the is_quiet param.
     depending on the is_quiet param.
     '''
     '''