From 5c5802c0897c280ded9d4fede9829a9bbeb324fd Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 12 Aug 2021 13:37:10 +0300 Subject: [PATCH] Fix python package with git+git:// links or git+ssh:// conversion --- clearml_agent/helper/package/external_req.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clearml_agent/helper/package/external_req.py b/clearml_agent/helper/package/external_req.py index f9daed1..544e423 100644 --- a/clearml_agent/helper/package/external_req.py +++ b/clearml_agent/helper/package/external_req.py @@ -64,10 +64,19 @@ class ExternalRequirements(SimpleSubstitution): vcs_url = req_line[4:] # reverse replace vcs_url = vcs_url[::-1].replace(fragment[::-1], '', 1)[::-1] + # remove ssh:// or git:// prefix for git detection and credentials + scheme = '' + if vcs_url and (vcs_url.startswith('ssh://') or vcs_url.startswith('git://')): + scheme = 'ssh://' # notice git:// is actually ssh:// + vcs_url = vcs_url[6:] + from ..repo import Git vcs = Git(session=session, url=vcs_url, location=None, revision=None) vcs._set_ssh_url() - new_req_line = 'git+{}{}'.format(vcs.url_with_auth, fragment) + new_req_line = 'git+{}{}{}'.format( + '' if scheme and '://' in vcs.url else scheme, + vcs.url_with_auth, fragment + ) if new_req_line != req_line: furl_line = furl(new_req_line) print('Replacing original pip vcs \'{}\' with \'{}\''.format(