2
2
import shutil
3
3
import subprocess
4
4
from pathlib import Path
5
- from typing import List , Literal , Union , overload
5
+ from typing import List , Literal , Union , overload , Dict
6
6
7
7
import yaml
8
8
from loguru import logger
@@ -21,7 +21,7 @@ def recursive_dict_update(d, u):
21
21
return d
22
22
23
23
24
- def cmd_json_to_dict (cmd : subprocess .CompletedProcess ) -> dict :
24
+ def cmd_json_to_dict (cmd : subprocess .CompletedProcess ) -> Dict :
25
25
return json .loads (cmd .stdout .decode ())
26
26
27
27
@@ -87,18 +87,18 @@ def install(self):
87
87
88
88
return self .cmd ("install" , "--only-concrete" , "--no-add" )
89
89
90
- # def spec(self, spec: str) -> dict :
90
+ # def spec(self, spec: str) -> Dict :
91
91
# res = self.cmd("spec", "-I", "--reuse", "--json", spec)
92
92
# return cmd_json_to_dict(res)
93
93
94
94
def concretize (self ):
95
95
return self .cmd ("concretize" , "--reuse" )
96
96
97
- def find (self ) -> dict :
97
+ def find (self ) -> Dict :
98
98
res = self .cmd ("find" , "--json" )
99
99
return cmd_json_to_dict (res )
100
100
101
- # def find_missing(self) -> dict :
101
+ # def find_missing(self) -> Dict :
102
102
# res = self.cmd(
103
103
# "find", "--show-concretized", "--deps", "--only-missing", "--json"
104
104
# )
@@ -130,18 +130,40 @@ def find_python_packages(
130
130
packages_dict : List [dict ] = json .loads (packages_json )
131
131
132
132
if only_names :
133
- return [
134
- f"{ p ['name' ]} =={ p ['version' ]} "
135
- for p in packages_dict
136
- if p ["name" ] != "pip"
137
- ]
133
+ return [f"{ p ['name' ]} =={ p ['version' ]} " for p in packages_dict ]
138
134
else :
139
135
return packages_dict
140
136
141
- def get_config (self ) -> dict :
137
+ def verify (self ) -> Dict [Path , list ]:
138
+ view_path = self .path / ".venv"
139
+ packages = list ((view_path / ".spack" ).iterdir ())
140
+
141
+ package_warnings = {}
142
+
143
+ for package in packages :
144
+ self .program .update_status (f"{ package .name } " )
145
+ manifest_file = package / "install_manifest.json"
146
+ manifest = json .loads (manifest_file .read_text ())
147
+ package_path = manifest_file .resolve ().parent .parent
148
+ files = {
149
+ Path (k .replace (str (package_path ), str (view_path ))): Path (k )
150
+ for k , v in manifest .items ()
151
+ if v ["type" ] == "file" and ".spack" not in k and "bin" not in k
152
+ }
153
+
154
+ warnings = []
155
+ for link , target in files .items ():
156
+ if not link .resolve () == target .resolve ():
157
+ warnings .append ((link , target ))
158
+
159
+ package_warnings [package ] = warnings
160
+
161
+ return package_warnings
162
+
163
+ def get_config (self ) -> Dict :
142
164
return yaml .safe_load ((self .path / "spack.yaml" ).read_text ())
143
165
144
- def set_config (self , config : dict ) -> None :
166
+ def set_config (self , config : Dict ) -> None :
145
167
current_config = self .get_config ()
146
168
new_config = recursive_dict_update (current_config , config )
147
169
0 commit comments