On Sun, 28 Mar 2010 23:40:35 +0200, [email protected] wrote:
> What is the preferred way of allowing a driver to use either
> DBI::PurePerl or DBI?
Because DBI::PurePerl is inside the DBI package, the only way to
disable DBI is to make your C compiler unavailable.
requiring DBI::PurePerl will, when not found, install DBI, which
includes DBI and DBI::PurePerl. The first will only not be installed
if it cannot be compiled.
> Module::Build does not support alternative requirements
> (one-or-the-other), but it does allow:
> =================================
> requires => {
> 'DBI::PurePerl' => 0.0,
> },
> recommends => {
> 'DBI' => 0.0,
> },
> =================================
Which will essentially require the same distribution.
It looks like you have no option but to require nothing, and try to
"require DBI::PurePerl" during Makefile.PL time maybe.
> In practice this results in circa 70% of smoke testers running the
> module with DBI installed.
>
> The remaining 30% however, fails with this error:
> =================================
> # Failed test 'use DBI;'
> # at t/00-load.t line 4.
> # Tried to use 'DBI'.
> # Error: Can't locate DBI.pm in @INC (@INC contains:
> [...snip...]) at (eval 4) line 2.
> # BEGIN failed--compilation aborted at (eval 4) line 2.
> =================================
>
> I could easily change the "use DBI" line into a conditional "require
> DBI::PurePerl" during BEGIN, but this does not fix the root of the
> problem, namely that the PurePerl version of DBI never gets installed.
Why would someone install DBI::PurePerl with a working XS version?
> Being able to install DBI::PurePerl is unfortunately kind of critical
> to being able to use it in any way whatsoever..
>
> Any good ideas?
Maybe too late now. But when Makamake took over Text::CSV, we discussed
the best interface. The old Text::CSV was heavily broken, and he wanted
Text::CSV to be the pur perl version of Text::CSV_XS.
We decided that the best plan was to create Text::CSV_PP to be the
pure-perl version of Text::CSV_XS and to Have Text::CSV choose the
fastest available on invocation. There is still a way to prefer either
by environment variables.
In order to do something similar with DBI, DBI should be renamed to
DBI::XS (or DBI_XS) and a new wrapper called DBI can at runtime select
either DBI::XS or DBI::PurePerl whatever is available. If this path
would be chosen, then it would be `normal' to also install
DBI::PurePerl because now the end-user has an option.
FWIW I am not the one going to implement this.
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/