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

Review and refactor Path::strip_prefix usages #1199

Closed
messense opened this issue Oct 14, 2022 · 0 comments · Fixed by #1204
Closed

Review and refactor Path::strip_prefix usages #1199

messense opened this issue Oct 14, 2022 · 0 comments · Fixed by #1204
Assignees
Milestone

Comments

@messense
Copy link
Member

messense commented Oct 14, 2022

It's getting quite messy, it needs both input to be relative/absolute to work correctly, but we do not have that guarantee at the moment. Things can easily go wrong, for example #1198.

Current state as of 5f2c219

rg strip_prefix
src/compile.rs
508:                        if py_init == sym_name.strip_prefix('_').unwrap_or(&sym_name) {
516:                            if py_init == sym_name.strip_prefix('_').unwrap_or(sym_name) {

src/python_interpreter/mod.rs
545:                                python.strip_prefix("python").unwrap_or(python)

src/module_writer.rs
662:                .strip_prefix(python_module.parent().unwrap())?;
732:            .strip_prefix(python_module.parent().unwrap())?;
842:        let relative = absolute.strip_prefix(python_module.as_ref().parent().unwrap())?;
939:                    let relative = file.path().strip_prefix(data.parent().unwrap())?;

src/auditwheel/platform_tag.rs
106:                if let Some(value) = value.strip_prefix("musllinux_") {
118:                    let value = value.strip_prefix("manylinux_").unwrap_or(&value);

src/source_distribution.rs
284:                    .strip_prefix(&pyproject_dir)
326:            .strip_prefix(pyproject_dir)?
345:        let relative_manifest_path = abs_manifest_path.strip_prefix(pyproject_dir)?;
485:            cargo_lock_path.strip_prefix(project_root)?
487:            cargo_lock_path.strip_prefix(&abs_manifest_dir)?
515:            let target = root_dir.join(source.strip_prefix(&pyproject_dir)?);
545:                let target = root_dir.join(&source.strip_prefix(pyproject_dir)?);

src/build_options.rs
996:        let (python_impl, python_ver) = if let Some(ver) = python.strip_prefix("pypy") {
997:            (InterpreterKind::PyPy, ver.strip_prefix('-').unwrap_or(ver))
998:        } else if let Some(ver) = python.strip_prefix("python") {
1001:                ver.strip_prefix('-').unwrap_or(ver),

Most of them are fine, just need to check source_distribution.rs and module_writer.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant