Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Commit 96dda44

Browse files
authored
Dockerfiles Python 3 cleanup (#3601)
1 parent 35ec34b commit 96dda44

File tree

12 files changed

+24
-154
lines changed

12 files changed

+24
-154
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ addons:
1616
packages:
1717
- libtool-bin
1818
- libcppunit-dev
19-
- python3
2019
- pkg-config
2120
- python3-dev
22-
- python3-wheel
21+
- python3-venv
2322
- wget
2423
- zip
2524
- zlib1g-dev

WORKSPACE

-19
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ REQUESTS_SRC = "https://pypi.python.org/packages/d9/03/155b3e67fe35fe5b6f4227a8d
181181

182182
SETUPTOOLS_WHEEL = "https://pypi.python.org/packages/a0/df/635cdb901ee4a8a42ec68e480c49f85f4c59e8816effbf57d9e6ee8b3588/setuptools-46.1.3-py3-none-any.whl"
183183

184-
VIRTUALENV_SRC = "https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz"
185-
186-
VIRTUALENV_PREFIX = "virtualenv-15.1.0"
187-
188184
WHEEL_SRC = "https://pypi.python.org/packages/c9/1d/bd19e691fd4cfe908c76c429fe6e4436c9e83583c4414b54f6c85471954a/wheel-0.29.0.tar.gz"
189185

190186
http_file(
@@ -229,21 +225,6 @@ http_file(
229225
urls = [SETUPTOOLS_WHEEL],
230226
)
231227

232-
http_archive(
233-
name = "virtualenv",
234-
build_file_content = "\n".join([
235-
"load(\"@rules_python//python:defs.bzl\", \"py_binary\")",
236-
"py_binary(",
237-
" name = 'virtualenv',",
238-
" srcs = ['virtualenv.py'],",
239-
" data = glob(['**/*']),",
240-
" visibility = ['//visibility:public'],",
241-
")",
242-
]),
243-
sha256 = "02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a",
244-
strip_prefix = VIRTUALENV_PREFIX,
245-
urls = [VIRTUALENV_SRC],
246-
)
247228
# end pex repos
248229

249230
# protobuf dependencies for C++ and Java

bazel_configure.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import datetime
3838
import platform
3939
import subprocess
40+
import tempfile
4041

4142
sys.path.append('third_party/python/semver')
4243
import semver
@@ -293,6 +294,11 @@ def discover_jdk():
293294
print('Using %s:\t%s' % ('JDK'.ljust(20), jdk_path))
294295
return jdk_path
295296

297+
def test_venv():
298+
with tempfile.TemporaryDirectory() as tmpdirname:
299+
if subprocess.run(["python3", "-m", "venv", tmpdirname]).returncode != 0:
300+
fail("Python3 venv module is not installed.")
301+
296302
######################################################################
297303
# Discover the linker directory
298304
######################################################################
@@ -413,7 +419,8 @@ def main():
413419
env_map['AUTOMAKE'] = discover_tool('automake', 'Automake', 'AUTOMAKE', '1.9.6')
414420
env_map['AUTOCONF'] = discover_tool('autoconf', 'Autoconf', 'AUTOCONF', '2.6.3')
415421
env_map['MAKE'] = discover_tool('make', 'Make', 'MAKE', '3.81')
416-
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.4')
422+
env_map['PYTHON3'] = discover_tool('python3', 'Python3', 'PYTHON3', '3.6')
423+
test_venv()
417424

418425
if platform == 'Darwin':
419426
env_map['LIBTOOL'] = discover_tool('glibtool', 'Libtool', 'LIBTOOL', '2.4.2')

docker/compile/Dockerfile.centos7

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ RUN yum -y install \
3636
libtool \
3737
make \
3838
patch \
39-
python \
4039
python3-devel \
4140
zip \
4241
unzip \

docker/compile/Dockerfile.ubuntu14.04

-57
This file was deleted.

docker/compile/Dockerfile.ubuntu16.04

-60
This file was deleted.

docker/compile/Dockerfile.ubuntu18.04

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ RUN apt-get update && apt-get -y install \
2929
libunwind8 \
3030
libcppunit-dev \
3131
patch \
32-
python \
3332
python3-dev \
33+
python3-venv \
3434
pkg-config \
3535
wget \
3636
zip \
37-
virtualenv \
3837
unzip \
3938
git \
4039
curl \
4140
tree \
4241
openjdk-11-jdk-headless
4342

43+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
44+
4445
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
4546

4647
ENV bazelVersion 3.4.1

docker/compile/Dockerfile.ubuntu20.04

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ RUN apt-get update && apt-get -y install \
3131
libunwind8 \
3232
libcppunit-dev \
3333
patch \
34+
python-is-python3 \
3435
python3-dev \
35-
python \
36+
python3-venv \
3637
pkg-config \
3738
wget \
3839
zip \
39-
virtualenv \
4040
unzip \
4141
git \
4242
curl \

docker/test/Dockerfile.ubuntu18.04

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ RUN apt-get update && apt-get -y install \
2929
libcppunit-dev \
3030
patch \
3131
python3-dev \
32+
python3-venv \
3233
wget \
3334
zip \
34-
virtualenv \
3535
unzip \
3636
git \
3737
curl \
3838
tree \
3939
openjdk-11-jdk-headless
4040

41+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
42+
4143
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
4244

4345
ENV bazelVersion 3.4.1

scripts/packages/BUILD

+3-3
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,9 @@ genrule(
604604
"export RELEASE_FILE_DIR=$$(pwd)",
605605
"export TMP_DIR=$$(mktemp -d -t heronpy.XXXXX)",
606606
"echo $$TMP_DIR",
607-
"$(location @virtualenv//:virtualenv) --no-download --quiet --clear $$TMP_DIR/venv",
608-
"PS1= source $$TMP_DIR/venv/bin/activate",
607+
# Create the virtual environment
608+
'python3 -m venv $$TMP_DIR/venv --clear',
609+
"VIRTUAL_ENV_DISABLE_PROMPT=1 source $$TMP_DIR/venv/bin/activate",
609610
"export HERONPY_DIR=$$TMP_DIR/heronpy",
610611
"export HERONPYAPI_UNZIP=$$TMP_DIR/heronapiunzip",
611612
"export HERONPYSTREAMLET_UNZIP=$$TMP_DIR/heronstreamletunzip",
@@ -661,7 +662,6 @@ genrule(
661662
"//heronpy/connectors:heron-pythonconnectors-package",
662663
"//heronpy/proto:proto-py-package",
663664
"//heronpy/streamlet:heron-python-streamlet-api-package",
664-
"@virtualenv",
665665
],
666666
)
667667

tools/rules/pex/BUILD

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ LINUX_EXECUTE = [
2525
POST_EXECUTE = [
2626
'ln -sf "$$OUTDIR" "$$TMPF"',
2727
'VENV="$${TMPF}/venv"',
28-
'$(location @virtualenv//:virtualenv) --no-download --quiet --clear "$$VENV"',
29-
'# this is just to keep the activate script happy',
30-
'PS1=',
31-
'source "$$VENV/bin/activate"',
28+
# Create the virtual environment
29+
'python3 -m venv $$VENV --clear',
30+
'VIRTUAL_ENV_DISABLE_PROMPT=1 source "$$VENV/bin/activate"',
3231

3332
'pip install pex \
3433
--quiet --no-cache-dir --no-index --build $(@D)/pexbuild \
@@ -70,6 +69,5 @@ genrule(
7069
executable = True,
7170
message = "Bootstrapping pex",
7271
output_to_bindir = True,
73-
tools = ["@virtualenv"],
7472
visibility = ["//visibility:public"],
7573
)

website2/website/scripts/python-doc-gen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ VENV=./venv/
3636
echo $VENV
3737
PIP_LOCATION=${HERON_ROOT_DIR}/bazel-bin/scripts/packages
3838

39-
virtualenv "$VENV"
39+
python3 -m venv "$VENV"
4040
source "$VENV/bin/activate"
4141
pip3 install pdoc==0.3.2
4242
pip3 install --ignore-installed six

0 commit comments

Comments
 (0)