Skip to content

Commit

Permalink
cast all Paths to str when running subprocesses; add .exe suffix (pyp…
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Nov 5, 2018
1 parent 500d3a8 commit 76ac69f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
22 changes: 9 additions & 13 deletions get-pipx.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def upgrade_package(self, package):
self._run_pip(["install", "--upgrade", package])

def _run_pip(self, cmd):
cmd = [self.python_path, "-m", "pip"] + cmd
cmd = [str(self.python_path), "-m", "pip"] + cmd
if not self.verbose:
cmd.append("-q")
_run(cmd)
Expand Down Expand Up @@ -111,23 +111,19 @@ def ensure_pipx_on_path(bin_dir, modify_path):
else:
f.write('export PATH="%s:$PATH"\n' % bin_dir)
echo("Added %s to the PATH environment variable in %s" % (bin_dir, config_file))
echo("")
echo("Open a new terminal to use pipx")
else:
echo(
textwrap.dedent(
"""
%(sep)s
f"""
Note:
To finish installation, {str(bin_dir)!r} must be added to your PATH.
This can be done by adding the following line to your shell
config file (such as ~/.bashrc if using bash):
Note:
To finish installation, %(bin_dir)s must be added to your PATH.
This can be done by adding the following line to your shell
config file:
export PATH=%(bin_dir)s:$PATH
%(sep)s
export PATH={str(bin_dir)}:$PATH
"""
% {"sep": "=" * 60, "bin_dir": bin_dir}
)
)

Expand All @@ -153,7 +149,7 @@ def install(
venv = Venv(venv_dir, python=python, verbose=verbose)
venv.create_venv()
venv.install_package(package)
binary = venv.bin_path / "pipx"
binary = venv.bin_path / "pipx" if not WINDOWS else venv.bin_path / "pipx.exe"
if not binary.is_file():
fail(f"Expected to find {str(binary)}")

Expand Down
10 changes: 6 additions & 4 deletions pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def get_package_dependencies(self, package: str) -> List[str]:
)
return (
subprocess.run(
[self.python_path, "-c", get_version_script], stdout=subprocess.PIPE
[str(self.python_path), "-c", get_version_script],
stdout=subprocess.PIPE,
)
.stdout.decode()
.split()
Expand All @@ -111,7 +112,7 @@ def get_package_version(self, package: str) -> Optional[str]:
)
version = (
subprocess.run(
[self.python_path, "-c", get_version_script],
[str(self.python_path), "-c", get_version_script],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
)
Expand Down Expand Up @@ -167,7 +168,8 @@ def get_package_binary_paths(self, package: str) -> List[Path]:
return []
binaries = (
subprocess.run(
[self.python_path, "-c", get_binaries_script], stdout=subprocess.PIPE
[str(self.python_path), "-c", get_binaries_script],
stdout=subprocess.PIPE,
)
.stdout.decode()
.split()
Expand Down Expand Up @@ -550,7 +552,7 @@ def run_ephemeral_binary(args, binary_args):
# download and run directly
r = requests.get(binary)
try:
exit(subprocess.run([args.python, "-c", r.content]).returncode)
exit(subprocess.run([str(args.python), "-c", r.content]).returncode)
except KeyboardInterrupt:
pass
exit(0)
Expand Down

0 comments on commit 76ac69f

Please sign in to comment.