Bug 1825755 - Only create the mozharness venv using `--without-pip` on Windows r=firefox-build-system-reviewers,glandium

- On Debian/Ubuntu, the base distribution of Python does not come with `ensurepip` (which is still called during `venv` creation). The benefit of not calling `ensurepip` explicitly in a separate command (like we now do for Windows) is that the error message you get when creating the `venv` is very clear and instructs the user to run `apt install python3.x-venv` to fix the problem. (`python3.x-venv` is what contains `ensurepip`). If we did not do this, it would just tell the user that there is `no ensurepip module` and it would hard to figure out that the solution is to run `apt install python3.x-venv`. This isn't an issue for us in CI, but it can be for end users, since that package may not be installed, and some commands (like talos tests) go through mozharness and invoke this code.

- Also removed some Python dependencies in the Linux build docs that are no longer needed.

Differential Revision: https://phabricator.services.mozilla.com/D174525
This commit is contained in:
ahochheiden 2023-04-11 18:49:03 +00:00
Родитель d34a5950bb
Коммит 80339c628f
2 изменённых файлов: 18 добавлений и 12 удалений

Просмотреть файл

@ -36,8 +36,8 @@ Python development files as well to install some pip packages.
You should be able to install Python using your system package manager:
- For Debian-based Linux (such as Ubuntu): ``sudo apt-get install curl python3 python3-dev python3-pip``
- For Fedora Linux: ``sudo dnf install python3 python3-devel python3-pip``
- For Debian-based Linux (such as Ubuntu): ``sudo apt-get install curl python3 python3-pip``
- For Fedora Linux: ``sudo dnf install python3 python3-pip``
If you need a version of Python that your package manager doesn't have (e.g.:
the provided Python 3 is too old, or you want Python 2 but it's not available),

Просмотреть файл

@ -531,23 +531,29 @@ class VirtualenvMixin(object):
sys.executable, str(expected_python_debug_exe)
)
venv_creation_flags = ["-m", "venv", venv_path]
if self._is_windows():
# To workaround an issue on Windows10 jobs in CI we have to
# explicitly install the default pip separately. Ideally we
# could just remove the "--without-pip" above and get the same
# result, but that's apparently not always the case.
venv_creation_flags = venv_creation_flags + ["--without-pip"]
self.mkdir_p(dirs["abs_work_dir"])
self.run_command(
[sys.executable, "-m", "venv", "--without-pip", venv_path],
[sys.executable] + venv_creation_flags,
cwd=dirs["abs_work_dir"],
error_list=VirtualenvErrorList,
halt_on_failure=True,
)
# To workaround an issue on Windows10 jobs in CI we have to
# explicitly install the default pip separately. Ideally we
# could just remove the "--without-pip" above and get the same
# result, but that's apparently not always the case.
self.run_command(
[str(venv_python_bin), "-m", "ensurepip", "--default-pip"],
cwd=dirs["abs_work_dir"],
halt_on_failure=True,
)
if self._is_windows():
self.run_command(
[str(venv_python_bin), "-m", "ensurepip", "--default-pip"],
cwd=dirs["abs_work_dir"],
halt_on_failure=True,
)
self._ensure_python_exe(venv_python_bin.parent)