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 get-pipx script #849

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## dev

- Add `pipx uninject` command (#820)
- [docs] Fix `pipx run` examples and update Python versions used by `pipx install` examples
- [docs] Add an example for installation from source with extras

- Change the program name to `path/to/python -m pipx` when running as `python -m pipx`
- Add get-pipx.py script

## 1.1.0

Expand Down
143 changes: 80 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,53 @@

**Source Code**: https://github.com/pypa/pipx

_For comparison to other tools including pipsi, see [Comparison to Other Tools](https://pypa.github.io/pipx/comparisons/)._
_For comparison to other tools, see [Comparison to Other Tools](https://pypa.github.io/pipx/comparisons/)._

## Install pipx

### On macOS
There are several ways to install pipx. Below is recommended. For other installation methods, see [installation](https://pypa.github.io/pipx/installation/).

```
brew install pipx
pipx ensurepath
```
The `get-pipx.py` installation script installs pipx with pipx itself.

Upgrade pipx with `brew update && brew upgrade pipx`.
After it's finished, you can upgrade pipx with `pipx upgrade pipx`. To uninstall, you can run `pipx uninstall pipx`.

### On Linux, install via pip (requires pip 19.0 or later)
For Linux and macOS:

```
python3 -m pip install --user pipx
python3 -m pipx ensurepath
curl https://raw.githubusercontent.com/pypa/pipx/main/get-pipx.py | python3
```

Upgrade pipx with `python3 -m pip install --user -U pipx`.
If python3 is not found on your PATH or there is a syntax error/typo, `curl` will fail with the error message: "(23) Failed writing body."

### On Windows, install via pip (requires pip 19.0 or later)
For Windows:

```
# If you installed python using the app-store, replace `python` with `python3` in the next line.
python -m pip install --user pipx
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/pypa/pipx/main/get-pipx.py -UseBasicParsing).Content | python
```

It is possible (even most likely) the above finishes with a WARNING looking similar to this:
To pass arguments to the `get-pipx.py` script:

```
WARNING: The script pipx.exe is installed in `<USER folder>\AppData\Roaming\Python\Python3x\Scripts` which is not on PATH
curl https://raw.githubusercontent.com/pypa/pipx/main/get-pipx.py | python3 - ARGS
```

If so, go to the mentioned folder, allowing you to run the pipx executable directly.
Enter the following line (even if you did not get the warning):
For example, you can see options with

```
pipx ensurepath
curl https://raw.githubusercontent.com/pypa/pipx/main/get-pipx.py | python3 - --help
```

This will add both the above mentioned path and the `%USERPROFILE%\.local\bin` folder to your search path.
Restart your terminal session and verify `pipx` does run.

Upgrade pipx with `python3 -m pip install --user -U pipx`.
After installing, you may want to restart your terminal and verify `pipx` is on your shell's $PATH by confirming `pipx --help` works.

### Shell completions

Shell completions are available by following the instructions printed with this command:

```

pipx completions
```

For more details, see the [installation instructions](https://pypa.github.io/pipx/installation/).
```

## Overview: What is `pipx`?

Expand Down Expand Up @@ -116,40 +107,47 @@ Best of all, pipx runs with regular user permissions, never calling `sudo pip in
You can globally install an application by running

```

pipx install PACKAGE

```
Comment on lines 109 to 113
Copy link
Member

Choose a reason for hiding this comment

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

Added empty lines seem unnecessary?


This automatically creates a virtual environment, installs the package, and adds the package's associated applications (entry points) to a location on your `PATH`. For example, `pipx install pycowsay` makes the `pycowsay` command available globally, but sandboxes the pycowsay package in its own virtual environment. **pipx never needs to run as sudo to do this.**

Example:

```
>> pipx install pycowsay
installed package pycowsay 2.0.3, Python 3.7.3
These apps are now globally available

> pipx install pycowsay
> installed package pycowsay 2.0.3, Python 3.7.3
> These apps are now globally available

- pycowsay

done! ✨ 🌟 ✨

> pipx list
> venvs are in /home/user/.local/pipx/venvs
> apps are exposed on your $PATH at /home/user/.local/bin
> package pycowsay 2.0.3, Python 3.7.3

>> pipx list
venvs are in /home/user/.local/pipx/venvs
apps are exposed on your $PATH at /home/user/.local/bin
package pycowsay 2.0.3, Python 3.7.3
- pycowsay


# Now you can run pycowsay from anywhere
>> pycowsay mooo
____
< mooo >
====
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||

> pycowsay mooo

---

# < mooo >

\
\
^**^
(oo)\_\_\_\_\_**
(\_\_)\ )\/\
||----w |
|| ||

```
Comment on lines +137 to 152
Copy link
Member

Choose a reason for hiding this comment

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

ASCII is broken


Expand All @@ -158,10 +156,12 @@ apps are exposed on your $PATH at /home/user/.local/bin
You can also install from a git repository. Here, `black` is used as an example.

```

pipx install git+https://github.com/psf/black.git
pipx install git+https://github.com/psf/black.git@branch # branch of your choice
pipx install git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 # git hash
pipx install https://github.com/psf/black/archive/18.9b0.zip # install a release
pipx install git+https://github.com/psf/black.git@branch # branch of your choice
pipx install git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 # git hash
pipx install https://github.com/psf/black/archive/18.9b0.zip # install a release

```

The pip syntax with `egg` must be used when installing extras:
Expand All @@ -187,23 +187,28 @@ A nice side benefit is that you don't have to remember to upgrade the app since
Okay, let's see what this looks like in practice!

```

pipx run APP [ARGS...]

```

This will install the package in an isolated, temporary directory and invoke the app. Give it a try:

```

> pipx run pycowsay moo

---
---

< moo >
---
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

---

\ ^**^
\ (oo)\_\_\_\_\_**
(\_\_)\ )\/\
||----w |
|| ||

```

Expand All @@ -212,16 +217,20 @@ Notice that you **don't need to execute any install commands to run the app**.
Any arguments after the application name will be passed directly to the application:

```

> pipx run pycowsay these arguments are all passed to pycowsay!

-------------------------------------------
---

< these arguments are all passed to pycowsay! >
-------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

---

\ ^**^
\ (oo)\_\_\_\_\_**
(\_\_)\ )\/\
||----w |
|| ||

```

Expand All @@ -230,33 +239,41 @@ Re-running the same app is quick because pipx caches Virtual Environments on a p
If the app name does not match that package name, you can use the `--spec` argument to specify the package to install and app to run separately:

```

pipx run --spec PACKAGE APP

```

You can also specify specific versions, version ranges, or extras:

```

pipx run APP==1.0.0

```

### Running from Source Control

You can also run from a git repository. Here, `black` is used as an example.

```

pipx run --spec git+https://github.com/psf/black.git black
pipx run --spec git+https://github.com/psf/black.git@branch black # branch of your choice
pipx run --spec git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 black # git hash
pipx run --spec git+https://github.com/psf/black.git@branch black # branch of your choice
pipx run --spec git+https://github.com/psf/black.git@ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 black # git hash
pipx run --spec https://github.com/psf/black/archive/18.9b0.zip black # install a release

```

### Running from URL

You can run .py files directly, too.

```

pipx run https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py
pipx is working!

```

### Summary
Expand Down
Loading