-
Notifications
You must be signed in to change notification settings - Fork 900
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 mastodon-py dist-info handling #336
Conversation
crates/install-wheel-rs/src/wheel.rs
Outdated
(match crate::find_dist_info(filename, archive.file_names().map(|name| (name, name))) { | ||
Ok((_, dist_info_dir)) => Ok(dist_info_dir.to_string()), | ||
Err(err) => Err(Error::InvalidWheel(err)), | ||
})?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this much clearer as:
let dist_info_prefix = match crate::find_dist_info(filename, archive.file_names().map(|name| (name, name))) {
Ok((_, dist_info_dir)) => dist_info_dir.to_string(),
Err(err) => return Err(Error::InvalidWheel(err)),
};
let dist_info_dir = find_dist_info(filename, archive.file_names().map(|name| (name, name))) | ||
.map_err(|err| format_err!("Invalid wheel {filename}: {err}"))? | ||
.1 | ||
.to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this .to_string
necessary? We immediately pass this to a format
call.
dist_infos.join(", ") | ||
))); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what happened to these errors? Are they no longer ever surfaced? Should we remove them from the enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still other cases where Error::InvalidWheel
is used
mastodon-py 1.5.1 uses a dot in its dist-info dir name, which we previously didn't handle, causing home-assistant to fail. The new implementation is based on https://github.com/pypa/packaging/blob/2f83540272e79e3fe1f5d42abae8df0c14ddf4c2/src/packaging/utils.py#L146-L172. Part of #199 ``` unzip -l Mastodon.py-1.5.1-py2.py3-none-any.whl Archive: Mastodon.py-1.5.1-py2.py3-none-any.whl Length Date Time Name --------- ---------- ----- ---- 153929 2020-02-29 17:39 mastodon/Mastodon.py 1029 2019-10-11 19:15 mastodon/__init__.py 7357 2019-10-11 20:24 mastodon/streaming.py 10 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/DESCRIPTION.rst 1398 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/metadata.json 9 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/top_level.txt 110 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/WHEEL 1543 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/METADATA 753 2020-03-14 18:14 Mastodon.py-1.5.1.dist-info/RECORD --------- ------- 166138 9 files ```
7dd45f9
to
c5bda98
Compare
Merging this since i need it for the top 8k pypi checks |
mastodon-py 1.5.1 uses a dot in its dist-info dir name, which we previously didn't handle, causing home-assistant to fail. The new implementation is based on https://github.com/pypa/packaging/blob/2f83540272e79e3fe1f5d42abae8df0c14ddf4c2/src/packaging/utils.py#L146-L172.
Part of #199