From 90e20e14ede7c92c15706986e975c39514ec9605 Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Wed, 30 Aug 2023 00:03:23 -0700 Subject: [PATCH] Use `python3`/`pip3` so we don't have to have `python`/`pip` symlinks To reduce ambiguity, by default the compiled output from python 3 results in the commands `python3` / `pip3`. Often wrapper tooling will create additional symlinks of `python`/`pip` pointing at these, but they aren't the out-of-the-box default when compiling Python straight from source. In our case, `pyenv` _does_ add these symlinks. However, if we move away from using `pyenv install` to another method (:wink:), then life will be simpler if we directly call `python3` / `pip3` because we won't need to create symlinks. --- python/helpers/build | 2 +- python/lib/dependabot/python/file_parser.rb | 2 +- .../dependabot/python/file_parser/pyproject_files_parser.rb | 2 +- python/lib/dependabot/python/file_parser/setup_file_parser.rb | 4 ++-- .../python/file_updater/pip_compile_file_updater.rb | 2 +- .../dependabot/python/file_updater/pipfile_file_updater.rb | 2 +- .../lib/dependabot/python/file_updater/poetry_file_updater.rb | 2 +- .../dependabot/python/file_updater/requirement_replacer.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python/helpers/build b/python/helpers/build index 4f043ff2c1e7..a413d4ba1542 100755 --- a/python/helpers/build +++ b/python/helpers/build @@ -18,4 +18,4 @@ cp -r \ "$install_dir" cd "$install_dir" -PYENV_VERSION=$1 pyenv exec pip --disable-pip-version-check install --use-pep517 -r "requirements.txt" +PYENV_VERSION=$1 pyenv exec pip3 --disable-pip-version-check install --use-pep517 -r "requirements.txt" diff --git a/python/lib/dependabot/python/file_parser.rb b/python/lib/dependabot/python/file_parser.rb index 317c9fd06c6a..7082908e5e71 100644 --- a/python/lib/dependabot/python/file_parser.rb +++ b/python/lib/dependabot/python/file_parser.rb @@ -133,7 +133,7 @@ def parsed_requirement_files write_temporary_dependency_files requirements = SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "parse_requirements", args: [Dir.pwd] ) diff --git a/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb b/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb index 3d07df0b53b7..e94fbd46cff2 100644 --- a/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb +++ b/python/lib/dependabot/python/file_parser/pyproject_files_parser.rb @@ -247,7 +247,7 @@ def parsed_pep621_dependencies write_temporary_pyproject SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "parse_pep621_dependencies", args: [pyproject.name] ) diff --git a/python/lib/dependabot/python/file_parser/setup_file_parser.rb b/python/lib/dependabot/python/file_parser/setup_file_parser.rb index dd5d56f31713..65578207f872 100644 --- a/python/lib/dependabot/python/file_parser/setup_file_parser.rb +++ b/python/lib/dependabot/python/file_parser/setup_file_parser.rb @@ -60,7 +60,7 @@ def parsed_setup_file write_temporary_dependency_files requirements = SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "parse_setup", args: [Dir.pwd] ) @@ -81,7 +81,7 @@ def parsed_sanitized_setup_file write_sanitized_setup_file requirements = SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "parse_setup", args: [Dir.pwd] ) 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 0094e7f7daf6..b3c3b900178f 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 @@ -376,7 +376,7 @@ def deps_to_augment_hashes_for(updated_content, original_content) def package_hashes_for(name:, version:, algorithm:) SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "get_dependency_hash", args: [name, version, algorithm] ).map { |h| "--hash=#{algorithm}:#{h['hash']}" } diff --git a/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb b/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb index 951966a9ba65..20e28aca4613 100644 --- a/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/pipfile_file_updater.rb @@ -326,7 +326,7 @@ def pipfile_hash_for(pipfile_content) SharedHelpers.in_a_temporary_directory do |dir| File.write(File.join(dir, "Pipfile"), pipfile_content) SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "get_pipfile_hash", args: [dir] ) diff --git a/python/lib/dependabot/python/file_updater/poetry_file_updater.rb b/python/lib/dependabot/python/file_updater/poetry_file_updater.rb index ad4f50a54511..34f70fa265d1 100644 --- a/python/lib/dependabot/python/file_updater/poetry_file_updater.rb +++ b/python/lib/dependabot/python/file_updater/poetry_file_updater.rb @@ -232,7 +232,7 @@ def pyproject_hash_for(pyproject_content) write_temporary_dependency_files(pyproject_content) SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{python_helper_path}", + command: "pyenv exec python3 #{python_helper_path}", function: "get_pyproject_hash", args: [dir] ) diff --git a/python/lib/dependabot/python/file_updater/requirement_replacer.rb b/python/lib/dependabot/python/file_updater/requirement_replacer.rb index 36e047abcdef..38dae3ba5268 100644 --- a/python/lib/dependabot/python/file_updater/requirement_replacer.rb +++ b/python/lib/dependabot/python/file_updater/requirement_replacer.rb @@ -134,7 +134,7 @@ def hash_separator(requirement) def package_hashes_for(name:, version:, algorithm:) SharedHelpers.run_helper_subprocess( - command: "pyenv exec python #{NativeHelpers.python_helper_path}", + command: "pyenv exec python3 #{NativeHelpers.python_helper_path}", function: "get_dependency_hash", args: [name, version, algorithm] ).map { |h| "--hash=#{algorithm}:#{h['hash']}" }