diff --git a/README.md b/README.md
index a8924449f3..24f1b3f98c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,5 @@
# pipx - Execute binaries from Python packages in isolated environments
-**Under development, not for general use yet**
-
diff --git a/get-pipx.py b/get-pipx.py
index 766e5ea1de..100d8fea68 100644
--- a/get-pipx.py
+++ b/get-pipx.py
@@ -128,18 +128,14 @@ def get_fs_package_name(package):
def install(pipx_local_venvs, package, local_bin_dir, pipx_symlink, python, verbose):
-
- fs_package_name = get_fs_package_name(package)
- venv_dir = pipx_local_venvs / fs_package_name
-
+ venv_dir = pipx_local_venvs / "pipx"
venv_dir.mkdir(parents=True, exist_ok=True)
pipx_symlink.parent.mkdir(parents=True, exist_ok=True)
logging.info(f"virtualenv location is {venv_dir}")
venv = Venv(venv_dir, python=python, verbose=verbose)
venv.create_venv()
venv.install_package(package)
- binary_name = "pipx"
- binary = venv.bin_path / binary_name
+ binary = venv.bin_path / 'pipx'
if not binary.is_file():
fail(f"Expected to find {str(binary)}")
if pipx_symlink.is_file():
@@ -169,7 +165,7 @@ def parse_options(argv):
help="Don't configure the PATH environment variable",
)
parser.add_argument(
- "--ignore-existing",
+ "--overwrite",
action="store_true",
help=("reinstall pipx even if existing installation was found"),
)
@@ -195,8 +191,8 @@ def main(argv=sys.argv[1:]):
local_bin_dir = os.environ.get("PIPX_BIN_DIR", DEFAULT_PIPX_BIN_DIR)
pipx_symlink = local_bin_dir / "pipx"
if which("pipx"):
- if args.ignore_existing:
- echo("pipx is already installed. Ignoring installation and continuing.")
+ if args.overwrite:
+ echo("reinstalling pipx")
else:
succeed("You already have pipx installed. Type `pipx` to run.")
elif pipx_symlink.is_symlink() and pipx_symlink.resolve().is_file():
diff --git a/pipx/main.py b/pipx/main.py
index 89ce7b0427..c4f506c89c 100644
--- a/pipx/main.py
+++ b/pipx/main.py
@@ -136,7 +136,7 @@ def get_package_binary_paths(self, package):
def run_binary(self, binary, binary_args):
cmd = [self.bin_path / binary] + binary_args
try:
- _run(cmd, check=False)
+ return _run(cmd, check=False)
except KeyboardInterrupt:
pass
@@ -147,7 +147,7 @@ def _run_pip(self, cmd):
cmd = [self.pip_path] + cmd
if not self.verbose:
cmd.append("-q")
- _run(cmd)
+ return _run(cmd)
def _run(cmd, check=True):
@@ -156,6 +156,7 @@ def _run(cmd, check=True):
returncode = subprocess.run(cmd).returncode
if check and returncode:
raise PipxError(f"{cmd_str!r} failed")
+ return returncode
def rmdir(path):
@@ -180,7 +181,7 @@ def download_and_run(venv_dir, package, binary, binary_args, python, verbose):
f"{binary} not found in package {package}. Available binaries: "
f"{', '.join(b.name for b in binaries)}"
)
- venv.run_binary(binary, binary_args)
+ return venv.run_binary(binary, binary_args)
def symlink_package_binaries(local_bin_dir, binary_paths, package):
@@ -282,11 +283,11 @@ def install(venv_dir, package, package_or_url, local_bin_dir, python, verbose):
if venv.get_package_version(package) is None:
venv.remove_venv()
- raise PipxError("Could not find package {package} after installing. Is the name correct?")
- elif not binary_paths:
+ raise PipxError(f"Could not find package {package}. Is the name correct?")
+ binary_paths = venv.get_package_binary_paths(package)
+ if not binary_paths:
venv.remove_venv()
raise PipxError("No binaries associated with this package")
- binary_paths = venv.get_package_binary_paths(package)
logging.info(f"new binaries: {', '.join(str(b.name) for b in binary_paths)}")
symlink_package_binaries(local_bin_dir, binary_paths, package)
print("done! ✨ 🌟 ✨")
@@ -341,7 +342,7 @@ def run_pipx_command(args):
"package from a url, pass the --url flag."
)
if package == "pipx":
- print("isntalling pipx from url f{INSTALL_PIPX_URL}")
+ print(f"isntalling pipx from url {INSTALL_PIPX_URL}")
args.url = INSTALL_PIPX_URL
if "url" in args:
if urllib.parse.urlparse(args.url).scheme:
@@ -402,7 +403,7 @@ def run_ephemeral_binary(args, binary_args):
prefix=f"{get_fs_package_name(package)}_"
) as venv_dir:
logging.info(f"virtualenv is temporary, its location is {venv_dir}")
- download_and_run(
+ return download_and_run(
Path(venv_dir), package, binary, binary_args, args.python, verbose
)
@@ -576,12 +577,9 @@ def cli():
)
args = get_binary_parser(add_help=True).parse_args(pipx_args)
setup(args)
- run_ephemeral_binary(args, binary_args)
+ exit(run_ephemeral_binary(args, binary_args))
except PipxError as e:
- print(e)
- exit(1)
-
- exit(0)
+ exit(e)
if __name__ == "__main__":