Alien::Base is almost ready
Not too long ago I mentioned on this blog that Alien::Base had reached a milestone, well today I’m announcing that its getting even closer.
Before I get there lets recap. The Alien namespace contains modules which provide external libraries to Perl modules. Alien:: modules typically can detect the presence of a library on your system or if not, install it. Then they can provide the locations and other information to the Perl modules that need them. Alien::Base aims to make these modules easier to write by providing most of this functionality in a configurable way.
Alien::Base, once it has decided that a computer does not have the library, will try to install it. One of my biggest concepts in designing Alien::Base is where it installs the library to. In contrast to attempting to install it to the system-at-large, it puts it in a static data location relative to the Alien:: module in question; it does this via File::ShareDir. Why is this important? Several reasons:
- It can be done without root privileges
- It respects perlbrew/local::lib
- It doesn’t unexpectedly change your system
For me number 3 is the most important. When installing a Perl module I don’t expect that there will be effects to the system outside of the Perl directory. This does bring a few drawbacks:
- Counter to #2 above, each installed Perl will need a separate copy of the library
- While satisfying the compile-time dependency is easy, satisfying the run-time dependency is hard
Yes #1 can be annoying if a large library is needed for multiple Perls. A workaround would be to manually install the library system-wide (via apt for example). Another that is planned is to add support for the new local::c project which brings local::lib-like functionality for C libraries.
Today’s news is that #2 has been fixed! Alien::Base now accomplishes this by appending to your $ENV{LD_RUN_PATH}
just in time to load the library. This will mean a slight change to the mechanism of use of the Alien:: module. The dependent module will now need to explicitly import
the Alien:: module.
package Some::Module::UsesMyLibrary;
use strict;
use warnings;
# this line now required for Alien::Base based modules
use Alien::MyLibrary;
require XSLoader;
XSLoader::load();
# your code
1;
In the past Alien:: modules have relied on system-installation, static libraries or rpath to do this work, but this mechanism seems to be simple and effective.
This was the last big hurdle to Alien::Base, so now I can (pretty) safely say, “Alien::Base is coming!” I had hoped to announce this when I first released Alien::Base, but some other functionality if taking longer than anticipated.
I expect a pre-alpha release to come soon, perhaps even this week. When I see that CPANtesters approves, I will then release the alpha version, at which point I will make a call for libraries which need wrapping, so keep that in mind; start thinking of those unwritten Alien:: modules you have always wished for; Alien::Base is going to empower YOU to create them!
Well, I have been pondering if I should put together Alien::OpenSSL and it looks like your work will make that much simpler. So, I’ll definitely try it.
Keep up the good work :-)
Sounds excellent! ++
This is excellent. Installing the run-time dependency from source will mean that it will be easier to create DWIM Perl for Linux and include all the C libraries needed to use LibXML or other such modules. Math::Pari maybe?
Have you talked to the people who are packaging CPAN modules for the various Linux distributions? I mean Debian, Fedora, and Mandriva.
It would be nice to make sure Alien::Base makes it easy to package the Alien::* modules as empty dependencies on the already packaged external libraries.
I was dubious about integrating relevant C code stuff from Potrace, but now it seems that I can just wait a few days and try to set up an Alien::Potrace library instead!
@All, thanks for the kind words! @Gabor, I have been thinking about how Alien::Base-based modules will work with package managers. I think that this shouldn’t be too hard; all that will be needed is the Alien/Base.pm, Alien/MyLibrary.pm and the Alien/MyLibrary/ConfigData.pm which will need to be tailored to the system install. Once the system is fully functional I will definitely be looking into this. And thanks for the mention in the PerlWeekly too!
This is very exciting!
Keep up the good work!! :)
This sounds fantastic. I have dabbled with Alien:: modules in the past for wxWidgets and SDL, and wondered whether it wouldn’t be a good idea to abstract out all all that cross-platform dependency stuff and make it easy. You’re a hero!