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
This commit is contained in:
Ian Wienand 2020-02-13 12:07:33 +11:00
parent 500e60dbf4
commit 82cfcfe551
8 changed files with 54 additions and 3 deletions

View File

@ -0,0 +1,5 @@
===========
ensure-venv
===========
A simple element to make sure `python3 -m venv` will work.

View File

@ -0,0 +1 @@
package-installs

View File

@ -0,0 +1 @@
python3-venv:

View File

@ -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": ""
}
}

View File

@ -1,6 +1,6 @@
cloud-init-datasources
dib-init-system
ensure-venv
install-types
pip-and-virtualenv
runtime-ssh-host-keys
source-repositories

View File

@ -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

View File

@ -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

View File

@ -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.