Giter Site home page Giter Site logo

homebrew? about pipx HOT 24 CLOSED

pypa avatar pypa commented on August 18, 2024 3
homebrew?

from pipx.

Comments (24)

sloria avatar sloria commented on August 18, 2024 2

It's fairly straightforward to create a Homebrew formula from a Python package. Here's the formula for doitlive: https://github.com/Homebrew/homebrew-core/blob/master/Formula/doitlive.rb .

I then use this script to update the Homebrew formula after I make a PyPI release: https://github.com/sloria/doitlive/blob/dev/release_homebrew.sh

@cs01 Would you be up for adding this to your release workflow?

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024 2

Got it working. Solution was to not use hombrew's virtualenv creation mechanism. Here's the pull request: Homebrew/homebrew-core#39020

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024 2

Merged! Homebrew/homebrew-core@e3e53ec

Please run brew install pipx to try it out.

@cs01 next step will be updating the readme to add brew install pipx for macOS and updating your make publish command. I'll use @sloria's release_homebrew script as a base.

PRs to come!

from pipx.

sloria avatar sloria commented on August 18, 2024 1

The advantage of a Homebrew installer would be that pipx could be installed in /usr/local/bin/pipx with the other homebrew-installed binaries.

Currently, if you install pipx is installed using Homebrew-installed python3:

python3 -m pip install --user pipx

The pipx binary gets installed to $HOME/Library/Python/3.7/bin/pipx, which isn't in $PATH by default.

I'm currently working around this by installing pipx with pipx...

python3 -m pip install --user pipx
python3 -m pipx install pipx

And ensuring that $HOME/.local/bin is at the front of $PATH:

export PATH="$HOME/.local/bin:$PATH"

from pipx.

cs01 avatar cs01 commented on August 18, 2024 1

PR's welcome to build it into the publish target of the makefile. That way I can keep running the same command, and homebrew will be updated.

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024 1

re:

Btw, not sure if this is relevant, but pipx no longer installs itself to $HOME/.local/bin, it just installs itself to site-packages.

Right, so the README states to run pip install --user pipx which means it will get installed in $HOME/.local/bin. If the user doesn't already have this in their PATH, the next command, pipx ensurepath would fail


re: automatically running ensurepath
I believe homebrew has a strict policy against modifying a user's shell profile automatically so pipx ensurepath cannot be done there. The general practice is to list it under the "Caveats" which is printed at install time. This is similar to how pip install --user pipx works right now where a warning is printed if the $HOME/.local/bin is not in the PATH.

The experience would be identical in terms of the printed warning except for the fact that the pipx tool is guaranteed to be on the PATH via homebrew. This way, the pipx ensurepath command or pipx --help etc. will always work.

If the user missess the caveat to add $HOME/.local/bin the first time, running any pipx command can notify them to do so since pipx is guaranteed to be in the PATH.


re: maintainance

yep, if @sloria doesn't want it, I'll volunteer to maintain. I use the tool a fair amount and I've been evangalizing it at work. would love to add support for homebrew since we install the majority of our CLI tools in this way.

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024 1

lol wait nevermind, there was a small issue! Homebrew/homebrew-core#39483

should be good momentarily, I'll post here when its merged.

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024 1

@cs01 merged! Homebrew/homebrew-core@dfbe626

from pipx.

cs01 avatar cs01 commented on August 18, 2024

I am planning on making a pipx-bootstrap package on PyPI to avoid the curl method (#44).

I think the hardest part of the installation is modifying the PATH and opening a new terminal. What do you think would be made easier by moving to brew?

from pipx.

halloleo avatar halloleo commented on August 18, 2024

Just saw this thread... To your question @cs01 what are the benefits of moving to brew: Beeing able to install something with brew means its all in the same package manager: E.g. you can list all your installed packages making it easier to migrate to a new machine.

ps: Thanks for pipx. It's awsome!

from pipx.

cs01 avatar cs01 commented on August 18, 2024

Thank you!

I have no objection to someone adding it to brew, but I won’t be able to take that on myself. Also note that standard installation is now more straightforward with just β€œpip install pipx” so if you add it to brew there is no need for the bootstrap command.

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

hi @sloria do you want to submit a PR for adding this to homebrew or should I take a stab at it?

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

@cs01 The biggest reason as far as I can tell is that the second command in the README: pipx ensurepath will fail if $HOME/.local/bin isn't already in the PATH.

It's a circular dependency

from pipx.

cs01 avatar cs01 commented on August 18, 2024

Could you explain more about what the issue with pipx ensurepath is? Maybe the homebrew formula could have the equivalent of pipx ensurepath built into it?

Btw, not sure if this is relevant, but pipx no longer installs itself to $HOME/.local/bin, it just installs itself to site-packages.

from pipx.

iain2k avatar iain2k commented on August 18, 2024

Not sure if this is related but the instructions in the pipx README.md say to use pip install --user pipx.

If you are using HomeBrew built Python the --user argument is disabled due to a bug in distuils.
https://docs.brew.sh/Homebrew-and-Python

from pipx.

cs01 avatar cs01 commented on August 18, 2024

@iain2k thanks for sharing! pipx technically does not require a --user install. I wrote that because I thought it would get around common issues on mac and avoid polluting the global environment.

For anyone else reading, I would like to set expectations on this appropriately: I welcome having pipx on homebrew but want to completely rely on someone owning the pipx/homebrew experience.

I want my involvement to be make publish (as it currently is). Any homebrew issues that come up would be owned by someone else. Is anyone interested in volunteering for this?

from pipx.

sloria avatar sloria commented on August 18, 2024

@AlJohri All yours--I won't have time to work on this.

from pipx.

cs01 avatar cs01 commented on August 18, 2024

which means it will get installed in $HOME/.local/bin

Is this true? On my computer it installs to ~/Library/Python/VERSION/bin

What does

python -c "import site; print(site.USER_BASE + '/bin')"

output for you?


re: automatically running ensurepath

I will defer to you to work through those details and dogfood them on your coworkers πŸ˜„


I'll volunteer to maintain. I use the tool a fair amount and I've been evangalizing it at work. would love to add support for homebrew since we install the majority of our CLI tools in this way.

Nice, thanks so much!

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

@cs01 you got it! πŸ˜„

Is this true?

My default python installed via asdf (similar to pyenv) has path of ~/.local/bin. Homebrew python has path of: ~Library/Python/3.7/bin (this folder does not exist).

asdf python

$ asdf list
nodejs
  11.10.0
  11.5.0
python
  2.7.15
  3.7.2
ruby
  2.5.3

$ which python
/Users/al/.asdf/shims/python

$ python --version
Python 3.7.2

$ python -c "import site; print(site.USER_BASE + '/bin')"
/Users/al/.local/bin

homebrew python

$ /usr/local/bin/python3 -c "import site; print(site.USER_BASE + '/bin')"
/Users/al/Library/Python/3.7/bin

$ stat /Users/al/Library/Python/3.7/bin
stat: /Users/al/Library/Python/3.7/bin: stat: No such file or directory

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

Screen Shot 2019-04-13 at 1 37 14 AM

ran into an issue where pipx ensurepath can see the PATH is set properly but pipx install <package> doesn't when installed via my test homebrew formula.

will work through debugging but just throwing this here in case its immediately obvious to someone

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

I think I've identified the issue. Homebrew requires creating an isolated virtualenv for any python app. For some reason, creating a venv as pipx does, when it is already inside a virtualenv, has odd behavior.

The two virtualenvs (the homebrew isolated virtualenv for pipx) and the venv that pipx creates for a single package become linked.

Looking for a way around this...

from pipx.

cs01 avatar cs01 commented on August 18, 2024

Nice, thanks!

I just tried running brew install pipx but got Error: No available formula with the name "pipx".

from pipx.

AlJohri avatar AlJohri commented on August 18, 2024

@cs01 try running brew update and then brew install pipx? maybe you have export HOMEBREW_NO_AUTO_UPDATE=1 set so it didn't automatically update

from pipx.

rdewolff avatar rdewolff commented on August 18, 2024

On macOS, as stated by some earlier, I had to

export PATH=$HOME/Library/Python/3.7/bin:$PATH

To make the command pipx work.

from pipx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.