Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix license line ending in wheel metadata for Windows #836

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
python-version: "3.10.0"
- name: Install cffi and virtualenv
run: pip install cffi virtualenv ziglang~=0.9.0
run: pip install cffi virtualenv ziglang~=0.9.0 twine
- uses: actions-rs/toolchain@v1
id: rustup
with:
Expand Down Expand Up @@ -103,6 +103,8 @@ jobs:
cargo run -- build --no-sdist -i python -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-gnu --zig
cargo run -- build --no-sdist -i python -m test-crates/pyo3-pure/Cargo.toml --target aarch64-unknown-linux-musl --zig
cargo run -- build --no-sdist -i python -m test-crates/pyo3-pure/Cargo.toml --target aarch64-apple-darwin --zig
# Check wheels with twine
twine check --strict test-crates/pyo3-pure/target/wheels/*.whl
test-alpine:
name: Test Alpine Linux
Expand Down
24 changes: 24 additions & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ fn fold_header(text: &str) -> String {
if i > 0 {
result.push_str("\r\n");
}
let line = line.trim_end();
if line.is_empty() {
result.push('\t');
} else {
Expand Down Expand Up @@ -794,6 +795,29 @@ mod test {
let content = metadata.to_file_contents();
let pkginfo: Result<python_pkginfo::Metadata, _> = content.parse();
assert!(pkginfo.is_ok());

let license = metadata
.to_vec()
.into_iter()
.filter_map(|(key, val)| {
if key.starts_with("License") {
Some(val)
} else {
None
}
})
.next()
.unwrap();
let mut lines = license.split_inclusive('\n');
assert_eq!(
lines.next().unwrap(),
"Copyright (c) 2018-present konstin\r\n"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without trim_end(), this becomes Copyright (c) 2018-present konstin\r\r\n on Windows.

https://github.com/messense/maturin/runs/5465287747?check_suite_focus=true

);
assert_eq!(lines.next().unwrap(), "\t\r\n");
assert_eq!(
lines.next().unwrap(),
"\tPermission is hereby granted, free of charge, to any\r\n"
);
}

#[test]
Expand Down