The Perl/Alien Blog

Here are some blog entries related to Perl and Alien.

The many ways to use Alien

By Graham Ollis on 13 June 2017

A while back I introduced the alienfile recipe system and we wrote a simple alienfile that provides in a CPAN context the tool xz and the library liblzma. I also went over how to test it with App::af. The week after that I showed how to integrate that alienfile into a fully functioning Alien called Alien::xz and promised to show how to then use that Alien from an XS or FFI module. Today I am going to do that. I am also going to show how to use a tool oriented Alien module. (conveniently, Alien::xz can be used in either library or tool oriented Alien mode). If you are more interested in FFI or tool oriented mode feel free to skip down to the appropriate paragraph.

First, lets suppose we have a very simple XS and Perl module that gives us the version of liblzma. This admittedly doesn't do anything very useful without the rest of the library, but it will help us test the basics of how to call a library that has been alienized. (if you need real LZMA support you should probably use IO::Compress::Lzma of course).

... read more

Integrating alienfile

By Graham Ollis on 4 April 2017

Last week I introduced the alienfile recipe system and we wrote a simple alienfile that provides the tool xz and the library liblzma. I also showed how to test it using App::af. Today we are going to take that alienfile and integrate it into a fully functional Alien distribution.

The main motiviation for alienfile + Alien::Build was to separate the alien detection and installer code from the perl installer code. (In fact your alienfile is fully usable without any Perl installer at all; you can use your alienfile from a Perl script or Perl module using Alien::Build directly).

For our Alien, we will be creating Alien-xz, and we will use Alien::Build::MM to provide the thin layer of functionality needed between ExtUtils::MakeMaker (EUMM) and Alien::Build. This is what our Makefile.PL should look like:

use strict;
use warnings;
use ExtUtils::MakeMaker;
use Alien::Build::MM;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Find or build xz",
  "AUTHOR" => "Graham Ollis <plicease\@cpan.org>",
  "VERSION_FROM" => "lib/Alien/xz.pm",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.52",
  },
  "PREREQ_PM" => {
    "Alien::Base" => "0.038",
  },
  "DISTNAME" => "Alien-xz",
  "LICENSE" => "perl",
  "NAME" => "Alien::xz",
  "PREREQ_PM" => {
    "Alien::Base" => "0.038"
  },
);

my $abmm = Alien::Build::MM->new;
%WriteMakefileArgs = $abmm->mm_args(%WriteMakefileArgs);

WriteMakefile(%WriteMakefileArgs);

sub MY::postamble {
  $abmm->mm_postamble;
}

... read more

alienfile

By Graham Ollis on 28 March 2017

Alien::Base was first released in alpha form five years ago this month! The good things that Alien::Base (runtime) and Alien::Base::ModuleBuild (its installer ABMB) did when it was unleashed on the world are many, but chiefly:

  1. It suggested a standard way of providing the compiler and linker flags needed to use an already installed alien. The original manifesto was pretty flip in terms of standards or best practices.

  2. It made it dead simple to create an Alien distribution that “alienized” a package that used autoconf and pkg-config, which probably covers a majority of open source libraries that you would be likely to want to “alienize”. (For those who are unfamiliar, autoconf provides a similar functionality to ExtUtils::MakeMaker in the C world and pkg-config is used to deal with dependencies in the C world).

  3. It made it possible with some work to create an Alien distribution that wrapped around a package that used vanilla Makefile's, CMake, and in some cases crazy custom installers.

... read more

Alien::Build vs. Alien::Base::ModuleBuild

By Graham Ollis on 23 March 2017

I have been working on the next generation of Alien::Base installer which is called Alien::Build. It is already quite usable, and I encourage it's use for anyone who is considering building a new Alien modules. It may also be useful to migrate existing Aliens, if they have requirements that can utilize its unique features. The main idea is to concentrate the recipe for discovery and building of a library into an alienfile which is separate from the Perl installer (usually ExtUtils::MakeMaker or Module::Build). Over the next few weeks I intend on writing a little about some of the new features of Alien::Build.
In the meantime, if you are interested, Alien::Build::Manual::AlienAuthor may help you get started.

A year ago I mentioned that we were planning on spinning Alien::Base::ModuleBuild (AB::MB) off from the main Alien::Base distribution. Now that we have a viable alternative, we plan to split AB::MB off into its own distribution next week. Alien::Base will specify AB::MB as a prerequisite, until the first of October 2017. At that time it will be removed as a prerequisite and if you are using AB::MB you will need to specify it as a configure_requires in your Build.PL.

The main potential breakage for this is that when trying to install an Alien which hasn't been fixed, you will receive an error message like this:

... read more

Alien::Base and Module::Build

By Graham Ollis on 1 March 2016

TL;DR - if you have an Alien::Base based Alien module, please update configure_requires so that it depends on Alien::Base::ModuleBuild instead of Alien::Base, and (this part is key) make a release.

This is technically more correct, and it will also future proof your module in the event that Alien::Base::ModuleBuild gets spun off from the rest of Alien::Base. There are a number of motivations making such a move. Please join us on GitHub or the #native IRC channel if are interested in working on the next generation of of Alien::Base.

... read more

Improved reliability with Alien and Test::Alien

By Graham Ollis on 20 January 2016

The one major platform that didn’t work on the initial switch was of course Strawberry Perl, but after some debugging and patches I got Alien::Hunspell and Text::Hunspell to work there as well. I even submitted patches to upstream to the hunspell project, which were accepted, so that in the future less patching will be required. This is what is great about Open Source when it works.

The results as recorded in the cpantesters matrix are stark:

... read more

Making Alien::Base more reliable

By Graham Ollis on 29 July 2015

The Alien::Base (AB) team has done a number of things over the past year with AB to make the installing packages more reliable. For AB based Alien developers who have created their own Alien::Libfoo this is great because they get the benefit of more reliable installs when users upgrade their version of AB without having to release a new version of Alien::Libfoo. Though largely backward compatible with version 0.005 (or perhaps further), modern versions of AB have also been given a few interface enhancements that require changes in Alien::Libfoo in order to benefit. So if you are an AB based Alien developer, please consider a couple of simple changes that you can make to make your distribution more reliable.

Use %c instead of %pconfigure.

Long story short, the %p directive was intended to handle the portability problem when running a command in the current directly. On Unix this requires a ./ prefix. That won’t work on Windows.
Unfortunately, configure is usually a shell script and on Windows you need MSYS (or something similar) to provide sh and friends. Even if you had MSYS, %pconfigure won’t correctly invoke configure on Windows, because that isn’t how you run a shell script on Windows. So back in version 0.005 we added the %c directive to mean “run configure however that works on this platform”. If AB sees that you are using %c it will also make sure that Alien::MSYS gets added as a build requirement, if it is needed. In many cases, adding Windows support for your AB based Alien distribution may be as simple replacing %pconfigure with %c and making AB 0.005 a prerequisite.

... read more

Alien::Base: System Integrators vs. CPAN Authors

By Graham Ollis on 22 July 2015

Last week I promised (or threatened depending on your outlook) to talk about Alien::Base in the context of system integration and distribution packagers.

Philosophy:

The philosophy for Alien::Base has always been that the system library should be used when it is available, and if not, the source code for that library can be downloaded and installed for you. My own Alien::FFI (isa Alien::Base) which provides libffi, and FFI::Platypus which uses it is a good example of the success of this approach as you can see from their respective test matrices

... read more

Alien::Base 0.020 and #native

By Graham Ollis on 15 July 2015

This week we rolled out the latest version of Alien::Base which includes a new feature and a bug fix. The most important change in this version are the two new avenues of communication that we have adopted, so I will discuss that first.

The first is that we have established the #native channel on irc.perl.org to discuss interactions with native interfaces.
This includes Alien in general, Alien::Base specifically, and we also intend it to be a place to discuss FFI::Platypus (Foreign Function Interface or NativeCall), as there is a degree of overlap for the people involved. You can now click on a big red button from the metacpan page for the project that will log you into IRC and allow you to start asking questions (or complain at us if that is what needs doing).

The second communication improvement is the creation of an Alien::Base FAQ (see Alien::Base::FAQ). I promised this last year but only recently got around to writing it. It consists of a number of questions (and corresponding answers) that I personally had when I was trying to figure out how to develop my own Alien::Base based Alien distributions. I’m hoping this guide will help those that are getting started now.

... read more

Alien::Base past, present and future (upcoming change in behavior)

By Graham Ollis on 22 April 2015.

Alien::Base has made a great deal of progress since last September when Joel Berger turned over day to day development for the project to the then newly created Alien::Base team. We’ve closed most of the major issues and pull requests. One remaining important issue will hopefully be solved soon (I will get to that later; if you are an Alien::Base user you may want to skip to The Future below). Stability and reliability has improved to the point where it is good enough to be used by real projects. My own FFI::Platypus depends on Alien::Base tech to provide libffi, as an example. I’d like to see some other projects take advantage of Alien::Base as well.

What have we fixed? A number of things:

... read more


Copyright © 2018 Graham Ollis, Joel Berger et al.