Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
Start adding support for multiple Python versions
Browse files Browse the repository at this point in the history
Twiddle Python setup to use a virtualenv, and to accept an argument to
select which Python version to use. Split Python setup to a separate
provisioning step so that the other bits can live in a shared image.

This seems to be close to "good enough" to make Drake actually build,
mostly by virtue of shoving a bunch of symlinks to the appropriate
Python version stuff straight into /usr.
  • Loading branch information
mwoehlke-kitware committed Sep 2, 2021
1 parent 51f5efe commit 320ed03
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
ARG PLATFORM=ubuntu:18.04

# -----------------------------------------------------------------------------
# Create a base provisioned image
# -----------------------------------------------------------------------------

FROM ubuntu:18.04 AS base
FROM ${PLATFORM} AS base

ADD image/provision.sh /image/
ARG PYTHON=3

ENV DEBIAN_FRONTEND=noninteractive
RUN /image/provision.sh

ADD image/provision-base.sh /image/

RUN /image/provision-base.sh

ADD image/provision-python.sh /image/

RUN /image/provision-python.sh ${PYTHON}

# -----------------------------------------------------------------------------
# Build Drake's dependencies
Expand Down
10 changes: 0 additions & 10 deletions image/provision.sh → image/provision-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
BAZEL_VERSION=4.1.0
BAZEL_ROOT=https://github.com/bazelbuild/bazel/releases/download

ln -s /usr/bin/python3 /usr/bin/python

# Install prerequisites
apt-get -y update

apt-get -y install --no-install-recommends \
autoconf automake default-jdk \
python3-dev libpython3-dev python3-pip \
gcc g++ gfortran libgfortran-7-dev \
libclang-9-dev clang-format-9 \
git cmake ninja-build pkg-config \
Expand All @@ -21,13 +18,6 @@ apt-get -y install --no-install-recommends \
libgl1-mesa-dev libxt-dev \
opencl-headers ocl-icd-opencl-dev

pip3 install \
pyyaml \
semantic-version \
setuptools \
wheel \
auditwheel

# Install bazel
cd /tmp
wget ${BAZEL_ROOT}/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
Expand Down
21 changes: 21 additions & 0 deletions image/provision-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

PYTHON=python${1:-3}

# Set up Python environment and install Python prerequisites
apt-get -y install --no-install-recommends \
${PYTHON}-dev lib${PYTHON}-dev ${PYTHON}-venv

${PYTHON} -m venv /usr/local

pip install \
pyyaml \
semantic-version \
setuptools \
wheel \
auditwheel

ln -s /usr/bin/${PYTHON}-config /usr/bin/python3-config
ln -s /usr/bin/${PYTHON}-config /usr/local/bin/python-config
ln -s /usr/local/bin/python /usr/bin/python
ln -s /usr/include/${PYTHON}m /usr/local/include/

0 comments on commit 320ed03

Please sign in to comment.