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
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'
'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