python: drop dependency on file for script check (#29513)

`file` was used to detect Python scripts with shebangs, so that the interpreter could be changed from <python prefix> to <view path>. With this change, we detect shebangs using Python instead, so that `file` is no longer required.
This commit is contained in:
Harmen Stoppels
2022-03-23 10:31:23 +01:00
committed by GitHub
parent 487b1c3690
commit 773da7ceba
4 changed files with 55 additions and 4 deletions

View File

@@ -13,7 +13,11 @@
from shutil import copy
import llnl.util.tty as tty
from llnl.util.filesystem import copy_tree, get_filetype, path_contains_subdirectory
from llnl.util.filesystem import (
copy_tree,
is_nonsymlink_exe_with_shebang,
path_contains_subdirectory,
)
from llnl.util.lang import match_predicate
from spack import *
@@ -1369,7 +1373,7 @@ def add_files_to_view(self, view, merge_map):
view.link(src, dst, spec=self.spec)
elif not os.path.islink(src):
copy(src, dst)
if 'script' in get_filetype(src):
if is_nonsymlink_exe_with_shebang(src):
filter_file(
self.spec.prefix,
os.path.abspath(