Skip to content

Commit

Permalink
python-setup: refactor Pipenv without lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus Wriedt Larsen authored and Michael A. Smith committed Apr 18, 2022
1 parent 808c292 commit b9577df
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python-setup/auto_install_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def install_packages_with_poetry():
return python_executable_path


def install_packages_with_pipenv(skip_lock=False):
def install_packages_with_pipenv(has_lockfile):
command = [sys.executable, '-m', 'pipenv']
if sys.platform.startswith('win32'):
# In windows the default path were the deps are installed gets wiped out between steps,
# so we have to set it up to a folder that will be kept
os.environ['WORKON_HOME'] = os.path.join(os.environ['RUNNER_WORKSPACE'], 'virtualenvs')
lock_args = ['--skip-lock'] if skip_lock else ['--keep-outdated', '--ignore-pipfile']
lock_args = ['--keep-outdated', '--ignore-pipfile'] if has_lockfile else ['--skip-lock']
try:
_check_call(command + ['install'] + lock_args)
except subprocess.CalledProcessError:
Expand Down Expand Up @@ -146,11 +146,10 @@ def install_packages(codeql_base_dir) -> Optional[str]:
if os.path.exists('Pipfile') or os.path.exists('Pipfile.lock'):
if os.path.exists('Pipfile.lock'):
print('Found Pipfile.lock, will install packages with Pipenv', flush=True)
return install_packages_with_pipenv()
return install_packages_with_pipenv(has_lockfile=True)
else:
print('Found Pipfile, will install packages with Pipenv', flush=True)
return install_packages_with_pipenv(skip_lock=True)

return install_packages_with_pipenv(has_lockfile=False)

# get_extractor_version returns the Python version the extractor thinks this repo is using
version = extractor_version.get_extractor_version(codeql_base_dir, quiet=False)
Expand Down

0 comments on commit b9577df

Please sign in to comment.