@@ -701,7 +701,6 @@ def from_filename(cls, filename):
701
701
Return a distribution built from the data found in a `filename` string.
702
702
Raise an exception if this is not a valid filename
703
703
"""
704
- filename = unquote (os .path .basename (filename .strip ("/" )))
705
704
clazz = cls .get_dist_class (filename )
706
705
return clazz .from_filename (filename )
707
706
@@ -950,6 +949,15 @@ def get_sdist_name_ver_ext(filename):
950
949
return name , version , extension
951
950
952
951
952
+ def get_filename (filename ):
953
+ """
954
+ Return a filename from a ``filename`` path or name string. Unquote as needed.
955
+ """
956
+ filename = filename .strip ("/" )
957
+ filename = os .path .basename (filename )
958
+ return unquote (filename )
959
+
960
+
953
961
@attr .attributes
954
962
class Sdist (Distribution ):
955
963
extension = attr .ib (
@@ -965,6 +973,7 @@ def from_filename(cls, filename):
965
973
Return a Sdist object built from a filename.
966
974
Raise an exception if this is not a valid sdist filename
967
975
"""
976
+ filename = get_filename (filename )
968
977
name_ver_ext = get_sdist_name_ver_ext (filename )
969
978
if not name_ver_ext :
970
979
raise InvalidDistributionFilename (filename )
@@ -1069,6 +1078,7 @@ def from_filename(cls, filename):
1069
1078
Return a wheel object built from a filename.
1070
1079
Raise an exception if this is not a valid wheel filename
1071
1080
"""
1081
+ filename = get_filename (filename )
1072
1082
wheel_info = cls .get_wheel_from_filename (filename )
1073
1083
if not wheel_info :
1074
1084
raise InvalidDistributionFilename (filename )
0 commit comments