File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ """Script that exits 1 if the current environment is not
2
+ in sync with the `requirements-dev.lock` file.
3
+ """
4
+
5
+ from pathlib import Path
6
+
7
+ import importlib_metadata
8
+
9
+
10
+ def should_run_sync () -> bool :
11
+ dev_lock = Path (__file__ ).parent .parent .joinpath ("requirements-dev.lock" )
12
+
13
+ for line in dev_lock .read_text ().splitlines ():
14
+ if not line or line .startswith ("#" ) or line .startswith ("-e" ):
15
+ continue
16
+
17
+ dep , lock_version = line .split ("==" )
18
+
19
+ try :
20
+ version = importlib_metadata .version (dep )
21
+
22
+ if lock_version != version :
23
+ print (f"mismatch for { dep } current={ version } lock={ lock_version } " )
24
+ return True
25
+ except Exception :
26
+ print (f"could not import { dep } " )
27
+ return True
28
+
29
+ return False
30
+
31
+
32
+ def main () -> None :
33
+ if should_run_sync ():
34
+ exit (1 )
35
+ else :
36
+ exit (0 )
37
+
38
+
39
+ if __name__ == "__main__" :
40
+ main ()
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ dev-dependencies = [
58
58
" time-machine" ,
59
59
" nox" ,
60
60
" dirty-equals>=0.6.0" ,
61
+ " importlib-metadata>=6.7.0" ,
61
62
62
63
]
63
64
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ h11==0.14.0
24
24
httpcore==1.0.2
25
25
httpx==0.25.2
26
26
idna==3.4
27
+ importlib-metadata==7.0.0
27
28
iniconfig==2.0.0
28
29
isort==5.10.1
29
30
mypy==1.7.1
@@ -50,5 +51,6 @@ time-machine==2.9.0
50
51
tomli==2.0.1
51
52
typing-extensions==4.8.0
52
53
virtualenv==20.24.5
54
+ zipp==3.17.0
53
55
# The following packages are considered to be unsafe in a requirements file:
54
56
setuptools==68.2.2
You can’t perform that action at this time.
0 commit comments