Skip to content

Loading…

Grab deps from cpanfile if there is no META.(yml|json) #213

Closed
wants to merge 2 commits into from

2 participants

@tokuhirom

When installing module from repository, cpanm grab deps from cpanfile, and install configure_requires.

It makes happy to install modules from git.

ref. #212

@miyagawa
Owner

The patch itself looks good, but for Module::Install, it's a little weird that you add Module::Install to configure_requires since if it's shipped to CPAN that way, CPAN installers will install Module::Install, even if it is included in inc/.

Probably the right behavior is to install devel dependencies in the dev mode (i.e. have .git/ directory, or dist.ini or whatever) before running configure.

This again boils down to the same problem with #205

@tokuhirom

Added devel deps installer code.

@miyagawa
Owner

Closing this for now.

@miyagawa miyagawa closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 3 deletions.
  1. +21 −3 lib/App/cpanminus/script.pm
View
24 lib/App/cpanminus/script.pm
@@ -1687,9 +1687,23 @@ sub build_stuff {
$dist->{meta} = $self->parse_meta('META.yml');
}
- if (!$dist->{meta} && $dist->{source} eq 'cpan') {
- $self->chat("META.yml/json not found or unparsable. Fetching META.yml from search.cpan.org\n");
- $dist->{meta} = $self->fetch_meta_sco($dist);
+ if (!$dist->{meta}) {
+ if ($dist->{source} eq 'cpan') {
+ $self->chat("META.yml/json not found or unparsable. Fetching META.yml from search.cpan.org\n");
+ $dist->{meta} = $self->fetch_meta_sco($dist);
+ } else {
+ if (-e 'cpanfile') {
+ $self->chat("META.yml/json not found or unparsable. Checking configure dependencies from cpanfile\n");
+
+ require Module::CPANfile;
+ my $cpanfile = eval { Module::CPANfile->load('cpanfile') };
+ if ($cpanfile) {
+ $dist->{meta} = +{
+ prereqs => $cpanfile->prereq_specs
+ };
+ }
+ }
+ }
}
$dist->{meta} ||= {};
@@ -1701,6 +1715,10 @@ sub build_stuff {
push @config_deps, %{$dist->{meta}{configure_requires} || {}};
}
+ if ( $dist->{source} ne 'cpan' && $dist->{meta}{prereqs}{devel}{requires} ) {
+ push @config_deps, %{$dist->{meta}{prereqs}{devel}{requires} || {}};
+ }
+
my $target = $dist->{meta}{name} ? "$dist->{meta}{name}-$dist->{meta}{version}" : $dist->{dir};
$self->install_deps_bailout($target, $dist->{dir}, $depth, @config_deps)
Something went wrong with that request. Please try again.