Skip to content

Commit

Permalink
use python -m pip instead of pip (pypa#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Nov 2, 2018
1 parent 1ab571e commit 500d3a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 5 additions & 3 deletions get-pipx.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def __init__(self, path, *, verbose=False, python=sys.executable):
self.root = path
self._python = python
self.bin_path = path / "bin" if not WINDOWS else path / "Scripts"
self.pip_path = self.bin_path / ("pip" if not WINDOWS else "pip.exe")
self.python_path = self.bin_path / ("python" if not WINDOWS else "python.exe")
self.verbose = verbose

Expand All @@ -81,7 +80,7 @@ def upgrade_package(self, package):
self._run_pip(["install", "--upgrade", package])

def _run_pip(self, cmd):
cmd = [self.pip_path] + cmd
cmd = [self.python_path, "-m", "pip"] + cmd
if not self.verbose:
cmd.append("-q")
_run(cmd)
Expand Down Expand Up @@ -225,7 +224,10 @@ def main(argv=sys.argv[1:]):
if args.overwrite:
echo(f"Overwriting existing pipx installation at {str(pipx_venv)!r}")
else:
succeed("You already have pipx installed. Type `pipx` to run.")
succeed(
"You already have pipx installed. Pass the `--overwrite` flag to reinstall. "
"Type `pipx` to run."
)
elif pipx_exposed_binary.is_symlink() and pipx_exposed_binary.resolve().is_file():
echo("pipx is already installed but not on your PATH")
ensure_pipx_on_path(local_bin_dir, not args.no_modify_path)
Expand Down
5 changes: 1 addition & 4 deletions pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ def __init__(
self.root = path
self._python = python
self.bin_path = path / "bin" if not WINDOWS else path / "Scripts"
self.pip_path = self.bin_path / ("pip" if not WINDOWS else "pip.exe")
self.python_path = self.bin_path / ("python" if not WINDOWS else "python.exe")
self.verbose = verbose
self.do_animation = not verbose

def create_venv(self) -> None:
with animate("creating virtual environment", self.do_animation):
_run([self._python, "-m", "venv", self.root])
if not self.pip_path.exists():
raise PipxError(f"Expected to find pip at {str(self.pip_path)}")
self.upgrade_package("pip")

def remove_venv(self) -> None:
Expand Down Expand Up @@ -190,7 +187,7 @@ def upgrade_package(self, package_or_url: str):
self._run_pip(["install", "--upgrade", package_or_url])

def _run_pip(self, cmd):
cmd = [self.pip_path] + cmd
cmd = [self.python_path, "-m", "pip"] + cmd
if not self.verbose:
cmd.append("-q")
return _run(cmd)
Expand Down

0 comments on commit 500d3a8

Please sign in to comment.