@@ -47,6 +47,26 @@ def find_opt(args, name):
47
47
return - 1
48
48
49
49
50
+ def ensure_opt (args , name , value ):
51
+ opt = f'--{ name } '
52
+ pos = find_opt (args , name )
53
+ if value is None :
54
+ if pos < 0 :
55
+ args .append (opt )
56
+ else :
57
+ args [pos ] = opt
58
+ elif pos < 0 :
59
+ args .extend ([opt , value ])
60
+ else :
61
+ arg = args [pos ]
62
+ if arg == opt :
63
+ if pos == len (args ) - 1 :
64
+ raise NotImplementedError ((args , opt ))
65
+ args [pos + 1 ] = value
66
+ else :
67
+ args [pos ] = f'{ opt } ={ value } '
68
+
69
+
50
70
def git_copy_repo (newroot , remote = None , * , verbose = True ):
51
71
if not GIT :
52
72
raise UnsupportedError ('git' )
@@ -156,17 +176,17 @@ def configure_python(builddir=None, prefix=None, cachefile=None, args=None, *,
156
176
157
177
cmd = [configure ]
158
178
if inherit :
159
- oldargs = get_configure_args (builddir )
179
+ oldargs = get_configure_args (builddir , fail = False )
160
180
if oldargs :
161
181
cmd .extend (oldargs )
162
182
if cachefile :
163
183
if args and find_opt (args , 'cache-file' ) >= 0 :
164
184
raise ValueError ('unexpected --cache-file' )
165
- cmd . extend ([ '-- cache-file' , os .path .abspath (cachefile )] )
185
+ ensure_opt ( cmd , ' cache-file' , os .path .abspath (cachefile ))
166
186
if prefix :
167
187
if args and find_opt (args , 'prefix' ) >= 0 :
168
188
raise ValueError ('unexpected --prefix' )
169
- cmd . extend ([ '-- prefix' , os .path .abspath (prefix )] )
189
+ ensure_opt ( cmd , ' prefix' , os .path .abspath (prefix ))
170
190
if args :
171
191
cmd .extend (args )
172
192
0 commit comments