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

Add --pypi option to pixi remove #602

Merged

Conversation

marcelotrevisani
Copy link
Contributor

@marcelotrevisani marcelotrevisani commented Jan 2, 2024

Remove dependencies on pypi-dependencies section in pixi.toml

It fixes #591

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Hey @marcelotrevisani
Thanks for your work!

There are some things I would change. Let me know if my reviews need more explaining!

src/cli/remove.rs Outdated Show resolved Hide resolved
src/project/manifest.rs Outdated Show resolved Hide resolved
src/project/manifest.rs Outdated Show resolved Hide resolved
src/project/manifest.rs Show resolved Hide resolved
src/project/manifest.rs Show resolved Hide resolved
src/project/python.rs Outdated Show resolved Hide resolved
src/project/python.rs Show resolved Hide resolved
src/project/python.rs Outdated Show resolved Hide resolved
src/cli/remove.rs Outdated Show resolved Hide resolved
src/consts.rs Show resolved Hide resolved
src/cli/remove.rs Outdated Show resolved Hide resolved
src/cli/remove.rs Outdated Show resolved Hide resolved
src/project/python.rs Outdated Show resolved Hide resolved
src/project/python.rs Outdated Show resolved Hide resolved
@marcelotrevisani
Copy link
Contributor Author

Thanks for reviewing this, I will do the modifications later today :)

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Nice improvements! few more notes, would like to get some more scenarios tested to avoid missing some features or breaking them in the future

src/cli/remove.rs Outdated Show resolved Hide resolved
src/project/manifest.rs Show resolved Hide resolved
src/project/python.rs Show resolved Hide resolved
src/project/python.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

One final comment, but otherwise look good to me!

.remove_target_dependency(dep, &spec_type, p)
if args.pypi {
let pkg_name = rip::types::PackageName::from_str(dep.as_source())
.expect("Expected dependency name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just like with the add functionality I think this cli subcommand should accept strings for deps. Parsing into a package name should yield an error if its not a valid package name. That way the user gets the best possible error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored that, please take a look again :)

src/cli/remove.rs Outdated Show resolved Hide resolved
src/cli/remove.rs Outdated Show resolved Hide resolved
@ruben-arts ruben-arts changed the title Add option remove --pypi Add --pypi option to pixi remove Jan 4, 2024
@ruben-arts
Copy link
Contributor

@marcelotrevisani As mentioned in discord, we would like to refactor the flow of the remove::execute function a bit. Now it does string parsing and removing in the same iteration and it doesn't early out.

We would like it to first do all the input validation and then iterate over those results to remove them from the project. This would then also reintroduce the early out but with an actual error. Do you want to do this refactor or can I push to your branch?

@marcelotrevisani
Copy link
Contributor Author

I can try to do it later on

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

This is much beter! Thanks for the refactor.

One more case that needs dealing with.

} else {
project.manifest.remove_pypi_dependency(dep)?
};
print_ok_dep_removal(
Copy link
Contributor

Choose a reason for hiding this comment

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

Printing in this function will possibly give incorrect information to the user as you might error in a next iteration.

e.g.

pixi rm --pypi requests bla
# Results in:
Removed requests "*" from [pypi-dependencies]
  × Couldn't find bla in pypi-dependencies

But as the save only happens later it will not actually be removed from the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, I will change that later today, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

@ruben-arts ruben-arts merged commit dc5bab5 into prefix-dev:main Jan 6, 2024
@marcelotrevisani marcelotrevisani deleted the fix/591-pixi-remove-pypi-package branch January 6, 2024 12:34
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 this pull request may close these issues.

Cannot pixi remove --pypi package
3 participants