From 955149ad6a70321a3683ad207ff92b2bd0f8de17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Zborowski?= Date: Sat, 27 Apr 2024 00:00:53 +0200 Subject: [PATCH] Added support for git dependencies with custom branch name. --- python_appimage/commands/build/app.py | 8 +++++++- python_appimage/utils/system.py | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/python_appimage/commands/build/app.py b/python_appimage/commands/build/app.py index 8ce2901..00c0c3e 100644 --- a/python_appimage/commands/build/app.py +++ b/python_appimage/commands/build/app.py @@ -253,6 +253,12 @@ def execute(appdir, name=None, python_version=None, linux_tag=None, 'WARNING: Running pip as' ) + git_warnings = ( + re.compile(r'\s+Running command git (clone|checkout) '), + re.compile(r"\s+Branch '.*' set up to track remote"), + re.compile(r"\s+Switched to a new branch '.*'"), + ) + isolation_flag = '-sE' if python_version[0] == '2' else '-I' system(('./AppDir/AppRun', isolation_flag, '-m', 'pip', 'install', '-U', in_tree_build, '--no-warn-script-location', 'pip'), exclude=deprecation) @@ -279,7 +285,7 @@ def execute(appdir, name=None, python_version=None, linux_tag=None, log('BUNDLE', requirement) system(('./AppDir/AppRun', isolation_flag, '-m', 'pip', 'install', '-U', in_tree_build, '--no-warn-script-location', requirement), - exclude=(deprecation, ' Running command git clone')) + exclude=(deprecation + git_warnings)) # Bundle the entry point diff --git a/python_appimage/utils/system.py b/python_appimage/utils/system.py index 03fde7d..f2e93ce 100644 --- a/python_appimage/utils/system.py +++ b/python_appimage/utils/system.py @@ -41,9 +41,16 @@ def system(args, exclude=None, stdin=None): if err: err = decode(err) stripped = [line for line in err.split(os.linesep) if line] + + def matches_pattern(line, pattern): + if isinstance(pattern, re.Pattern): + return bool(pattern.match(line)) + return line.startswith(pattern) + for pattern in exclude: stripped = [line for line in stripped - if not line.startswith(pattern)] + if not matches_pattern(line, pattern)] + if stripped: # Tolerate single line warning(s) for line in stripped: