Class: Dependabot::Python::PipenvRunner

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/pipenv_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, lockfile:, language_version_manager:, dependency_files: nil) ⇒ PipenvRunner

Returns a new instance of PipenvRunner.



23
24
25
26
27
28
# File 'lib/dependabot/python/pipenv_runner.rb', line 23

def initialize(dependency:, lockfile:, language_version_manager:, dependency_files: nil)
  @dependency = dependency
  @lockfile = lockfile
  @language_version_manager = language_version_manager
  @dependency_files = dependency_files
end

Instance Method Details

#run(command, fingerprint: nil) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/dependabot/python/pipenv_runner.rb', line 65

def run(command, fingerprint: nil)
  run_command(
    "pyenv local #{language_version_manager.python_major_minor}",
    fingerprint: "pyenv local <python_major_minor>"
  )

  run_command(command, fingerprint: fingerprint)
end

#run_pipenv_graphObject



55
56
57
58
59
60
61
62
# File 'lib/dependabot/python/pipenv_runner.rb', line 55

def run_pipenv_graph
  SharedHelpers.in_a_temporary_directory do
    write_temporary_dependency_files
    language_version_manager.install_required_python
    run_command("pyenv exec pipenv sync --dev", fingerprint: "pyenv exec pipenv sync --dev")
    run_command("pyenv exec pipenv graph --json", fingerprint: "pyenv exec pipenv graph --json")
  end
end

#run_upgrade(constraint) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dependabot/python/pipenv_runner.rb', line 31

def run_upgrade(constraint)
  constraint = "" if constraint == "*"

  # Build the full package specification with extras
  extras_spec = extras_specification
  package_spec = "#{dependency_name}#{extras_spec}#{constraint}"

  command = "pyenv exec pipenv upgrade --verbose #{package_spec}"
  command << " --dev" if lockfile_section == "develop"

  run(command, fingerprint: "pyenv exec pipenv upgrade --verbose <dependency_name><extras><constraint>")
end

#run_upgrade_and_fetch_version(constraint) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/dependabot/python/pipenv_runner.rb', line 45

def run_upgrade_and_fetch_version(constraint)
  run_upgrade(constraint)

  updated_lockfile = JSON.parse(File.read("Pipfile.lock"))

  fetch_version_from_parsed_lockfile(updated_lockfile)
end