Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Dependent Package Requirement

by jandrew (Chaplain)
on May 18, 2016 at 18:56 UTC ( [id://1163366]=perlquestion: print w/replies, xml ) Need Help??

jandrew has asked for the wisdom of the Perl Monks concerning the following question:

I have a package that depends on Archive::Zip and for most cases that seems to work. For netbsd and a few other cases though it doesn't work. I would like to provide alternate support unzipping files with Corions newish module Archive::SevenZip. I know how to test for either in the package and use the one that is loaded. I also know how to set up testing that will test either case. I just don't know/remember how to set up the dependencies for Makefile.PL and META.yml. I would like the package to build and test if either Archive::Zip or Archive::SevenZip will build/install but not require both.

I would especially like to accomplish this with Dist::Zilla if possible. Any help is greatly appreciated.

Update: I realized I didn't say this explicitly but I do want the prerequisites to fail if neither Archive::Zip or Archive::SevenZip will build successfully.

Replies are listed 'Best First'.
Re: Dependent Package Requirement
by RonW (Parson) on May 19, 2016 at 19:29 UTC

    If I understand you correctly, you want to package your module in a way that an attempt to install it won't also automatically cause either Archive::Zip or Archive::SevenZip to be installed, unless neither is already installed.

    From looking at http://search.cpan.org/~dagolden/CPAN-Meta-2.150005/lib/CPAN/Meta/Spec.pm, I think the best you can do is make both optional ("recomends"), then have a test to make sure one of those is available.

    You might be able to add code to Makefile.PL before the line with WriteMakefile, but I don't know how you could then get either archiver installed from there. Maybe you could do system 'cpan Archive::Zip';

    Update: Looked again and found 1140942. Seems it is possible to modify MakeFile.PL to munge the prereqs.

      RonW++ Thanks for replying. You have it right. Mostly I wouldn't ask but I know that at least one platform and several perl configurations fail to install Archive::Zip even though for now it is the preferred module to implement. The conundrum is how to succeed in the face of an imperfect module dependency.

      I was afraid that might be the answer. I'm planning on running some tests in a branch and see what I can get to happen in Travis-CI but I'm afraid it might take a hack on the cpan or cpanm apps to accomplish what I want. I will post to this thread as I have results but I have to get the test suite and module ready first so it will take several days before I know what won't work for sure.

        After looking some more, I found 1140942. Looks like you could add more prereqs. See stevieb's sample MakeFile.PL in that post.

        Depending on the return value of WriteMakefile, you might even be able to try Archive:Zip first, then Archive::SevenZip

Re: Dependent Package Requirement
by Anonymous Monk on May 18, 2016 at 22:46 UTC
    WriteMakefile() is a function that takes args :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1163366]
Approved by dorko
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found