From 82cfcfe5514fc780e837b9344e1ac7f7a1056b82 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 13 Feb 2020 12:07:33 +1100 Subject: [PATCH] Add ensure-venv element, install glean with it All the platforms we care about now have python3 with venv (even centos7 now) packaged somehow. Add an ensure-venv element to make sure that "python3 -m venv" works. Any other elements that wish to install non-distribution-packaged Python utilities can use this to keep them separate from the main system installs. Port glean to use this, and drop its dependency on pip-and-virtualenv. Change-Id: Ic16f134fe34293bb68e7c632dd320f523366320d --- .../elements/ensure-venv/README.rst | 5 +++++ .../elements/ensure-venv/element-deps | 1 + .../ensure-venv/package-installs.yaml | 1 + .../elements/ensure-venv/pkg-map | 19 +++++++++++++++++++ .../elements/simple-init/element-deps | 2 +- .../simple-init-repo-install/40-glean | 8 +++++++- .../simple-init-source-install/40-glean | 8 +++++++- .../notes/ensure-venv-d7c16a2a04fd3b8f.yaml | 13 +++++++++++++ 8 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 diskimage_builder/elements/ensure-venv/README.rst create mode 100644 diskimage_builder/elements/ensure-venv/element-deps create mode 100644 diskimage_builder/elements/ensure-venv/package-installs.yaml create mode 100644 diskimage_builder/elements/ensure-venv/pkg-map create mode 100644 releasenotes/notes/ensure-venv-d7c16a2a04fd3b8f.yaml diff --git a/diskimage_builder/elements/ensure-venv/README.rst b/diskimage_builder/elements/ensure-venv/README.rst new file mode 100644 index 00000000..d9a52113 --- /dev/null +++ b/diskimage_builder/elements/ensure-venv/README.rst @@ -0,0 +1,5 @@ +=========== +ensure-venv +=========== + +A simple element to make sure `python3 -m venv` will work. diff --git a/diskimage_builder/elements/ensure-venv/element-deps b/diskimage_builder/elements/ensure-venv/element-deps new file mode 100644 index 00000000..7076aba9 --- /dev/null +++ b/diskimage_builder/elements/ensure-venv/element-deps @@ -0,0 +1 @@ +package-installs diff --git a/diskimage_builder/elements/ensure-venv/package-installs.yaml b/diskimage_builder/elements/ensure-venv/package-installs.yaml new file mode 100644 index 00000000..78b2e885 --- /dev/null +++ b/diskimage_builder/elements/ensure-venv/package-installs.yaml @@ -0,0 +1 @@ +python3-venv: diff --git a/diskimage_builder/elements/ensure-venv/pkg-map b/diskimage_builder/elements/ensure-venv/pkg-map new file mode 100644 index 00000000..0056fefa --- /dev/null +++ b/diskimage_builder/elements/ensure-venv/pkg-map @@ -0,0 +1,19 @@ +{ + "family": { + "debian": { + "python3-venv": "python3-venv" + }, + "gentoo": { + "python3-venv": "dev-lang/python" + }, + "redhat": { + "python3-venv": "python3" + }, + "suse": { + "python3-venv": "python3" + } + }, + "default": { + "python3-venv": "" + } +} diff --git a/diskimage_builder/elements/simple-init/element-deps b/diskimage_builder/elements/simple-init/element-deps index 9d4a9f73..014ef9be 100644 --- a/diskimage_builder/elements/simple-init/element-deps +++ b/diskimage_builder/elements/simple-init/element-deps @@ -1,6 +1,6 @@ cloud-init-datasources dib-init-system +ensure-venv install-types -pip-and-virtualenv runtime-ssh-host-keys source-repositories diff --git a/diskimage_builder/elements/simple-init/install.d/simple-init-repo-install/40-glean b/diskimage_builder/elements/simple-init/install.d/simple-init-repo-install/40-glean index a7491ab9..5a838de7 100755 --- a/diskimage_builder/elements/simple-init/install.d/simple-init-repo-install/40-glean +++ b/diskimage_builder/elements/simple-init/install.d/simple-init-repo-install/40-glean @@ -21,4 +21,10 @@ fi set -eu set -o pipefail -$DIB_PYTHON_PIP install /tmp/glean.git +python3 -m venv /usr/glean +/usr/glean/bin/pip install /tmp/glean.git + +mkdir -p /usr/local/bin +ln -sf /usr/glean/bin/glean /usr/local/bin/glean +ln -sf /usr/glean/bin/glean.sh /usr/local/bin/glean.sh +ln -sf /usr/glean/bin/glean-install /usr/local/bin/glean-install diff --git a/diskimage_builder/elements/simple-init/install.d/simple-init-source-install/40-glean b/diskimage_builder/elements/simple-init/install.d/simple-init-source-install/40-glean index 4dd685ad..2107a87d 100755 --- a/diskimage_builder/elements/simple-init/install.d/simple-init-source-install/40-glean +++ b/diskimage_builder/elements/simple-init/install.d/simple-init-source-install/40-glean @@ -21,4 +21,10 @@ fi set -eu set -o pipefail -$DIB_PYTHON_PIP install glean +python3 -m venv /usr/glean +/usr/glean/bin/pip install glean + +mkdir -p /usr/local/bin +ln -sf /usr/glean/bin/glean /usr/local/bin/glean +ln -sf /usr/glean/bin/glean.sh /usr/local/bin/glean.sh +ln -sf /usr/glean/bin/glean-install /usr/local/bin/glean-install diff --git a/releasenotes/notes/ensure-venv-d7c16a2a04fd3b8f.yaml b/releasenotes/notes/ensure-venv-d7c16a2a04fd3b8f.yaml new file mode 100644 index 00000000..0af105cc --- /dev/null +++ b/releasenotes/notes/ensure-venv-d7c16a2a04fd3b8f.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + The `ensure-venv` module is added to ensure that `python3 -m venv` + is available on the host. This can be useful if you wish to + install non-distribution-packaged Python software on a host during + build, but not mix any non-distro installation. This works on all + platforms with Python 3 available. +depreceations: + - | + The `simple-init` element now uses `ensure-venv` so is technically + Python 3 only. At this stage, all supported platforms have Python + 3 available. \ No newline at end of file