Windows Support: Fixup Perl build (#29711)

* Add pl2bat to PATH: Windows on Perl requires the script pl2bat.bat
  and Perl to be available to the installer via the PATH. The build
  and dependent environments of Perl on Windows have the install
  prefix bin added to the PATH.
* symlink with win32file module instead of using Executable to
  call mklink (mklink is a shell function and so is not accessible
  in this manner).
This commit is contained in:
John W. Parent 2022-03-31 14:47:11 -04:00 committed by GitHub
parent 90da5dc909
commit 88b1bf751d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View file

@ -11,10 +11,11 @@
from llnl.util import lang from llnl.util import lang
from spack.util.executable import Executable
is_windows = _platform == 'win32' is_windows = _platform == 'win32'
if is_windows:
from win32file import CreateHardLink
def symlink(real_path, link_path): def symlink(real_path, link_path):
""" """
@ -53,16 +54,7 @@ def _win32_junction(path, link):
path = os.path.join(parent, path) path = os.path.join(parent, path)
path = os.path.abspath(path) path = os.path.abspath(path)
command = "mklink" CreateHardLink(link, path)
default_args = [link, path]
if os.path.isdir(path):
# try using a junction
default_args.insert(0, '/J')
else:
# try using a hard link
default_args.insert(0, '/H')
Executable(command)(*default_args)
@lang.memoized @lang.memoized

View file

@ -15,6 +15,7 @@
import os import os
import platform import platform
import re import re
import sys
from contextlib import contextmanager from contextlib import contextmanager
from llnl.util.lang import match_predicate from llnl.util.lang import match_predicate
@ -23,7 +24,7 @@
from spack import * from spack import *
from spack.operating_systems.mac_os import macos_version from spack.operating_systems.mac_os import macos_version
is_windows = str(spack.platforms.host()) == 'windows' is_windows = sys.platform == 'win32'
class Perl(Package): # Perl doesn't use Autotools, it should subclass Package class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
@ -330,6 +331,8 @@ def _setup_dependent_env(self, env, dependent_spec, deptypes):
if perl_lib_dirs: if perl_lib_dirs:
perl_lib_path = ':'.join(perl_lib_dirs) perl_lib_path = ':'.join(perl_lib_dirs)
env.prepend_path('PERL5LIB', perl_lib_path) env.prepend_path('PERL5LIB', perl_lib_path)
if is_windows:
env.append_path('PATH', self.prefix.bin)
def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_build_environment(self, env, dependent_spec):
self._setup_dependent_env(env, dependent_spec, self._setup_dependent_env(env, dependent_spec,
@ -361,6 +364,7 @@ def setup_dependent_package(self, module, dependent_spec):
def setup_build_environment(self, env): def setup_build_environment(self, env):
if is_windows: if is_windows:
env.append_path('PATH', self.prefix.bin)
return return
spec = self.spec spec = self.spec