package CPAN;

package MYCPAN;
use File::Spec;

use strict;
use warnings;

( my $dir = $INC{'CPAN.pm'}) =~ s/CPAN\.pm//;
$dir = File::Spec->canonpath( $dir );

# this bogosity is here to fool Module::Metadata just enough that the
# tests for Dist::Zilla::Plugin::DynamicPrereqs passes.
our $VERSION;
$CPAN::VERSION = do { require CPAN; delete $INC{'CPAN.pm'}; $CPAN::VERSION; };

{
    local @INC = grep { File::Spec->canonpath($_) ne $dir } @INC;
    delete $INC{'CPAN.pm'};
    require CPAN;
}

local @INC = @INC;

# newer CPAN::HandleConfig's have cpan_home() rather than home()
unshift @INC,
   CPAN::HandleConfig->can( 'home' )       ? File::Spec->catdir( CPAN::HandleConfig::home(), '.cpan' )
 : CPAN::HandleConfig->can( 'cpan_home' )  ? CPAN::HandleConfig::cpan_home()
                                              : ();

eval { require CPAN::MyConfig;
       require CPAN::MyConfigOverride };

1;
