Skip to content

Conversation

@NicholasBHubbard
Copy link
Contributor

@NicholasBHubbard NicholasBHubbard commented Nov 14, 2025

This PR aims to solve issue #2124.

Here is a link to the metacpan api url that is currently used, searching a module Dist::Zilla (whos distribution provides many modules): https://fastapi.metacpan.org/v1/module/Dist::Zilla . Notice that there is no field for provided modules. If instead we search for a release of the Dist-Zilla distribution, we see a long list of provided modules under the provides field: https://fastapi.metacpan.org/v1/release/Dist-Zilla .

I created a function search_provided_modules() that finds all the provided modules of some version of some distribution. This function is instead used to set the self.provides field in the input() function. The release api does not show the provided modules versions, so I used different but equivalent logic to search the module api for all modules that belong to the given distribution version. This allows us to also determine the module version (which isn't necessarily) the same as the distribution version.

While I was at it I updated the search() function, renaming it search_module(), and added an optional parameter to specify which version of the module to search. The HTTP GET method for the metacpan api url that was being used only finds the latest version of the module. To find a specific version, I updated the code to use the HTTP POST method for the metacpan api that allows for more powerful queries. The query I used is the same except that if the version parameter is defined it queries for that specific version of the module instead of the latest version.

Another thing worth noting is that I found that we had an unused variable named dep that was defined in the input() function, and was created by a call to search(). I deleted this variable. Here is a link to the variable definition.

I added new tests to cpan_spec.rb for this new search_provided_modules() function, and also updated an exisiting test to check self.provides after calling input().

Issue #2124 showed that currently fpm did not find the correct provided modules. Here are the same commands that were given in the issue, showing that this PR fixed the problem (cut off as there are over 140 entries):

$ bin/fpm --debug-workspace --no-cpan-test -s cpan -t rpm Dist::Zilla
$ grep 'Provides:' /tmp/package-rpm-build-8625b072deccf5d9b8aa3f85dadafd6df946c124a6f05347ad7f2d541059/SPECS/perl-Dist-Zilla.spec
Provides: perl(Dist::Zilla) = 6.036
Provides: perl(Dist::Zilla::App) = 6.036
Provides: perl(Dist::Zilla::App::Command) = 6.036
Provides: perl(Dist::Zilla::App::Command::add) = 6.036
Provides: perl(Dist::Zilla::App::Command::authordeps) = 6.036
Provides: perl(Dist::Zilla::App::Command::build) = 6.036
Provides: perl(Dist::Zilla::App::Command::clean) = 6.036
Provides: perl(Dist::Zilla::App::Command::install) = 6.036
Provides: perl(Dist::Zilla::App::Command::listdeps) = 6.036
Provides: perl(Dist::Zilla::App::Command::new) = 6.036
Provides: perl(Dist::Zilla::App::Command::nop) = 6.036
...

@wbraswell
Copy link
Contributor

@jordansissel
As usual, I have reviewed and approved this PR before it was submitted by @NicholasBHubbard .
Thanks in advance! :-)

@wbraswell
Copy link
Contributor

@jordansissel
This is currently our second-most-important PR to get merged as soon as possible, because it is blocking us from fixing other downstream bugs. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants