From 4415e78fd8368d90b98b8de2320ec850fe37335a Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Wed, 12 Oct 2022 07:40:14 -0600 Subject: [PATCH 1/6] Fixing PR failures if pypi.org unavailable --- .../python/file_updater/pip_compile_file_updater.rb | 4 +++- python/lib/dependabot/python/metadata_finder.rb | 2 ++ python/lib/dependabot/python/update_checker.rb | 2 ++ python/lib/dependabot/python/update_checker/index_finder.rb | 3 +++ .../python/update_checker/pip_compile_version_resolver.rb | 5 +++-- .../python/update_checker/pipenv_version_resolver.rb | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index 27708dc948a..4413c16876d 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -220,7 +220,7 @@ def write_updated_dependency_files end def install_required_python - return if run_command("pyenv versions").include?("#{python_version}\n") + return if run_command("pyenv versions").include?("#{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") @@ -449,6 +449,8 @@ def pip_compile_index_options "--extra-index-url=#{authed_url}" end end + index_finder = Dependabot::Python::UpdateChecker::IndexFinder.new(dependency_files: dependency_files, credentials: credentials) + ["--index-url=#{index_finder.index_url_for_dependency('')}"] end def includes_unsafe_packages?(content) diff --git a/python/lib/dependabot/python/metadata_finder.rb b/python/lib/dependabot/python/metadata_finder.rb index 09e7fca0120..c136a0b31ba 100644 --- a/python/lib/dependabot/python/metadata_finder.rb +++ b/python/lib/dependabot/python/metadata_finder.rb @@ -131,6 +131,8 @@ def pypi_listing return @pypi_listing rescue JSON::ParserError next + rescue Excon::Error::Timeout + next end @pypi_listing = {} # No listing found diff --git a/python/lib/dependabot/python/update_checker.rb b/python/lib/dependabot/python/update_checker.rb index ef673477d86..55a0747ba05 100644 --- a/python/lib/dependabot/python/update_checker.rb +++ b/python/lib/dependabot/python/update_checker.rb @@ -277,6 +277,8 @@ def poetry_library? pypi_info = JSON.parse(index_response.body)["info"] || {} pypi_info["summary"] == details["description"] + rescue Excon::Error::Timeout + false rescue URI::InvalidURIError false end diff --git a/python/lib/dependabot/python/update_checker/index_finder.rb b/python/lib/dependabot/python/update_checker/index_finder.rb index ce74363c821..eb6525f64e7 100644 --- a/python/lib/dependabot/python/update_checker/index_finder.rb +++ b/python/lib/dependabot/python/update_checker/index_finder.rb @@ -36,6 +36,9 @@ def index_urls end.uniq end + def index_url_for_dependency(dependency_name) + return main_index_url if main_index_url + end private attr_reader :dependency_files, :credentials diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index c654082b324..6ee308ec838 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -244,6 +244,8 @@ def pip_compile_index_options "--extra-index-url=#{authed_url}" end end + index_finder = IndexFinder.new(dependency_files: dependency_files, credentials: credentials) + ["--index-url=#{index_finder.index_url_for_dependency('')}"] end def run_pip_compile_command(command) @@ -314,8 +316,7 @@ def write_original_manifest_files end def install_required_python - return if run_command("pyenv versions").include?("#{python_version}\n") - + return if run_command("pyenv versions").include?("#{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") run_command("pyenv exec pip install -r" \ diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index ec0532e477f..4d2d0f3edac 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -323,7 +323,7 @@ def install_required_python nil end - return if run_command("pyenv versions").include?("#{python_version}\n") + return if run_command("pyenv versions").include?("#{python_version}") requirements_path = NativeHelpers.python_requirements_path run_command("pyenv install -s #{python_version}") From fcdc181727fc23ed21cbfa0e0bd2dea0c2529237 Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Wed, 12 Oct 2022 08:08:36 -0600 Subject: [PATCH 2/6] remove index_url_for_dependency --- .../dependabot/python/file_updater/pip_compile_file_updater.rb | 2 -- python/lib/dependabot/python/update_checker/index_finder.rb | 3 --- .../python/update_checker/pip_compile_version_resolver.rb | 2 -- 3 files changed, 7 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index 4413c16876d..c6c3e88b90f 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -449,8 +449,6 @@ def pip_compile_index_options "--extra-index-url=#{authed_url}" end end - index_finder = Dependabot::Python::UpdateChecker::IndexFinder.new(dependency_files: dependency_files, credentials: credentials) - ["--index-url=#{index_finder.index_url_for_dependency('')}"] end def includes_unsafe_packages?(content) diff --git a/python/lib/dependabot/python/update_checker/index_finder.rb b/python/lib/dependabot/python/update_checker/index_finder.rb index eb6525f64e7..ce74363c821 100644 --- a/python/lib/dependabot/python/update_checker/index_finder.rb +++ b/python/lib/dependabot/python/update_checker/index_finder.rb @@ -36,9 +36,6 @@ def index_urls end.uniq end - def index_url_for_dependency(dependency_name) - return main_index_url if main_index_url - end private attr_reader :dependency_files, :credentials diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index 6ee308ec838..3d9bacb50ca 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -244,8 +244,6 @@ def pip_compile_index_options "--extra-index-url=#{authed_url}" end end - index_finder = IndexFinder.new(dependency_files: dependency_files, credentials: credentials) - ["--index-url=#{index_finder.index_url_for_dependency('')}"] end def run_pip_compile_command(command) From b34b098c932def468bd3299f6ed0d95a8399a3bd Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Wed, 12 Oct 2022 08:32:19 -0600 Subject: [PATCH 3/6] fix lint issues --- .../dependabot/python/file_updater/pip_compile_file_updater.rb | 2 +- .../python/update_checker/pip_compile_version_resolver.rb | 3 ++- .../python/update_checker/pipenv_version_resolver.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index c6c3e88b90f..59163522546 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -220,7 +220,7 @@ def write_updated_dependency_files end def install_required_python - return if run_command("pyenv versions").include?("#{python_version}") + return if run_command("pyenv versions").include?(python_version.to_s) run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index 3d9bacb50ca..bf279355ded 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -314,7 +314,8 @@ def write_original_manifest_files end def install_required_python - return if run_command("pyenv versions").include?("#{python_version}") + return if run_command("pyenv versions").include?(python_version.to_s) + run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") run_command("pyenv exec pip install -r" \ diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index 4d2d0f3edac..8882d50dfd3 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -323,7 +323,7 @@ def install_required_python nil end - return if run_command("pyenv versions").include?("#{python_version}") + return if run_command("pyenv versions").include?(python_version.to_s) requirements_path = NativeHelpers.python_requirements_path run_command("pyenv install -s #{python_version}") From 5c2212162745eac3b6cbe6adc206f4b66e701102 Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Wed, 12 Oct 2022 09:21:08 -0600 Subject: [PATCH 4/6] already a string. --- .../dependabot/python/file_updater/pip_compile_file_updater.rb | 2 +- .../python/update_checker/pip_compile_version_resolver.rb | 2 +- .../dependabot/python/update_checker/pipenv_version_resolver.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index 59163522546..b0760030882 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -220,7 +220,7 @@ def write_updated_dependency_files end def install_required_python - return if run_command("pyenv versions").include?(python_version.to_s) + return if run_command("pyenv versions").include?(python_version) run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index bf279355ded..bb4d5a0f3ed 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -314,7 +314,7 @@ def write_original_manifest_files end def install_required_python - return if run_command("pyenv versions").include?(python_version.to_s) + return if run_command("pyenv versions").include?(python_version) run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index 8882d50dfd3..9d06ff15bc3 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -323,7 +323,7 @@ def install_required_python nil end - return if run_command("pyenv versions").include?(python_version.to_s) + return if run_command("pyenv versions").include?(python_version) requirements_path = NativeHelpers.python_requirements_path run_command("pyenv install -s #{python_version}") From 7a3382b729c31d4eb9fd3f65226cd031edfca8c6 Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Thu, 13 Oct 2022 07:06:28 -0600 Subject: [PATCH 5/6] Version check improvement --- .../dependabot/python/file_updater/pip_compile_file_updater.rb | 2 +- .../python/update_checker/pip_compile_version_resolver.rb | 2 +- .../dependabot/python/update_checker/pipenv_version_resolver.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index b0760030882..482f087c754 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -220,7 +220,7 @@ def write_updated_dependency_files end def install_required_python - return if run_command("pyenv versions").include?(python_version) + return if run_command("pyenv versions").include?(" #{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index bb4d5a0f3ed..5b1e60e5ddd 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -314,7 +314,7 @@ def write_original_manifest_files end def install_required_python - return if run_command("pyenv versions").include?(python_version) + return if run_command("pyenv versions").include?(" #{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index 9d06ff15bc3..0da5eaf8b87 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -323,7 +323,7 @@ def install_required_python nil end - return if run_command("pyenv versions").include?(python_version) + return if run_command("pyenv versions").include?(" #{python_version}") requirements_path = NativeHelpers.python_requirements_path run_command("pyenv install -s #{python_version}") From 8467689319c22a574c71943c997a08b682dc7d0b Mon Sep 17 00:00:00 2001 From: Tom Christensen Date: Mon, 17 Oct 2022 09:11:21 -0600 Subject: [PATCH 6/6] Make the spaces more readable/visible --- .../dependabot/python/file_updater/pip_compile_file_updater.rb | 2 +- .../python/update_checker/pip_compile_version_resolver.rb | 2 +- .../dependabot/python/update_checker/pipenv_version_resolver.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb index 482f087c754..267b695bf87 100644 --- a/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pip_compile_file_updater.rb @@ -220,7 +220,7 @@ def write_updated_dependency_files end def install_required_python - return if run_command("pyenv versions").include?(" #{python_version}") + return if run_command("pyenv versions").include?("\ #{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb index 5b1e60e5ddd..d0b32fdc387 100644 --- a/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pip_compile_version_resolver.rb @@ -314,7 +314,7 @@ def write_original_manifest_files end def install_required_python - return if run_command("pyenv versions").include?(" #{python_version}") + return if run_command("pyenv versions").include?("\ #{python_version}") run_command("pyenv install -s #{python_version}") run_command("pyenv exec pip install --upgrade pip") diff --git a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb index 0da5eaf8b87..608ce50ae54 100644 --- a/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb +++ b/python/lib/dependabot/python/update_checker/pipenv_version_resolver.rb @@ -323,7 +323,7 @@ def install_required_python nil end - return if run_command("pyenv versions").include?(" #{python_version}") + return if run_command("pyenv versions").include?("\ #{python_version}") requirements_path = NativeHelpers.python_requirements_path run_command("pyenv install -s #{python_version}")