From 88b1bf751d76e010584b251f482cdfb0ba5351a1 Mon Sep 17 00:00:00 2001 From: "John W. Parent" <45471568+johnwparent@users.noreply.github.com> Date: Thu, 31 Mar 2022 14:47:11 -0400 Subject: [PATCH] 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). --- lib/spack/llnl/util/symlink.py | 16 ++++------------ var/spack/repos/builtin/packages/perl/package.py | 6 +++++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/spack/llnl/util/symlink.py b/lib/spack/llnl/util/symlink.py index d6e4651557..6c55d74f66 100644 --- a/lib/spack/llnl/util/symlink.py +++ b/lib/spack/llnl/util/symlink.py @@ -11,10 +11,11 @@ from llnl.util import lang -from spack.util.executable import Executable - is_windows = _platform == 'win32' +if is_windows: + from win32file import CreateHardLink + def symlink(real_path, link_path): """ @@ -53,16 +54,7 @@ def _win32_junction(path, link): path = os.path.join(parent, path) path = os.path.abspath(path) - command = "mklink" - 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) + CreateHardLink(link, path) @lang.memoized diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index e44a711d45..eec1927622 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -15,6 +15,7 @@ import os import platform import re +import sys from contextlib import contextmanager from llnl.util.lang import match_predicate @@ -23,7 +24,7 @@ from spack import * 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 @@ -330,6 +331,8 @@ def _setup_dependent_env(self, env, dependent_spec, deptypes): if perl_lib_dirs: perl_lib_path = ':'.join(perl_lib_dirs) 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): 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): if is_windows: + env.append_path('PATH', self.prefix.bin) return spec = self.spec