Use importlib_resources in Python 3.6 images.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Tue, 16 Jun 2020 10:48:26 +0000 (13:48 +0300)
committerJoe Jordan <ejjordan12@gmail.com>
Mon, 3 Aug 2020 03:11:30 +0000 (03:11 +0000)
Python 3.7 adds importlib.resources to the standard library, which
provides an efficient built in alternative to pkg_resources.
Backported functionality is available in the importlib_resources
package. We should add it to our Docker images to allow testing new
features while we still officially support Python 3.6.

See also issue #2961

admin/containers/scripted_gmx_docker_builds.py

index 4aa57d5176fe2b643e206e535702a4e26de64bc8..cf5416460412b0e009f36e91343aa8413c1a34d0 100644 (file)
@@ -300,7 +300,7 @@ def add_tsan_stage(input_args, output_stages: typing.Mapping[str, hpccm.Stage]):
 def prepare_venv(version: StrictVersion) -> typing.Sequence[str]:
     """Get shell commands to set up the venv for the requested Python version."""
     major = version.version[0]
-    minor = version.version[1]
+    minor = version.version[1]  # type: int
 
     pyenv = '$HOME/.pyenv/bin/pyenv'
 
@@ -329,6 +329,11 @@ def prepare_venv(version: StrictVersion) -> typing.Sequence[str]:
             'setuptools>=42' \
             'scikit-build>=0.10'""".format(path=venv_path))
 
+    # TODO: Remove 'importlib_resources' dependency when Python >=3.7 is required.
+    if minor == 6:
+        commands.append("""{path}/bin/python -m pip install --upgrade \
+                'importlib_resources'""".format(path=venv_path))
+
     return commands