Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

loading libxml2 as a prerequisite

by jandrew (Chaplain)
on Nov 19, 2014 at 00:55 UTC ( [id://1107680]=perlquestion: print w/replies, xml ) Need Help??

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

All,

I have recently loaded a package to CPAN Spreadsheet::XLSX::Reader::LibXML. The package is built on XML::LibXML which requires the libxml2 library in order to build successfully. Strangely this seems to come packaged with the OS for Windows but not for Unix or Linux OS's. I'm wondering if there is a good way to require libxml2 and it's dev package to load on non-windows systems through Makefile.PL magic with a Dist::Zilla plugin, ExtUtils::MakeMaker, or Module::Build in order to auto build this package from CPAN(M|P). I first noticed this issue when I wasn't getting many test reports from Linux / Unix systems in the CPAN Testers page.

I did get access to a Linux system and installed Alien::LibXML through CPANP and then tried to install XML::LibXML again and failed. I then installed libxml2 and libxml2-dev with the linux package installer and went back and installed XML::LibXML with no problems. (I also installed my own package with only minor problems hence the roll to v0.10.6)

I am not a strong ExtUtils::MakeMaker or Module::Build user so I have relied heavily on Dist::Zilla++ and friends to get my modules out in the past. I will knuckle down and read what I need to but I'm not quite sure where to start. If it were as simple as requiring Alien::LibXML I might have tried to muddle through but I think I'm out of my depth here. Pointers on where to start would be greatly appreciated!

Replies are listed 'Best First'.
Re: loading libxml2 as a prerequisite
by Anonymous Monk on Nov 19, 2014 at 01:03 UTC

    If it were as simple as requiring Alien::LibXML I might have tried to muddle through but I think I'm out of my depth here. Pointers on where to start would be greatly appreciated!

    Yes, it is that simple, depend on XML::LibXML in your module and Makefile.PL (or equivalent) and you're done

    Yes, you could go ahead and also depend on Alien::LibXML in your Makefile.PL (or equivalent), since someone was kind enough to create Alien::LibXML ... but you shouldn't trouble yourself about it :)

    Other than this there is nothing to do

    Well, you could simply provide apt-get installable binary package which declares all the right dependencies ... Re: How to release a precompiled XS module? (apt-get repository) ... but thats not CPAN stuff :)

    loaded is not uploaded or downloaded, its not that loaded, and ATM I'm not loaded either

      As mentioned in the "Steps attempted to resolve the problem" neither XML::LibXML or Alien::LibXML doesn't 'just install' in Linux without the libxml2 packages pre-installed. I already had a dependency on XML::LibXML in my Makefile.PL and when I CPAN pre-installed Alien::LibXML with CPAN I still couldn't get XML::LibXML to install via CPAN. I looked at your link but it seems to be instructions on how to build a Debian package. I would prefer to stick with CPAN.

      Update: I am using perlbrew on an AWS Linux server for my Linux text. Any chance that might cause problems?

      Update2: Alien::LibXML does 'just install' it just doesn't provide any libraries that XML::LibXML can find. It looks like the Docs I was looking for are Alien::Base::Authoring

        As mentioned in the "Steps attempted to resolve the problem" XML::LibXML won't 'just install' in Linux or Unix without the libxml2 packages pre-installed.

        This was clear, but why are you concerned ?

        :) You don't release XML::LibXML or Alien::LibXML , so its not really any of your business :)

        As mentioned in the "Steps attempted to resolve the problem" Alien::LibXML won't 'just install' in Linux or Unix without the libxml2 packages pre-installed.

        I kind of doubt that :)

        If Alien::LibXML doesn't install libxml2, report a bug, but I think it does install libxml2, just look at https://metacpan.org/source/TOBYINK/Alien-LibXML-0.003/Build.PL

        Also, like the docs say, XML::LibXML currently makes no use of Alien::LibXML, so report a bug in XML::LibXML?

        Yeah, looks like even if you install Alien::LibXML XML::LibXML won't know anything about it ... standard way you as a user can let it know is through Makefile.PL args INC=/LIB=

        Most modules on CPAN do not have a corresponding Alien:: library, and its been that way for most of the history of CPAN ... that a user has to  apt-get install.. before he can cpan SomeModule is kind of a FAQ

        So, as maintainer of Spreadsheet::XLSX::Reader::LibXML, there is nothing for you to do, maybe improve your docs to explain the appropriate apt-get steps ...

        You could at an utils/installlibxml2.pl to help you out your users, but this stuff doesn't belong in your Makefile.PL, each cpan author takes care of his own distribution

        I almost forgot, you could always fork XML::LibXML to use Alien::LibXML and release that on cpan, and submit a feature request ... see upload a fork (unauthorized version),

         

        Hopefully that is clear :)

      Yes, you could go ahead and also depend on Alien::LibXML in your Makefile.PL (or equivalent), since someone was kind enough to create Alien::LibXML ... but you shouldn't trouble yourself about it :)

      Yup, you could, but XML::LibXML itself doesn't , so I wouldn't bother :)

Re: loading libxml2 as a prerequisite
by sundialsvc4 (Abbot) on Nov 19, 2014 at 13:05 UTC

    I think that the only thing which you can realistically do is to document the requirement.   Put the prerequisite Perl package into the dependency list for yours, but tell the Gentle Reader that it is important that the underlying .so or .dll files be present.   cpan will recognize the prerequisite and attempt to install XML::LibXML if it isn’t there yet, but most-unfortunately that install might not be successful and there might be nothing that the (non-Administrative) user can actually do about it.   Some [Perl] installers react graciously when an underlying binary library isn’t there; others fall-down into a tangled heap of smelly ones and zeros.   Generally speaking, none of them can actually be expected to install the library.   So, I think, you need to voice the issue very clearly in your package documentation, including a discussion of what the Gentle Reader may expect (and that he might need to call the I.T. department).

      sundialsvc4 Thank you, I had overlooked adding this to the documentation near term till I get this resolved.

      Long term the documents should probably warn of the installation of the underlying library libxml2. (when I get it to work)

Re: loading libxml2 as a prerequisite
by jandrew (Chaplain) on Nov 19, 2014 at 13:13 UTC

    Since it appears that the journey here leads down the road of a better Alien::LibXML does anyone have a suggestion of an Alien::XXX module that represents best practice?

    I am starting by reading Alien::Base::Authoring and family but in the past I have always found the most success if I also beg, borrow, steal from good samples when I enter a new area of study. My preference would be something that uses the Alien::Base ecosystem so I can leverage the reading and borrowing together.

    In this case I mostly need the Linux / Unix side to work better so that would be another 'nice to have' when I borrow.

      It's not the fault of Alien::LibXML. It installs libxml and, if asked, supplies the location. The problem is that nobody is asking. (Alien::LibXML can't simply install libXML in, for example, /usr/lib, because it doesn't have the authority to do so. Also, different distros put libraries in different places and/or might have an older version the distro needs.)

      Even when your module says it depends on Alien::LibXML and XML::LibXML, the cpan installer doesn't automatically tell each module it's installing about any other modules. If a module needs information about other modules, it has to get that information itself.

      In the case of XML::LibXML, if it's Build.pl (or whatever it uses) can't find libxml, it could then try to require Alien::LibXML. If that succeeds, it could then ask Alien::LibXML where libXML is.

      Update: However, I don't think there's a way to make a conditional dependency. If libxml were already installed, Alien::LibXML could skip installing it (unless the user specified otherwise), Alien::LibXML itself would still get installed if listed as a dependency by another module.

        As I mentioned in my first post this question has taken me down a path in perl that I rarely travel. (That is a good thing) I would like to thank the monks for their general patience.

        On the resolution front it appears that the root cause of my initial issue is that the libxml2-dev libraries also need to be installed incremental to the libxml2 libraries in order for XML::LibXML to be installed. I am now in the process of figuring that out.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found