question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `pipx hook` command

See original GitHub issue

Hi! Thank you for this fabulous tool!

How would this feature be useful?

Conda offers a command conda shell.{bash|zsh|fish} hook which can be invoked from scripts to bring the Conda environment into the current shell.

The boilerplate Conda adds to rcfiles actually invokes this command! But it’s also useful for scripts which install a sequence of tools (Conda, pipx, Poetry) to bootstrap a developer’s Python environment, with minimal interaction on their part.

I’m running pipx ensurepath from my bootstrap script, however it doesn’t take effect until starting the next shell. Starting a new shell is a rather clunky thing to do in the middle of a shell script execution.

Describe the solution you’d like

A pipx hook {bash|zsh|fish} command which outputs set -x PATH $PATH /Users/pnm/.local/bin or something similar, which updates and exports PATH in the current shell.

Another alternative (a little less nice I guess) would be a command like pipx bindir which resolves pipx’s config and just prints /Users/pnm/.local/bin.

Describe alternatives you’ve considered

My workaround is to hard-code ~/.local/bin in my bootstrap script. This works, however I’d have more confidence using a pipx command since I know it will honor pipx’s config. It also makes the intention of my bootstrap script more self-documenting.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
uranusjrcommented, Jul 11, 2021

That makes sense, thanks. Would you be interested in contributing such a command? I feel we can extend the idea to something like pipx environment, pipx constants, or something like that (I’m not good at naming things). This would print the variables pipx uses in pipx.constants, such as PIPX_HOME, PIPX_SHARED_LIBS, and PIPX_BIN_DIR (the last is the one you’re looking for). The format can be something like

$ pipx environment
PIPX_HOME=/home/user/.local/pipx
PIPX_SHARED_LIBS=/home/user/.local/pipx/shared
PIPX_BIN_DIR=/home/user/.local/bin

and we can maybe have an option to print a specific value like

$ pipx environment --value=PIPX_BIN_DIR
/home/user/.local/bin

Not sure what best to design this, other ideas are definitely welcomed.

1reaction
meowmeowmeowcatcommented, Jan 13, 2022

Hi @uranusjr, I am going to implement this. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installation - pipx
As an example, you can install global apps accessible by all users on your system with the following command (on MacOS, Linux, and...
Read more >
Quickstart — nitpick 0.32.0 documentation
Run as a pre-commit hook . If you use pre-commit on your project, add this to the .pre-commit-config.yaml in your ...
Read more >
Installation - Datasette documentation
The pipx ensurepath command configures your shell to ensure it can find commands that have been installed by pipx - generally by making...
Read more >
How to set up a perfect Python project - Sourcery
Pipx is a handy utility that allows quick installation of python command line tools. We'll be using it to install pipenv and cookiecutter....
Read more >
pyproject.toml - pip documentation v22.3.1
For building packages using this interface, pip uses an isolated environment. That is, pip will install build-time Python dependencies in a temporary directory ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found