File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 55import subprocess
66from tempfile import mkdtemp
77from typing import Optional
8+ import shutil
89
910import extractor_version
1011
@@ -154,6 +155,17 @@ def install_packages(codeql_base_dir) -> Optional[str]:
154155 # get_extractor_version returns the Python version the extractor thinks this repo is using
155156 version = extractor_version .get_extractor_version (codeql_base_dir , quiet = False )
156157
158+ if version == 2 and not sys .platform .startswith ('win32' ):
159+ # On Ubuntu 22.04 'python2' is not available by default. We want to give a slightly better
160+ # error message than a traceback + `No such file or directory: 'python2'`
161+ if shutil .which ("python2" ) is None :
162+ sys .exit (
163+ "package installation failed: we detected this code as Python 2, but 'python2' executable was not available."
164+ "To enable automatic package installation, please install 'python2' before the 'github/codeql-action/init' step, "
165+ "such as running 'sudo apt install python2' (Ubuntu 22.04)."
166+ "If your code is not Python 2, but actually Python 3, please file a bug report at https://github.com/github/codeql-action/issues/new"
167+ )
168+
157169 if os .path .exists ('requirements.txt' ):
158170 print ('Found requirements.txt, will install packages with pip' , flush = True )
159171 return install_requirements_txt_packages (version )
You can’t perform that action at this time.
0 commit comments