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 5
5
import subprocess
6
6
from tempfile import mkdtemp
7
7
from typing import Optional
8
+ import shutil
8
9
9
10
import extractor_version
10
11
@@ -154,6 +155,17 @@ def install_packages(codeql_base_dir) -> Optional[str]:
154
155
# get_extractor_version returns the Python version the extractor thinks this repo is using
155
156
version = extractor_version .get_extractor_version (codeql_base_dir , quiet = False )
156
157
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
+
157
169
if os .path .exists ('requirements.txt' ):
158
170
print ('Found requirements.txt, will install packages with pip' , flush = True )
159
171
return install_requirements_txt_packages (version )
You can’t perform that action at this time.
0 commit comments