On Wed, Jan 28, 2009 at 6:21 PM, Eric Wilhelm <[email protected]>wrote:

>
>
> >To this:
> >    maybe_requires => {
> >      'Win32API::File' => [ 0.11, $^O eq 'MSWin32' ]
> >    }
>
> I think I would rather express that 'eq' check as data.
>

Well, yes, we all would, but that's not how it works today.  Part of the
reason we have a *.PL file for configuration is to enable a wide variety of
programmatic checks that can't all be designed into a data structure.  So
short of enhancing META.yml with massive generic conditional requirements
logic, I'm suggesting the somewhat opposite step of at least making sure
that things that are dynamically determined to be requirements get held out
of the 'requires' section.

On that basis, I would want to see M::B support this:

    maybe_requires => {
      'Win32API::File' => [ 0.11, \&_arbitrary_check ]
    }

Let people keep writing whatever code they want into Build.PL, but just help
them structure it in a way that more clearly delineates absolute versus
conditional requirements in the META.yml file.


>
> >Then when Build.PL is run, if the condition is satisfied,
> > Win32API::File would get included among requirements, but when
> > META.yml is generated, it's included in the 'maybe_requires' section,
> > not the 'requires' section.
>
> Here's where I'm not following what you want to do to the existing
> META.yml.  Are you saying the consumer is going to directly use
> $condition to decide if it needs the module?


Not at all.  It should be an error to have a 'maybe_requires' section in
META.yml and also have 'dynamic_config: 0'.  But there are non-installation
consumers that might be able to usefullly consume 'maybe_requires'
information.  E.g. search.cpan.org could include them in a list 'related
modules' or CPANTS could include them in determining what things are
prerequisites of other things.

Right now, anything dynamic that isn't required on the author's computer is
just left out of the META.yml entirely and we lose that information.  I'm
proposing we fix that.

So what happens to META.yml?  In the example I gave, this is what should be
generated:

    requires:
      perl: 5.006
      Sub::Uplevel: 0
    maybe_requires:
      Win32API::File: 0.11

It ignores the conditional and just writes the requirement into the
maybe_requires section.  (But _build/prereqs gets built based on how the
conditionals actually resolve.)

When we start generating MYMETA.yml files when running Build.PL, if the user
is on Win32, they get this:

    requires:
      perl: 5.006
      Sub::Uplevel: 0
      Win32API::File: 0.11

But if they aren't on Win32, they get this:

    requires:
      perl: 5.006
      Sub::Uplevel: 0

All that 'maybe_requires' indicates in META.yml is that these are
requirements that may or not apply and that can only be resolved by running
Build.PL or Makefile.PL.

-- David

Reply via email to