Perl - allow package activation without PERL5LIB variable (#4540)

* perl: prepend default perl @INC path to support package activation

* perl: remove stray comma from list of configure arguments

* perl: final comma in configure arguments makes adding arguments safer

This reverts commit fdc10cd611f525ebc31ca1953e048095b1c75350.

* perl: add comment about modified @INC (thanks to George Hartzell)

* perl: use self.prefix.lib and self.prefix.bin for clarity

* perl: convert tabs added by editor to spaces for flake8

* perl: use new path syntax: prefix.lib.perl5

* perl: avoid line break before binary operator

* perl: use compact spack syntax for perl executable
This commit is contained in:
Milton Woods 2017-07-24 00:41:45 +10:00 committed by Adam J. Stewart
parent 62b4087c09
commit 4044e9f918

View File

@ -93,6 +93,23 @@ def configure_args(self):
'-Dloclibpth=' + self.spec['gdbm'].prefix.lib, '-Dloclibpth=' + self.spec['gdbm'].prefix.lib,
] ]
# Extensions are installed into their private tree via
# `INSTALL_BASE`/`--install_base` (see [1]) which results in a
# "predictable" installation tree that sadly does not match the
# Perl core's @INC structure. This means that when activation
# merges the extension into the extendee[2], the directory tree
# containing the extensions is not on @INC and the extensions can
# not be found.
#
# This bit prepends @INC with the directory that is used when
# extensions are activated [3].
#
# [1] https://metacpan.org/pod/ExtUtils::MakeMaker#INSTALL_BASE
# [2] via the activate method in the PackageBase class
# [3] https://metacpan.org/pod/distribution/perl/INSTALL#APPLLIB_EXP
config_args.append('-Accflags=-DAPPLLIB_EXP=\\"' +
self.prefix.lib.perl5 + '\\"')
# Discussion of -fPIC for Intel at: # Discussion of -fPIC for Intel at:
# https://github.com/LLNL/spack/pull/3081 and # https://github.com/LLNL/spack/pull/3081 and
# https://github.com/LLNL/spack/pull/4416 # https://github.com/LLNL/spack/pull/4416
@ -130,10 +147,6 @@ def install_cpanm(self):
make() make()
make('install') make('install')
def setup_environment(self, spack_env, run_env):
"""Set PERL5LIB to support activation of Perl packages"""
run_env.set('PERL5LIB', join_path(self.prefix, 'lib', 'perl5'))
def setup_dependent_environment(self, spack_env, run_env, dependent_spec): def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
"""Set PATH and PERL5LIB to include the extension and """Set PATH and PERL5LIB to include the extension and
any other perl extensions it depends on, any other perl extensions it depends on,
@ -143,8 +156,8 @@ def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
for d in dependent_spec.traverse( for d in dependent_spec.traverse(
deptype=('build', 'run'), deptype_query='run'): deptype=('build', 'run'), deptype_query='run'):
if d.package.extends(self.spec): if d.package.extends(self.spec):
perl_lib_dirs.append(join_path(d.prefix, 'lib', 'perl5')) perl_lib_dirs.append(d.prefix.lib.perl5)
perl_bin_dirs.append(join_path(d.prefix, 'bin')) perl_bin_dirs.append(d.prefix.bin)
perl_bin_path = ':'.join(perl_bin_dirs) perl_bin_path = ':'.join(perl_bin_dirs)
perl_lib_path = ':'.join(perl_lib_dirs) perl_lib_path = ':'.join(perl_lib_dirs)
spack_env.prepend_path('PATH', perl_bin_path) spack_env.prepend_path('PATH', perl_bin_path)
@ -159,10 +172,10 @@ def setup_dependent_package(self, module, dependent_spec):
""" """
# perl extension builds can have a global perl executable function # perl extension builds can have a global perl executable function
module.perl = Executable(join_path(self.spec.prefix.bin, 'perl')) module.perl = self.spec['perl'].command
# Add variables for library directory # Add variables for library directory
module.perl_lib_dir = join_path(dependent_spec.prefix, 'lib', 'perl5') module.perl_lib_dir = dependent_spec.prefix.lib.perl5
# Make the site packages directory for extensions, # Make the site packages directory for extensions,
# if it does not exist already. # if it does not exist already.
@ -179,7 +192,7 @@ def filter_config_dot_pm(self):
kwargs = {'ignore_absent': True, 'backup': False, 'string': False} kwargs = {'ignore_absent': True, 'backup': False, 'string': False}
# Find the actual path to the installed Config.pm file. # Find the actual path to the installed Config.pm file.
perl = Executable(join_path(prefix.bin, 'perl')) perl = self.spec['perl'].command
config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e', config_dot_pm = perl('-MModule::Loaded', '-MConfig', '-e',
'print is_loaded(Config)', output=str) 'print is_loaded(Config)', output=str)