diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-09-17 17:06:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-17 17:06:16 +0200 |
commit | aa6651fe27dda47c69042c06b5d56ffdb9d582e0 (patch) | |
tree | c9ebd295383916efbff092e10bdfde6834b98a57 | |
parent | 3ded2fc9c53cc5dc684e49da25f4517bb687f3f5 (diff) | |
download | spack-aa6651fe27dda47c69042c06b5d56ffdb9d582e0.tar.gz spack-aa6651fe27dda47c69042c06b5d56ffdb9d582e0.tar.bz2 spack-aa6651fe27dda47c69042c06b5d56ffdb9d582e0.tar.xz spack-aa6651fe27dda47c69042c06b5d56ffdb9d582e0.zip |
drop main dep from build_environment/subprocess_context (#46426)
-rw-r--r-- | lib/spack/spack/build_environment.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/main.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/paths.py | 13 | ||||
-rw-r--r-- | lib/spack/spack/subprocess_context.py | 6 |
4 files changed, 18 insertions, 18 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index bf8ac6c1ea..26eb0e79f6 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -62,7 +62,6 @@ import spack.compilers 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 diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index eb15789c76..c0bb3d3355 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -100,24 +100,12 @@ section_order = { #: 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: diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py index aa64276421..84583cd552 100644 --- a/lib/spack/spack/paths.py +++ b/lib/spack/spack/paths.py @@ -136,3 +136,16 @@ user_config_path = _get_user_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 diff --git a/lib/spack/spack/subprocess_context.py b/lib/spack/spack/subprocess_context.py index f96e530e97..c823e65703 100644 --- a/lib/spack/spack/subprocess_context.py +++ b/lib/spack/spack/subprocess_context.py @@ -22,7 +22,7 @@ from types import ModuleType 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 @@ class PackageInstallContext: 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) |