diff --git a/.circleci/images/Dockerfile b/.circleci/images/Dockerfile index 8cee6f46c..7f9a0f3e3 100644 --- a/.circleci/images/Dockerfile +++ b/.circleci/images/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:latest # System setup -RUN apt-get update && apt-get install -y python3-flake8 python3-pip python3-pil clang git openssh-client make-guile +RUN apt-get update && apt-get install -y python3-flake8 python3-pip python3-pil clang git openssh-client build-essential libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev libffi-dev # kitty deps RUN apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libpng-dev libfontconfig-dev libpython3-dev libxkbcommon-x11-dev python3-pygments @@ -9,5 +9,10 @@ RUN apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev l # Needed to build kitty docs RUN pip3 install sphinx +# Install multiple pythons +ADD install-python.py /tmp/install-python.py +RUN python3 /tmp/install-python.py py3.5 https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz +RUN python3 /tmp/install-python.py py3.7 https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz + LABEL com.circleci.preserve-entrypoint=true ENTRYPOINT sleep 2h diff --git a/.circleci/images/install-python.py b/.circleci/images/install-python.py new file mode 100644 index 000000000..cb934e849 --- /dev/null +++ b/.circleci/images/install-python.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# vim:fileencoding=utf-8 +# License: GPLv3 Copyright: 2019, Kovid Goyal + +import io +import os +import shlex +import shutil +import subprocess +import sys +import tarfile +from urllib.request import urlopen + +PY, URL = sys.argv[1], sys.argv[2] +SRC = f'/usr/src/{PY}' + +os.chdir('/usr/src') +before = frozenset(os.listdir('.')) + + +def run(cmd): + cmd = shlex.split(cmd) + p = subprocess.Popen(cmd) + if p.wait() != 0: + raise SystemExit(p.returncode) + + +with urlopen(URL) as f: + data = f.read() + +with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf: + tf.extractall() +after = frozenset(os.listdir('.')) +src_dir = tuple(after - before)[0] +os.rename(src_dir, SRC) +os.chdir(SRC) +run(f'./configure --prefix=/opt/{PY} --enable-shared --with-system-expat --with-system-ffi --without-ensurepip') +run(f'make -j {os.cpu_count()}') +run('make install') +os.chdir('/') +shutil.rmtree(SRC)