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: Add 'pipx run' entry point #217

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

matthewfeickert
Copy link
Contributor

@matthewfeickert matthewfeickert commented Apr 24, 2024

  • Allows for running the equivalent of python -m id with pipx run id.

Example:

$ docker run --rm -ti python:3.12 /bin/bash
root@c4f607410d2e:/# python -m pip install pipx
root@c4f607410d2e:/# python -m pipx ensurepath
Success! Added /root/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨
root@c4f607410d2e:/# . ~/.bashrc 
root@c4f607410d2e:/# pipx run --no-cache --spec git+https://github.com/matthewfeickert/id.git@feat/add-pipx-run-entrypoint id --help
⚠️  id is already on your PATH and installed at /usr/bin/id. Downloading and running anyway.
usage: id [-h] [-V] [-v] [-d] audience

a tool for generating OIDC identities

positional arguments:
  audience       the OIDC audience to use

options:
  -h, --help     show this help message and exit
  -V, --version  show program's version number and exit
  -v, --verbose  run with additional debug logging; supply multiple times to increase verbosity (default: 0)
  -d, --decode   decode the OIDC token into JSON (default: False)
root@c4f607410d2e:/#

pyproject.toml Outdated
Comment on lines 46 to 47
[project.entry-points."pipx.run"]
id = "id.__main__:entrypoint"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for linking this! I have no idea pipx run had its own entrypoint namespace, so this was helpful.

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 only learned about it from @henryiii in the last 12 hours. :)

id/__main__.py Outdated
Comment on lines 86 to 88
def entrypoint() -> None:
main()
Copy link
Contributor Author

@matthewfeickert matthewfeickert Apr 24, 2024

Choose a reason for hiding this comment

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

This isn't strictly required as one could imagine just using

"id.__main__:main"

in pyproject.toml but this allows for subtle decoupling between entrypoint and main if desired, like build has.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@di might have a different opinion, but IMO it's okay to have this just be main instead -- I don't think we have a plan/foreseen need for decoupling the two, so YAGNI applies 🙂

Copy link
Owner

Choose a reason for hiding this comment

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

I'm ok with it just being main as well!

@matthewfeickert
Copy link
Contributor Author

@woodruffw @di This is ready for review. Let me know if you have any questions, and if this isn't of interest feel free to just close it.

@woodruffw woodruffw added the enhancement New feature or request label Apr 24, 2024
Copy link
Collaborator

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

Thank you @matthewfeickert, this is great! I left one comment about the entrypoint (which @di can override).

@woodruffw
Copy link
Collaborator

/gcbrun

* Allows for running the equivalent of 'python -m id' with 'pipx run id'.
@matthewfeickert
Copy link
Contributor Author

Force pushed to cleanup linting — sorry missed that. I'll wait for Dustin's feedback before making any final changes to pyproject.toml and __main__.py to avoid having to keep making you hit /gcbrun over and over.

@di
Copy link
Owner

di commented Apr 24, 2024

/gcbrun

@woodruffw woodruffw merged commit 4552a88 into di:main Apr 24, 2024
13 checks passed
@woodruffw woodruffw mentioned this pull request Apr 24, 2024
@matthewfeickert matthewfeickert deleted the feat/add-pipx-run-entrypoint branch April 24, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants