diff --git a/Library/Homebrew/test/utils/pypi_spec.rb b/Library/Homebrew/test/utils/pypi_spec.rb index 021a2215c8..20f423df52 100644 --- a/Library/Homebrew/test/utils/pypi_spec.rb +++ b/Library/Homebrew/test/utils/pypi_spec.rb @@ -22,6 +22,7 @@ describe PyPI do let(:package_with_different_version) { described_class.new("snakemake==5.29.0") } let(:package_with_extra) { described_class.new("snakemake[foo]") } let(:package_with_extra_and_version) { described_class.new("snakemake[foo]==5.28.0") } + let(:package_with_different_capitalization) { described_class.new("SNAKEMAKE") } let(:package_from_url) { described_class.new(package_url, is_url: true) } let(:other_package) { described_class.new("virtualenv==20.2.0") } @@ -146,6 +147,10 @@ describe PyPI do it "returns true for the same package with different versions" do expect(package_with_version.same_package?(package_with_different_version)).to eq true end + + it "returns true for the same package with different capitalization" do + expect(package.same_package?(package_with_different_capitalization)).to eq true + end end describe "<=>" do diff --git a/Library/Homebrew/utils/pypi.rb b/Library/Homebrew/utils/pypi.rb index 8473c38f51..68cbc5f699 100644 --- a/Library/Homebrew/utils/pypi.rb +++ b/Library/Homebrew/utils/pypi.rb @@ -91,7 +91,7 @@ module PyPI sig { params(other: Package).returns(T::Boolean) } def same_package?(other) - @name.tr("_", "-") == other.name.tr("_", "-") + @name.downcase.tr("_", "-") == other.name.downcase.tr("_", "-") end # Compare only names so we can use .include? on a Package array @@ -231,7 +231,7 @@ module PyPI end # Remove extra packages that may be included in pipgrip output - exclude_list = %W[#{main_package.name.downcase} argparse pip setuptools wheel wsgiref].map { |p| Package.new p } + exclude_list = %W[#{main_package.name} argparse pip setuptools wheel wsgiref].map { |p| Package.new p } found_packages.delete_if { |package| exclude_list.include? package } new_resource_blocks = ""