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

feat(pipx): add support for specifying package extras #2510

Merged
merged 5 commits into from
Aug 31, 2024

Conversation

antoniomdk
Copy link
Contributor

@antoniomdk antoniomdk commented Aug 27, 2024

Closes #2491

Some Python tools support optional features upon package installation, via pipx install package[feature,…]. This is used, for example, by Harlequin.

This PR adds support for specifying extras via

mytool = { version = '3.10', extras = 'foo,bar' }

NOTE: It only works for tools published to a registry (e.g PyPI), git-based tools require a different syntax than the one already implemented. (git+...#egg=project[...]).

NOTE: I had some issues setting up the local docker environment (unrelated to this project), so I couldn't run the e2e tests. There may be other parts of the code that could complain if using [, ] in the tool name, but the PyPI resolution error is the first one that popped up when trying to use package extras.

@antoniomdk antoniomdk marked this pull request as ready for review August 27, 2024 14:25
@jdx
Copy link
Owner

jdx commented Aug 27, 2024

I think Tool Options would be a better solution as it wouldn't require a new convention in mise https://mise.jdx.dev/dev-tools/#tool-options

See #2515 for an example

@antoniomdk
Copy link
Contributor Author

@jdx How would you propose the syntax for tool options in this case? Python extras are a list rather than a map, maybe something like

mytool = { version = '3.10', extras = ['bar'] }

@jdx
Copy link
Owner

jdx commented Aug 28, 2024

I think for now unfortunately it only supports strings so you will need to do this:

mytool = { version = '3.10', extras = 'foo,bar' }

I may be wrong though, I may have implemented some simple array support

@antoniomdk
Copy link
Contributor Author

That's fine, I'll update the PR to accommodate the tool options convention!

@antoniomdk antoniomdk force-pushed the antonio/add-extras-support-for-pipx branch from 51cb1d3 to 04bd924 Compare August 28, 2024 14:55
@antoniomdk
Copy link
Contributor Author

@jdx I've updated the code to use ToolVersions. Not sure if we have a way to add validation for the extra field, but probably the pipx/uvx error will be informative enough.

@jdx
Copy link
Owner

jdx commented Aug 29, 2024

you've got a test failure

@antoniomdk antoniomdk force-pushed the antonio/add-extras-support-for-pipx branch from 4f78c2b to 7c7e9d1 Compare August 29, 2024 11:53
@antoniomdk antoniomdk force-pushed the antonio/add-extras-support-for-pipx branch from 6189ddc to 9c896b3 Compare August 31, 2024 09:35
@antoniomdk
Copy link
Contributor Author

@jdx this is ready for review. The git history is kind of messy, let me know if you want me to clean it up before merging 👍

@jdx jdx merged commit 6730416 into jdx:main Aug 31, 2024
10 checks passed
triarius pushed a commit to triarius/mise that referenced this pull request Sep 18, 2024
* feat(pipx): add support for specifying extras

* chore: fix linting erros

* tests: add e2e tests for pipx with extras
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.

pipx: support features
2 participants