Skip to content

Commit

Permalink
Pin virtualenv 16.7.9 to fix Python bin installation. (#399)
Browse files Browse the repository at this point in the history
* Pin virtualenv 16.7.9 to fix Python bin installation.

virtualenv>=20 and venv both set sys.base_prefix to a value outside the
virtual environment whereas virtualenv 16.7.9 does not. This triggers
virtualenv detection in setuptools/distutils[1] which causes them to
ignore our configured install-scripts options.

Since this issue is causing test failures and issues with our
distributed binary archives, I think it's worth pinning a version of
virtualenv that meets our needs while we explore alternatives.

[1]: https://github.com/pypa/setuptools/blob/a5dec2f14e3414e4ee5dd146bff9c289d573de9a/setuptools/dist.py#L573-L579

Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* C'mon colon.

Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>
  • Loading branch information
nuclearsandwich committed Mar 4, 2020
1 parent b247ffc commit bd47ae1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions linux_docker_resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs`
RUN curl --silent http://packages.osrfoundation.org/gazebo.key | apt-key add -

# Install some development tools.
RUN apt-get update && apt-get install --no-install-recommends -y build-essential ccache cmake pkg-config python3-empy python3-setuptools python3-vcstool python3-venv
RUN apt-get update && apt-get install --no-install-recommends -y build-essential ccache cmake pkg-config python3-empy python3-setuptools python3-vcstool
RUN apt-get update && apt-get install --no-install-recommends -y python3-lark-parser python3-opencv

# Install build and test dependencies of ROS 2 packages.
Expand Down Expand Up @@ -65,7 +65,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \

# Install and self update pip/setuptools to the latest version.
RUN apt-get update && apt-get install --no-install-recommends -y python3-pip
RUN pip3 install -U setuptools pip
RUN pip3 install -U setuptools pip virtualenv==16.7.9

# Install clang if build arg is true
RUN if test ${COMPILE_WITH_CLANG} = true; then apt-get update && apt-get install --no-install-recommends -y clang libc++-dev libc++abi-dev; fi
Expand Down
1 change: 1 addition & 0 deletions linux_docker_resources/Dockerfile-CentOS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN yum install \
python36-pytest-repeat \
python36-snowballstemmer \
python36-vcstool \
python36-virtualenv \
python-rosdep \
sudo \
systemd \
Expand Down
10 changes: 8 additions & 2 deletions ros2_batch_job/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,17 @@ def run(args, build_function, blacklisted_package_names=None):
if args.do_venv:
print('# BEGIN SUBSECTION: enter virtualenv')

if args.os != 'linux':
# Do not try this on Linux as elevated privileges are needed.
# The Linux host or Docker image will need to ensure the right
# version of virtualenv is available.
job.run([sys.executable, '-m', 'pip', 'install', '-U', 'virtualenv==16.7.9'])

venv_subfolder = 'venv'
remove_folder(venv_subfolder)
job.run([
sys.executable, '-m', 'venv', '--copies', '--system-site-packages',
venv_subfolder])
sys.executable, '-m', 'virtualenv', '--system-site-packages',
'-p', sys.executable, venv_subfolder])
venv_path = os.path.abspath(os.path.join(os.getcwd(), venv_subfolder))
venv, venv_python = generated_venv_vars(venv_path)
job.push_run(venv) # job.run is now venv
Expand Down

0 comments on commit bd47ae1

Please sign in to comment.