Skip to content

Commit 3053252

Browse files
authored
Install python3-venv if it's not already installed on Linux, (#1317)
* Install python3.-venv if it's not already installed on Linux,
1 parent 25a198b commit 3053252

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

scripts/gha/install_prereqs_desktop.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def main():
9090
if not ("gcc version 9." in gcc_ver.stderr or "gcc version 10." in gcc_ver.stderr):
9191
if (not utils.is_command_installed('gcc-10') or
9292
not utils.is_command_installed('g++-10')):
93-
utils.run_command(['apt', 'install', '-y', 'gcc-10', 'g++-10'],
94-
as_root=True)
93+
utils.run_command(['apt', 'install', '-y', 'gcc-10',
94+
'g++-10'], as_root=True)
9595
utils.run_command(['update-alternatives', '--install', '/usr/bin/gcc',
9696
'gcc', '/usr/bin/gcc-10', '10'], as_root=True)
9797
utils.run_command(['update-alternatives', '--install', '/usr/bin/g++',
@@ -100,7 +100,12 @@ def main():
100100
'/usr/bin/gcc-10'], as_root=True)
101101
utils.run_command(['update-alternatives', '--set', 'g++',
102102
'/usr/bin/g++-10'], as_root=True)
103-
103+
104+
# On Linux, the python3-venv package is required.
105+
if utils.is_linux_os():
106+
if not utils.glob_exists("/usr/share/doc/python3.*-venv"):
107+
utils.run_command(['apt', 'install', '-y', 'python3-venv'], as_root=True)
108+
104109
# Install required python dependencies.
105110
# On Catalina, python2 in installed as default python.
106111
# Example command:

scripts/gha/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"""
2121

2222
import distutils.spawn
23+
import glob
2324
import platform
2425
import shutil
2526
import subprocess
@@ -65,6 +66,11 @@ def is_command_installed(tool):
6566
return distutils.spawn.find_executable(tool)
6667

6768

69+
def glob_exists(glob_path):
70+
"""Check if any file/directory exists at a given path glob."""
71+
return len(glob.glob(glob_path)) > 0
72+
73+
6874
def delete_directory(dir_path):
6975
"""Recursively delete a valid directory"""
7076
if os.path.exists(dir_path):
@@ -260,4 +266,3 @@ def install_x86_support_libraries(gha_build=False):
260266
with open(os.devnull, "w") as devnull:
261267
subprocess.run(["dpkg", "-s"] + packages, stdout=devnull, stderr=subprocess.STDOUT,
262268
check=True)
263-

0 commit comments

Comments
 (0)