Commit 71429b10 authored by Jason R. Coombs's avatar Jason R. Coombs

Fix two failures in sorting where filename parts became a factor in the version. Ref #432.

parent 8af3b6ef
...@@ -195,11 +195,19 @@ class SetuptoolsOldReleasesWithoutZip: ...@@ -195,11 +195,19 @@ class SetuptoolsOldReleasesWithoutZip:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
raise e raise e
@staticmethod
def version_from_filename(filename):
basename = os.path.basename(filename)
name, ext = os.path.splitext(basename)
if name.endswith('.tar'):
name, ext2 = os.path.splitext(name)
return LooseVersion(name)
def convert_targz_to_zip(self): def convert_targz_to_zip(self):
print("Converting the tar.gz to zip...") print("Converting the tar.gz to zip...")
files = glob.glob('%s/*.tar.gz' % self.dirpath) files = glob.glob('%s/*.tar.gz' % self.dirpath)
total_converted = 0 total_converted = 0
for targz in sorted(files, key=LooseVersion): for targz in sorted(files, key=self.version_from_filename):
# Extract and remove tar. # Extract and remove tar.
tar = tarfile.open(targz) tar = tarfile.open(targz)
tar.extractall(path=self.dirpath) tar.extractall(path=self.dirpath)
...@@ -230,8 +238,7 @@ class SetuptoolsOldReleasesWithoutZip: ...@@ -230,8 +238,7 @@ class SetuptoolsOldReleasesWithoutZip:
def upload_zips_to_pypi(self): def upload_zips_to_pypi(self):
print('Uploading to pypi...') print('Uploading to pypi...')
zips = sorted(glob.glob('%s/*.zip' % self.dirpath), key=LooseVersion) zips = sorted(glob.glob('%s/*.zip' % self.dirpath), key=self.version_from_filename)
print("simulated upload of", zips); return
upload.upload(dists=zips) upload.upload(dists=zips)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment