diff --git a/python/lib/dependabot/python/file_parser.rb b/python/lib/dependabot/python/file_parser.rb index 0846bcf13d..07ea6a47b1 100644 --- a/python/lib/dependabot/python/file_parser.rb +++ b/python/lib/dependabot/python/file_parser.rb @@ -86,6 +86,10 @@ def python_requirement_parser sig { returns(Ecosystem::VersionManager) } def package_manager + if Dependabot::Experiments.enabled?(:enable_file_parser_python_local) + Dependabot.logger.info("Detected package manager : #{detected_package_manager.name}") + end + @package_manager ||= detected_package_manager end @@ -93,12 +97,12 @@ def package_manager def detected_package_manager setup_python_environment if Dependabot::Experiments.enabled?(:enable_file_parser_python_local) + return PipenvPackageManager.new(T.must(detect_pipenv_version)) if detect_pipenv_version + return PoetryPackageManager.new(T.must(detect_poetry_version)) if detect_poetry_version return PipCompilePackageManager.new(T.must(detect_pipcompile_version)) if detect_pipcompile_version - return PipenvPackageManager.new(T.must(detect_pipenv_version)) if detect_pipenv_version - PipPackageManager.new(detect_pip_version) end @@ -123,7 +127,7 @@ def detect_poetry_version # Detects the version of pip-compile. If the version cannot be detected, it returns nil sig { returns(T.nilable(String)) } def detect_pipcompile_version - if pip_compile_files + if pipcompile_in_file package_manager = PipCompilePackageManager::NAME version = package_manager_version(package_manager) @@ -145,7 +149,7 @@ def detect_pipenv_version package_manager = PipenvPackageManager::NAME version = package_manager_version(package_manager) - .to_s.split("versions ").last&.strip + .to_s.split("version ").last&.strip log_if_version_malformed(package_manager, version) @@ -174,7 +178,6 @@ def detect_pip_version sig { params(package_manager: String).returns(T.any(String, T.untyped)) } def package_manager_version(package_manager) version_info = SharedHelpers.run_shell_command("pyenv exec #{package_manager} --version") - Dependabot.logger.info("Package manager #{package_manager}, Info : #{version_info}") version_info @@ -206,6 +209,11 @@ def log_if_version_malformed(package_manager, version) sig { returns(String) } def python_raw_version + if Dependabot::Experiments.enabled?(:enable_file_parser_python_local) + Dependabot.logger.info("Detected python version: #{language_version_manager.python_version}") + Dependabot.logger.info("Detected python major minor version: #{language_version_manager.python_major_minor}") + end + language_version_manager.python_version end @@ -333,7 +341,7 @@ def pipcompile_in_file end def pipenv_files - requirement_files.any?(PipenvPackageManager::MANIFEST_FILENAME) + dependency_files.any? { |f| f.name == PipenvPackageManager::LOCKFILE_FILENAME } end def poetry_files diff --git a/python/lib/dependabot/python/package_manager.rb b/python/lib/dependabot/python/package_manager.rb index 98da0cf2c8..21ba731da9 100644 --- a/python/lib/dependabot/python/package_manager.rb +++ b/python/lib/dependabot/python/package_manager.rb @@ -130,6 +130,7 @@ class PipenvPackageManager < Dependabot::Ecosystem::VersionManager NAME = "pipenv" MANIFEST_FILENAME = "Pipfile" + LOCKFILE_FILENAME = "Pipfile.lock" SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) diff --git a/python/lib/dependabot/python/update_checker.rb b/python/lib/dependabot/python/update_checker.rb index af874e2d47..75dbc78750 100644 --- a/python/lib/dependabot/python/update_checker.rb +++ b/python/lib/dependabot/python/update_checker.rb @@ -113,6 +113,10 @@ def fetch_lowest_resolvable_security_fix_version end def resolver + if Dependabot::Experiments.enabled?(:enable_file_parser_python_local) + Dependabot.logger.info("Python package resolver : #{resolver_type}") + end + case resolver_type when :pip_compile then pip_compile_version_resolver when :pipenv then pipenv_version_resolver