Subject: | Should File::ShareDir::PAR build-require PAR? |
Hello Steffen,
I am working on code that we intend to deploy in two styles:
1. as a standard installation (/usr/share/perl5, etc.)
2. as a stand-alone PAR
Since this code uses shared files, File::ShareDir::PAR seems to be a
perfect tool to accommodate for both cases.
My understanding is that File::ShareDir::PAR intends to be a drop-in
replacement for File::ShareDir--that is, if one is not operating under
PAR, File::ShareDir::PAR delegates to File::ShareDir.
To me, this suggests that File::ShareDir::PAR should be able to operate
independently of PAR. However, File::ShareDir::PAR lists PAR as a build
dependency.
I understand that when File::ShareDir::PAR actually needs to call PAR,
it requires a minimum PAR version. Therefore, I think I understand why
PAR is listed as a build dependency: you want to ensure that
File::ShareDir::PAR does not attempt to operate with an outdated version
of PAR.
However, since my code uses File::ShareDir::PAR even when PAR is not in
use, PAR becomes a dependency for installations where it will never be
required.
To work around this, I am continuing to use File::ShareDir and
dynamically requiring File::ShareDir::PAR when I detect that PAR is in
use. Consequently, I am also doing the PAR version checking myself.
In order to Debian-package File::ShareDir::PAR for internal deployment,
I am also manually removing the PAR dependency. This feels like an
incorrect way to solve the problem, but it is necessary for me to ensure
that a Debian-packaged standard installation of my code does not depend
on libpar-perl.
To cut to the chase: given my use case, do you feel that it could be
appropriate to change PAR from a required build dependency to a
conditional dynamic runtime dependency? This would make
File::ShareDir::PAR a true drop-in replacement for File::ShareDir, since
it would work as expected without a PAR installation.
I don't know whether the attached modification of _par_in_use would be
sufficient, but your consideration and feedback would be much
appreciated. :)
Best wishes from Melbourne, Australia.
--Alex Peters
Subject: | _par_in_use.txt |
# The minimum version of PAR required for correct functioning
# of PAR-specific code.
use constant MIN_PAR_VERSION = 0.989;
# Whether the installed version of PAR is sufficient.
our $par_is_adequate;
sub _par_in_use {
return 1 if $par_is_adequate;
return() unless exists $INC{"PAR.pm"};
return() unless @PAR::LibCache;
# If we get this far, PAR must be loaded.
if ($PAR::VERSION < MIN_PAR_VERSION) {
die sprintf(
'File::ShareDir::PAR has detected that PAR %s is in use, '
. 'but %s is required for File::ShareDir::PAR to work '
. 'properly',
$PAR::VERSION,
MIN_PAR_VERSION
);
}
$par_is_adequate = 1;
return 1;
}