Skip to content

Commit dffce99

Browse files
committed
Minor fixes to python installation scripts based on code review
1 parent 6645c55 commit dffce99

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

python-setup/auto_install_packages.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import subprocess
66
from tempfile import mkdtemp
7+
from typing import Optional
78

89
import extractor_version
910

@@ -101,7 +102,7 @@ def install_with_setup_py(version: int):
101102
return venv_python
102103

103104

104-
def install_packages() -> str:
105+
def install_packages(codeql_base_dir) -> Optional[str]:
105106
if os.path.exists('poetry.lock'):
106107
print('Found poetry.lock, will install packages with poetry', flush=True)
107108
return install_packages_with_poetry()
@@ -113,7 +114,7 @@ def install_packages() -> str:
113114
print('Found Pipfile, will install packages with Pipenv', flush=True)
114115
return install_packages_with_pipenv()
115116

116-
version = extractor_version.get_extractor_version(sys.argv[1], quiet=False)
117+
version = extractor_version.get_extractor_version(codeql_base_dir, quiet=False)
117118

118119
if os.path.exists('requirements.txt'):
119120
print('Found requirements.txt, will install packages with pip', flush=True)
@@ -124,17 +125,20 @@ def install_packages() -> str:
124125
return install_with_setup_py(version)
125126

126127
print("was not able to install packages automatically", flush=True)
128+
return None
127129

128130

129131
if __name__ == "__main__":
130132
if len(sys.argv) != 2:
131133
sys.exit('Must provide base directory for codeql tool as only argument')
132134

135+
codeql_base_dir = sys.argv[1]
136+
133137
# The binaries for packages installed with `pip install --user` are not available on
134138
# PATH by default, so we need to manually add them.
135139
os.environ['PATH'] = os.path.expanduser('~/.local/bin') + os.pathsep + os.environ['PATH']
136140

137-
python_executable_path = install_packages()
141+
python_executable_path = install_packages(codeql_base_dir)
138142

139143
if python_executable_path is not None:
140144
print("Setting CODEQL_PYTHON={}".format(python_executable_path))

0 commit comments

Comments
 (0)