From 725a91f1cc5cfb2decc05c9a6d77acd1a2644598 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 15 Jan 2020 22:47:52 -0800 Subject: [PATCH] Fix bug where packages with literal hyphens don't parse right. --- pip_download.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pip_download.py b/pip_download.py index f85e44c..2da4c2c 100644 --- a/pip_download.py +++ b/pip_download.py @@ -21,13 +21,15 @@ def pip_download(package): subprocess.call([sys.executable, '-m', 'pip', 'download', package, '-d', tmpdir.name]) downloaded_files = os.listdir(tmpdir.name) for filename in downloaded_files: - parts = filename.split('-') - filename_package = parts[0] - if filename_package.lower() == package.lower(): + filename = filename.lower() + prefix = package.lower() + '-' + if filename.startswith(prefix): + parts = filename.replace(prefix, '') + parts = parts.split('-') + version = parts[0] break else: raise Exception(f'None of the downloads match the package name {package}? {downloaded_files}') - version = parts[1] version = clean_version(version) new_directory = f'{package}\\{package}-{version}' if not os.path.exists(new_directory):