Fix bug where packages with literal hyphens don't parse right.
This commit is contained in:
parent
2d5ef0c7cf
commit
725a91f1cc
1 changed files with 6 additions and 4 deletions
|
@ -21,13 +21,15 @@ def pip_download(package):
|
||||||
subprocess.call([sys.executable, '-m', 'pip', 'download', package, '-d', tmpdir.name])
|
subprocess.call([sys.executable, '-m', 'pip', 'download', package, '-d', tmpdir.name])
|
||||||
downloaded_files = os.listdir(tmpdir.name)
|
downloaded_files = os.listdir(tmpdir.name)
|
||||||
for filename in downloaded_files:
|
for filename in downloaded_files:
|
||||||
parts = filename.split('-')
|
filename = filename.lower()
|
||||||
filename_package = parts[0]
|
prefix = package.lower() + '-'
|
||||||
if filename_package.lower() == package.lower():
|
if filename.startswith(prefix):
|
||||||
|
parts = filename.replace(prefix, '')
|
||||||
|
parts = parts.split('-')
|
||||||
|
version = parts[0]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception(f'None of the downloads match the package name {package}? {downloaded_files}')
|
raise Exception(f'None of the downloads match the package name {package}? {downloaded_files}')
|
||||||
version = parts[1]
|
|
||||||
version = clean_version(version)
|
version = clean_version(version)
|
||||||
new_directory = f'{package}\\{package}-{version}'
|
new_directory = f'{package}\\{package}-{version}'
|
||||||
if not os.path.exists(new_directory):
|
if not os.path.exists(new_directory):
|
||||||
|
|
Loading…
Reference in a new issue