@@ -34,17 +34,25 @@ PYPI_PROJECT = "tuf"
34
34
35
35
def build (build_dir : str ) -> str :
36
36
"""Build release locally. Return version as string"""
37
- cmd = ["python3" , "-m" , "build" , "--outdir" , build_dir ]
38
- subprocess .run (cmd , stdout = subprocess .DEVNULL , check = True )
37
+ orig_dir = os .path .dirname (os .path .abspath (__file__ ))
38
+
39
+ with TemporaryDirectory () as src_dir :
40
+ # fresh git clone: this prevents uncommitted files from affecting build
41
+ git_cmd = ["git" , "clone" , "--quiet" , orig_dir , src_dir ]
42
+ subprocess .run (git_cmd , stdout = subprocess .DEVNULL , check = True )
43
+
44
+ build_cmd = ["python3" , "-m" , "build" , "--outdir" , build_dir , src_dir ]
45
+ subprocess .run (build_cmd , stdout = subprocess .DEVNULL , check = True )
46
+
39
47
build_version = None
40
48
for filename in os .listdir (build_dir ):
41
49
prefix , postfix = f"{ PYPI_PROJECT } -" , ".tar.gz"
42
50
if filename .startswith (prefix ) and filename .endswith (postfix ):
43
51
build_version = filename [len (prefix ) : - len (postfix )]
52
+
44
53
assert build_version
45
54
return build_version
46
55
47
-
48
56
def get_git_version () -> str :
49
57
"""Return version string from git describe"""
50
58
cmd = ["git" , "describe" ]
0 commit comments