Skip to content

Commit

Permalink
classifiers metadata name should be Classifier instead of `Classifi…
Browse files Browse the repository at this point in the history
…ers`

https://packaging.python.org/specifications/core-metadata/#classifier-multiple-use

I've downloaded `Flask` and `requests` from PyPI, they all show
`Classifier` in wheel metadata
  • Loading branch information
messense committed Jun 1, 2021
1 parent 6d1dea6 commit 0cb3d79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Metadata21 {
add_vec("Supported-Platform", &self.supported_platform);
add_vec("Platform", &self.platform);
add_vec("Supported-Platform", &self.supported_platform);
add_vec("Classifiers", &self.classifiers);
add_vec("Classifier", &self.classifiers);
add_vec("Requires-Dist", &self.requires_dist);
add_vec("Provides-Dist", &self.provides_dist);
add_vec("Obsoletes-Dist", &self.obsoletes_dist);
Expand Down Expand Up @@ -542,7 +542,7 @@ mod test {
Metadata-Version: 2.1
Name: info-project
Version: 0.1.0
Classifiers: Programming Language :: Python
Classifier: Programming Language :: Python
Requires-Dist: flask~=1.1.0
Requires-Dist: toml==0.10.0
Summary: A test project
Expand Down Expand Up @@ -601,7 +601,7 @@ mod test {
Metadata-Version: 2.1
Name: info-project
Version: 0.1.0
Classifiers: Programming Language :: Python
Classifier: Programming Language :: Python
Requires-Dist: flask~=1.1.0
Requires-Dist: toml==0.10.0
Summary: A test project
Expand Down Expand Up @@ -649,7 +649,7 @@ mod test {
Metadata-Version: 2.1
Name: info
Version: 0.1.0
Classifiers: Programming Language :: Python
Classifier: Programming Language :: Python
Summary: A test project
Home-Page: https://example.org
Author: konstin <[email protected]>
Expand Down
10 changes: 9 additions & 1 deletion src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ pub fn upload(
// Type system shenanigans
.chain(metadata21.to_vec().into_iter())
// All fields must be lower case and with underscores or they will be ignored by warehouse
.map(|(key, value)| (key.to_lowercase().replace("-", "_"), value))
.map(|(key, value)| {
let mut key = key.to_lowercase().replace("-", "_");
if key == "classifier" {
// PyPI upload api expects `classifiers` instead of `classifier`
// See https://github.com/pypa/warehouse/issues/3151#issuecomment-796965735
key = "classifiers".to_string();
}
(key, value)
})
.collect();

let mut form = Form::new();
Expand Down

0 comments on commit 0cb3d79

Please sign in to comment.