OneapiPackage: do not use getpass.getuser (#45727)

* OneapiPackage: do not use getpass.getuser
This commit is contained in:
Greg Becker 2024-08-14 09:48:44 -07:00 committed by GitHub
parent 586a35be43
commit 2b6bdc7013
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Common utilities for managing intel oneapi packages."""
import getpass
import os
import platform
import shutil
@ -13,6 +12,7 @@
from llnl.util.filesystem import HeaderList, LibraryList, find_libraries, join_path, mkdirp
from llnl.util.link_tree import LinkTree
import spack.util.path
from spack.build_environment import dso_suffix
from spack.directives import conflicts, license, redistribute, variant
from spack.package_base import InstallError
@ -99,7 +99,7 @@ def install_component(self, installer_path):
# with other install depends on the userid. For root, we
# delete the installercache before and after install. For
# non root we redefine the HOME environment variable.
if getpass.getuser() == "root":
if spack.util.path.get_user() == "root":
shutil.rmtree("/var/intel/installercache", ignore_errors=True)
bash = Executable("bash")
@ -122,7 +122,7 @@ def install_component(self, installer_path):
self.prefix,
)
if getpass.getuser() == "root":
if spack.util.path.get_user() == "root":
shutil.rmtree("/var/intel/installercache", ignore_errors=True)
# Some installers have a bug and do not return an error code when failing