Re: Change in order of PREREQ_PM and CONFIGURE
[email protected] (Michael G Schwern)
| Newsgroups | perl.makemaker |
|---|---|
| Message-ID | <[email protected]> |
Martin Evans wrote:
> Apologies for bothering you but I am not sure if this is a bug so did
> not want to rtpan it.
Thanks for that, but it's actually more of a bother this way and I encourage
folks to report first, and worry about whether or not it's actually a bug later.
Takes more effort to make a ticket then to close one, I'd rather have the
not-a-bug discussion on record in the tracker.
> Between ExtUtils::MakeMaker 6.32 and 6.33 the order that CONFIGURE is
> run has changed from after PREREQ_PM to before PREREQ_PM.
I love reading bug reports about MakeMaker because I learn about these
surprising new features. :) I had no idea about CONFIGURE.
> I don't think
> it can be classed as a bug since the pod does not specifically say
> CONFIGURE is run after PREREQ_PM. This causes me a problem as I was
> using a require in CONFIGURE sub which was also in PREREQ_PM so
> PREREQ_PM would error if the required module was not found (and hence
> not cause a failure on cpan-testers). Since 6.33 the require in
> CONFIGURE fails which causes a cpan-testers failure. The thread on
> cpan-testers-discuss where this came about is:
>
> http://www.mail-archive.com/cpan-testers-discuss%40perl.org/msg00076.html
>
> and my specific code is:
>
> $opts{PREREQ_PM} = { "DBI" => 1.21 };
> $opts{CONFIGURE} = sub {
> require DBI::DBD;
> my $dbi_arch_dir = dbd_dbi_arch_dir();
> if (exists($opts{INC})) {
> return {INC => "$opts{INC} -I$dbi_arch_dir"};
> } else {
> return {INC => "-I$dbi_arch_dir"};
> }
> };
> }
>
> My module needs DBI installing first because of the call to
> dbd_dbi_arch_dir() above which I need to change INC. I was relying on
> PREREQ_PM failing before CONFIGURE was run.
This is one of those interesting "that doesn't work... and never should have
worked" situations. The CONFIGURE and PREREQ_PM logic haven't been touched in
years. And it shouldn't work anyway because whether or not the CONFIGURE is
run before or after PREREQ_PM, dependencies aren't resolved until after the
whole Makefile.PL is run.
I see the missing piece is that you were using PREREQ_FATAL. Yes, that did
move in 6.33. I didn't log why, it was part of some changes to the
PREREQ_FATAL docs and message. The code move doesn't look like it was
necessary. I guess I can move it back.
But I don't know if it will help. I know neither CPAN nor CPANPLUS do
anything with a PREREQ_FATAL message. They're left with no Makefile, so it's
going to fail anyway. Maybe CPAN::Reporter has special logic for that?
As mentioned in the thread, configure_requires is the proper way to handle
this. At the moment there is no documented way to do this in MakeMaker, but
Module::Build can do it. Also while CPAN supports it, CPANPLUS still doesn't
support it.
Welcome to one of the nasty little bits of CPAN. We're working on it.
--
Stabbing you in the face so you don't have to.