Skip to content

Commit 0d97ea8

Browse files
committed
Call pipenv and poetry through python
1 parent 72e430f commit 0d97ea8

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

python-setup/auto_install_packages.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ def _check_output(command):
2323

2424

2525
def install_packages_with_poetry():
26+
command = ['poetry']
2627
if sys.platform.startswith('win32'):
28+
command = ['py', '-3' , '-m', 'poetry']
2729
os.environ['POETRY_VIRTUALENVS_PATH'] = os.path.join(os.environ['RUNNER_WORKSPACE'], 'virtualenvs')
2830
try:
29-
_check_call(['poetry', 'install', '--no-root'])
31+
_check_call(command + ['install', '--no-root'])
3032
except subprocess.CalledProcessError:
3133
sys.exit('package installation with poetry failed, see error above')
3234

@@ -35,7 +37,7 @@ def install_packages_with_poetry():
3537
# virtualenv for the package, which was the case for using poetry for Python 2 when
3638
# default system interpreter was Python 3 :/
3739

38-
poetry_out = _check_output(['poetry', 'run', 'which', 'python'])
40+
poetry_out = _check_output(command + ['run', 'which', 'python'])
3941
python_executable_path = poetry_out.decode('utf-8').splitlines()[-1]
4042

4143
if sys.platform.startswith('win32'):
@@ -44,14 +46,16 @@ def install_packages_with_poetry():
4446

4547

4648
def install_packages_with_pipenv():
49+
command = ['pipenv']
4750
if sys.platform.startswith('win32'):
51+
command = ['py', '-3' , '-m', 'pipenv']
4852
os.environ['WORKON_HOME'] = os.path.join(os.environ['RUNNER_WORKSPACE'], 'virtualenvs')
4953
try:
50-
_check_call(['pipenv', 'install', '--keep-outdated', '--ignore-pipfile'])
54+
_check_call(command + ['install', '--keep-outdated', '--ignore-pipfile'])
5155
except subprocess.CalledProcessError:
5256
sys.exit('package installation with pipenv failed, see error above')
5357

54-
pipenv_out = _check_output(['pipenv', 'run', 'which', 'python'])
58+
pipenv_out = _check_output(command + ['run', 'which', 'python'])
5559
python_executable_path = pipenv_out.decode('utf-8').splitlines()[-1]
5660

5761
if sys.platform.startswith('win32'):
@@ -162,9 +166,7 @@ def install_packages(codeql_base_dir) -> Optional[str]:
162166

163167
# The binaries for packages installed with `pip install --user` are not available on
164168
# PATH by default, so we need to manually add them.
165-
if sys.platform.startswith('win32'):
166-
os.environ['PATH'] = os.path.expandvars('%APPDATA%\Python\\Python38\\scripts') + os.pathsep + os.environ['PATH']
167-
else:
169+
if sys.platform.startswith('linux'):
168170
os.environ['PATH'] = os.path.expanduser('~/.local/bin') + os.pathsep + os.environ['PATH']
169171

170172
python_executable_path = install_packages(codeql_base_dir)

0 commit comments

Comments
 (0)