From 45d032dd7dd32b42e65fb683cdce6b43046d5261 Mon Sep 17 00:00:00 2001 From: konsti Date: Mon, 20 Nov 2023 12:21:22 +0100 Subject: [PATCH] Fix wheel filename serialization (#465) We need an underscore in the wheel filename, not a dash --- crates/distribution-filename/src/wheel.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/distribution-filename/src/wheel.rs b/crates/distribution-filename/src/wheel.rs index ff0791477..d7720a85b 100644 --- a/crates/distribution-filename/src/wheel.rs +++ b/crates/distribution-filename/src/wheel.rs @@ -114,7 +114,13 @@ impl FromStr for WheelFilename { impl Display for WheelFilename { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}-{}-{}.whl", self.name, self.version, self.get_tag()) + write!( + f, + "{}-{}-{}.whl", + self.name.as_dist_info_name(), + self.version, + self.get_tag() + ) } } @@ -277,4 +283,19 @@ mod tests { "foo-1.2.3-build-python-abi-platform.whl" )); } + + #[test] + fn from_and_to_string() { + let wheel_names = &[ + "django_allauth-0.51.0-py3-none-any.whl", + "osm2geojson-0.2.4-py3-none-any.whl", + "numpy-1.26.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + ]; + for wheel_name in wheel_names { + assert_eq!( + WheelFilename::from_str(wheel_name).unwrap().to_string(), + *wheel_name + ); + } + } }