@@ -111,7 +111,7 @@ def format(self, record):
111111def _get_bin_path (build_dir = None ):
112112 if not build_dir :
113113 return os .getenv ('PATH' )
114- build_dir = Path (build_dir )
114+ build_dir = Path (build_dir ). absolute ()
115115 path_sep = ';' if sys .platform == 'win32' else ':'
116116 return path_sep .join (list (map (str , build_dir .rglob ('vcpkg_installed/*/tools/**/bin' ))) + [os .getenv ('PATH' )])
117117
@@ -152,6 +152,10 @@ def _run(cmd, *args, cwd, path=None, env=None, input=None, capture_output=True,
152152 env ['PATH' ] = path
153153 if _term_colors_on ():
154154 env ['FORCE_COLOR' ] = '1'
155+
156+ # Windows needs shell=True if env or path is modified
157+ if sys .platform == 'win32' and (env or path ):
158+ run_kwargs ['shell' ] = True
155159
156160 if docker_image :
157161 docker_cmd = ['docker' , 'run' , '--rm' , '--tty=true' , f'--workdir={ cwd } ' , f'--user={ os .getuid ()} :{ os .getgid ()} ' ]
@@ -209,8 +213,8 @@ def _git_get_branch(*, cwd):
209213
210214def _git_branches_related (branch1 , branch2 , * , cwd ):
211215 """Check whether branch is ancestor or descendant of another."""
212- return (_run (['git' , 'merge-base' , '--is-ancestor' , branch1 , branch2 ], cwd = cwd ).returncode == 0 or
213- _run (['git' , 'merge-base' , '--is-ancestor' , branch2 , branch1 ], cwd = cwd ).returncode == 0 )
216+ return (_run (['git' , 'merge-base' , '--is-ancestor' , branch1 , branch2 ], cwd = cwd , check = False ).returncode == 0 or
217+ _run (['git' , 'merge-base' , '--is-ancestor' , branch2 , branch1 ], cwd = cwd , check = False ).returncode == 0 )
214218
215219
216220_GIT_ORIG_BRANCH_CWD = None
@@ -443,10 +447,12 @@ def check_app_stream_info(version, cwd):
443447 appstream = Path (cwd ) / appstream
444448 if not appstream .is_file ():
445449 raise Error ('File not found: %s' , appstream )
446- major , minor , patch = _split_version (version )
447- if not re .search (rf'^\s*<release version="{ major } \.{ minor } \.{ patch } " date=".+?">' ,
448- appstream .read_text (), re .MULTILINE ):
449- raise Error (f'{ appstream } has not been updated to the "%s" release.' , version )
450+ regex = re .compile (rf'^\s*<release version="{ version } " date=".+?">' )
451+ with appstream .open ('r' , encoding = 'utf-8' ) as f :
452+ for line in f :
453+ if regex .search (line ):
454+ return
455+ raise Error (f'{ appstream } has not been updated to the "%s" release.' , version )
450456
451457 @staticmethod
452458 def check_git ():
@@ -682,15 +688,14 @@ def build_windows(self, version, src_dir, output_dir, *, parallelism, cmake_opts
682688
683689 # Start the build
684690 with tempfile .TemporaryDirectory () as build_dir :
685- # NOTE: Shell must be True on Windows to run the command in the provided vs_env
686691 logger .info ('Configuring build...' )
687- _run (['cmake' , * cmake_opts , str (src_dir )], cwd = build_dir , env = vs_env , shell = True , capture_output = False )
692+ _run (['cmake' , * cmake_opts , str (src_dir )], cwd = build_dir , env = vs_env , capture_output = False )
688693
689694 logger .info ('Compiling sources...' )
690- _run (['cmake' , '--build' , '.' , f'--parallel' , str (parallelism )], cwd = build_dir , env = vs_env , shell = True , capture_output = False )
695+ _run (['cmake' , '--build' , '.' , f'--parallel' , str (parallelism )], cwd = build_dir , env = vs_env , capture_output = False )
691696
692697 logger .info ('Packaging application...' )
693- _run (['cpack' , '-G' , 'ZIP;WIX' ], cwd = build_dir , env = vs_env , shell = True , capture_output = False )
698+ _run (['cpack' , '-G' , 'ZIP;WIX' ], cwd = build_dir , env = vs_env , capture_output = False )
694699
695700 output_files = list (Path (build_dir ).glob ("*.zip" )) + list (Path (build_dir ).glob ("*.msi" ))
696701 for output_file in output_files :
@@ -1092,7 +1097,6 @@ def run(self, subcmd, src_dir, branch, **kwargs):
10921097 self .check_transifex_config_exists (src_dir )
10931098
10941099 kwargs ['resource' ] = self .derive_resource_name (kwargs ['resource' ], cwd = src_dir )
1095- kwargs ['resource' ] = self .TRANSIFEX_RESOURCE .format (kwargs ['resource' ])
10961100 kwargs ['tx_args' ] = kwargs ['tx_args' ][1 :]
10971101 if subcmd == 'tx-push' :
10981102 self .run_tx_push (src_dir , ** kwargs )
0 commit comments