drop main dep from build_environment/subprocess_context (#46426)

This commit is contained in:
Harmen Stoppels 2024-09-17 17:06:16 +02:00 committed by GitHub
parent 3ded2fc9c5
commit aa6651fe27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 18 deletions

View File

@ -62,7 +62,6 @@
import spack.config
import spack.deptypes as dt
import spack.error
import spack.main
import spack.multimethod
import spack.package_base
import spack.paths
@ -451,7 +450,7 @@ def set_wrapper_variables(pkg, env):
env.set(SPACK_DEBUG, "TRUE")
env.set(SPACK_SHORT_SPEC, pkg.spec.short_spec)
env.set(SPACK_DEBUG_LOG_ID, pkg.spec.format("{name}-{hash:7}"))
env.set(SPACK_DEBUG_LOG_DIR, spack.main.spack_working_dir)
env.set(SPACK_DEBUG_LOG_DIR, spack.paths.spack_working_dir)
if spack.config.get("config:ccache"):
# Enable ccache in the compiler wrapper

View File

@ -100,24 +100,12 @@
#: Properties that commands are required to set.
required_command_properties = ["level", "section", "description"]
#: Recorded directory where spack command was originally invoked
spack_working_dir = None
spack_ld_library_path = os.environ.get("LD_LIBRARY_PATH", "")
#: Whether to print backtraces on error
SHOW_BACKTRACE = False
def set_working_dir():
"""Change the working directory to getcwd, or spack prefix if no cwd."""
global spack_working_dir
try:
spack_working_dir = os.getcwd()
except OSError:
os.chdir(spack.paths.prefix)
spack_working_dir = spack.paths.prefix
def add_all_commands(parser):
"""Add all spack subcommands to the parser."""
for cmd in spack.cmd.all_commands():
@ -998,7 +986,7 @@ def finish_parse_and_run(parser, cmd_name, main_args, env_format_error):
raise env_format_error
# many operations will fail without a working directory.
set_working_dir()
spack.paths.set_working_dir()
# now we can actually execute the command.
if main_args.spack_profile or main_args.sorted_profile:

View File

@ -136,3 +136,16 @@ def _get_system_config_path():
#: System configuration location
system_config_path = _get_system_config_path()
#: Recorded directory where spack command was originally invoked
spack_working_dir = None
def set_working_dir():
"""Change the working directory to getcwd, or spack prefix if no cwd."""
global spack_working_dir
try:
spack_working_dir = os.getcwd()
except OSError:
os.chdir(prefix)
spack_working_dir = prefix

View File

@ -22,7 +22,7 @@
import spack.config
import spack.environment
import spack.main
import spack.paths
import spack.platforms
import spack.repo
import spack.store
@ -72,12 +72,12 @@ def __init__(self, pkg):
else:
self.pkg = pkg
self.env = spack.environment.active_environment()
self.spack_working_dir = spack.main.spack_working_dir
self.spack_working_dir = spack.paths.spack_working_dir
self.test_state = TestState()
def restore(self):
self.test_state.restore()
spack.main.spack_working_dir = self.spack_working_dir
spack.paths.spack_working_dir = self.spack_working_dir
env = pickle.load(self.serialized_env) if _SERIALIZE else self.env
if env:
spack.environment.activate(env)