Hey everyone -
I sense two basic approaches here. There is the "use package managers"
group and the "make it install everywhere via CPAN" group. Personally I
love package managers and I try to use them whenever I can. Sometimes I
can't. Sometimes I'm on a restricted Linux box, other times I'm on a
Windows machine. (Aside: for Windows, I just discovered
Chocolatey<http://chocolatey.org/>while writing this. Maybe we *could*
focus on package managers for
everything.)
The whole point of Alien modules is that some distributions, like Padre,
have *tons* of CPAN dependencies. Some of those dependencies rely on
external libraries (i.e. wxWidgets). Before the concept of Alien modules,
you would say "cpan Padre", come back after 30 minutes and curse that the
build process died two minutes in because the development headers needed
for wxWidgets weren't installed. You'd install libraries, re-invoke "cpan
Padre", come back after thirty minutes, and break your mug because the
build process died *again* at some other dependency. Even on Linux systems
this is a pain in the neck (and it's morel likely to occur on Linux
systems, since you're unlikely to have your X11 development headers
installed).
Ultimately, I disagree with Dima's characterization of our users. I think
we need to consider our users just like FireFox does. Some users like to
install Add-ons to FireFox. In the same way, some users like to install
Perl modules from CPAN. But we should see our CPAN consumers as *users*,
not *developers*, just like FireFox Add-on users are not developers,
either. "Users" just want the damn thing to install so they can get on with
surfing the web, or building a website, or performing their data analysis.
If installation isn't super-simple, *they'll never share it with their
friends*.
Having written Alien::TinyCC so that it Just Works on The Big Three
platforms, I have developed a few opinions.
@debian folks and other package managers: Including separate
libper-alien-XXX packages leads to large package lists. One solution is to
just put the requisite Alien::XXX module in the *development* version of
the upstream package. But of course that sets an arguably bad precedent to
include such build info for *all* languages in *all* dev packages. But this
is really an aside. Perl modules like PDL have to be oriented for
cross-platform distribution.
@dll hell: When Joel was working on Alien::Base, he convinced me of the
idea that Alien modules should *never* install their libraries to any
system-wide location. Instead, your Alien module should (1) ensure that the
library is available, (2) provide compile-time flags for EU::MM, M::B, etc,
and finally, (3) *provide a run-time module to be invoked by consuming
modules that prepares the environment*. I just realized while typing this
that the third point is not part of the Alien manifesto, but I think it
should be. Let me illustrate with an example of how I avoid dependency hell
using this system.
Alien::tcc ensures that you have a working copy of the Tiny C Compiler on
your system. Amusingly, it breaks rule 1 by always installing tcc, because
I hacked it out quickly and didn't want to handle detection issues.
However, it puts tcc in your File::ShareDir location. For example, since I
use perlbrew on a Mac, this installs the tcc compiler and all the headers
and libraries to
"$HOME/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/auto/share/dist/Alien-TinyCC/"
Let me assure you there is no way to accidentally load those shared
objects! (On a side-note, as far as I am aware, File::ShareDir does not
provide architecture-dependent sharedir locations. This is a problem when
you have machines with different architectures using NFS. And you happen to
install an Alien module on said NFS. Yes, I know from experience.)
"But," you ask, "if you build an XS module against libtcc, how could
Dynaloader possibly find the .a or .so or .dll or .dylib or whatever files?
In Windows, for example, the dynamic library loader searches %PATH% for the
requested library file. On Linux, the $LD_LIBRARY_PATH needs to contain
this info." That's a good question, and I'm glad you asked. The solution to
this problem is to let the package Alien::TinyCC modify your PATH or
LD_LIBRARY_PATH environment variable so that the crazy-long Perl-specific
path *is* in the correct variable. Thus, if your XS module uses libtcc,
your Perl module file (.pm file) must contain the line "use Alien::TinyCC"
before calling Dynaloader (or XSloader). No matter what, installing tcc to
your system won't break Alien::TinyCC, and Alien::TinyCC won't break your
locally installed tcc.
@debian folks: Consider what I just pointed out. If an Alien module is
designed to install its local copy of the library to the File::ShareDir,
then it must provide runtime hooks to properly prepare the environment. Of
course, there's no need for Debian's Alien::XXX to be a replica of the
original: It could provide its own runtime module that properly sets up
everything to link against the system library.
Longwinded as always. Sorry. But I hope this adds some useful perspective
to why I like to do Alien modules this way.
David
P. S. There is a way to use pkgconfig everywhere: we could for example
provide Alien::pkgconfig! Then the Alien modules could depend on it, and
reliably use pkg-config on all platforms. But the Alien author would still
have to ensure the pkg-config works, and user would still have to install
the libraries separately, which defeats the whole point of Alien modules.
Post by Zakariyya MughalPost by Chris MarshallThey apparently use binary distribution sites, instructions for users
on systems with package managers, and binaries+instructions for poor
http://www.scipy.org/install.html
Yes, exactly. To elaborate, the approach they've used to avoid the
complexity of compilers, build options, and conflicting system libraries
is to make the Conda package manager that distributes all of the binary
dependencies (roughly equivalent to apt-get, yum for multiple OSes)[^1].
There was actually a conversation on Reddit comparing Conda to pip (the
normal way of installing packages) just yesterday that that got a
response from several of the core SciPy developers[^2].
[1]: <http://docs.continuum.io/anaconda/pkgs.html>, <
http://www.continuum.io/blog/conda>, <
http://technicaldiscovery.blogspot.com/2013/12/why-i-promote-conda.html>.
[2]: <
http://www.reddit.com/r/Python/comments/1vled5/anaconda_seems_to_have_a_nicely_set_up_library/
Regards,
- Zaki Mughal
_______________________________________________
PDL-porters mailing list
http://mailman.jach.hawaii.edu/mailman/listinfo/pdl-porters
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." -- Brian Kernighan