package Dist::Zilla::Plugin::Prereqs::EnsurePP;

our $DATE = '2016-02-19'; # DATE
our $VERSION = '0.09'; # VERSION

use 5.010001;
use strict;
use warnings;

use Moose;
with 'Dist::Zilla::Role::InstallTool';

use App::lcpan::Call qw(call_lcpan_script);
use Module::Path::More qw(module_path);
use Module::XSOrPP qw(is_pp);
use namespace::autoclean;

sub setup_installer {
    my ($self) = @_;

    my $prereqs_hash = $self->zilla->prereqs->as_string_hash;
    my $rr_prereqs = $prereqs_hash->{runtime}{requires} // {};

    $self->log(["Listing prereqs ..."]);
    my $res = call_lcpan_script(argv=>[
        "deps", "-R",
        grep {$_ ne 'perl'} keys %$rr_prereqs]);
    my $has_err;
    for my $entry (@$res) {
        my $mod = $entry->{module};
        $mod =~ s/^\s+//;
        next if $mod eq 'perl';
        if (!module_path(module=>$mod)) {
            $self->log_fatal(["Prerequisite %s is not installed", $mod]);
        if (!is_pp($mod)) {
            $self->log(["Prerequisite %s is not PP", $mod]);

    if ($has_err) {
        $self->log_fatal(["There are some errors in prerequisites"]);

# ABSTRACT: Make sure that prereqs (and their deps) are all PP modules



=encoding UTF-8

=head1 NAME

Dist::Zilla::Plugin::Prereqs::EnsurePP - Make sure that prereqs (and their deps) are all PP modules

=head1 VERSION

This document describes version 0.09 of Dist::Zilla::Plugin::Prereqs::EnsurePP (from Perl distribution Dist-Zilla-Plugin-Prereqs-EnsureCoreOrPP), released on 2016-02-19.


In dist.ini:



This plugin will check that all RuntimeRequires prereqs (and all their recursive
RuntimeRequires deps) are all PP modules. To do this checking, all prereqs must
be installed during build time and they all must be indexed by CPAN. Also, a
reasonably fresh local CPAN mirror indexed (produced by L<App::lcpan>) is

I need this when building a dist that needs to be included in a fatpacked

Note: I put this plugin in setup_installer phase instead of before_release
because I don't always use "dzil release" (i.e. during offline deployment, I
"dzil build" and "pause upload" separately.)

=for Pod::Coverage .+


Please visit the project's homepage at L<>.

=head1 SOURCE

Source repository is at L<>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired

=head1 SEE ALSO

L<App::FatPacker>, L<App::depak>


Related plugins: L<Dist::Zilla::Plugin::CheckPrereqsIndexed>,

L<App::lcpan>, L<lcpan>

=head1 AUTHOR

perlancar <>


This software is copyright (c) 2016 by

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.