Skip to content

Commit 72bd386

Browse files
author
Chad Smith
authored
pass pip_args and verbose flag when determining package name (#321)
1 parent bbae6ff commit 72bd386

6 files changed

Lines changed: 35 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See Contributing for how to update this file.
2121
<a href="https://travis-ci.org/pipxproject/pipx"><img src="https://travis-ci.org/pipxproject/pipx.svg?branch=master" /></a>
2222

2323
<a href="https://pypi.python.org/pypi/pipx/">
24-
<img src="https://img.shields.io/badge/pypi-0.15.0.0-blue.svg" /></a>
24+
<img src="https://img.shields.io/badge/pypi-0.15.0.1-blue.svg" /></a>
2525
<a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
2626
</p>
2727

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.15.0.1
2+
3+
- [bugfix] pass pip arguments to pip when determining package name
4+
15
0.15.0.0
26

37
Upgrade instructions: When upgrading to 0.15.0.0 or above from a pre-0.15.0.0 version, you must re-install all packages to take advantage of the new persistent pipx metadata files introduced in this release. These metadata files store pip specification values, injected packages, any custom pip arguments, and more in each main package's venv. You can do this by running `pipx reinstall-all` or `pipx uninstall-all`, then reinstalling manually.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See Contributing for how to update this file.
2121
<a href="https://travis-ci.org/pipxproject/pipx"><img src="https://travis-ci.org/pipxproject/pipx.svg?branch=master" /></a>
2222

2323
<a href="https://pypi.python.org/pypi/pipx/">
24-
<img src="https://img.shields.io/badge/pypi-0.15.0.0-blue.svg" /></a>
24+
<img src="https://img.shields.io/badge/pypi-0.15.0.1-blue.svg" /></a>
2525
<a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
2626
</p>
2727

src/pipx/commands/commands.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def install(
3535
# zip file, or tar.gz file.
3636
# Determine package_name to properly name venv directory.
3737
if venv_dir is None or package_name is None:
38-
package_name = _package_name_from_spec(package_spec, python)
38+
package_name = _package_name_from_spec(
39+
package_spec, python, pip_args=pip_args, verbose=verbose
40+
)
3941
venv_container = VenvContainer(constants.PIPX_LOCAL_VENVS)
4042
venv_dir = venv_container.get_venv_dir(package_name)
4143

@@ -80,21 +82,23 @@ def install(
8082
raise
8183

8284

83-
def _package_name_from_spec(package_spec: str, python: str) -> str:
85+
def _package_name_from_spec(
86+
package_spec: str, python: str, *, pip_args: List[str], verbose: bool
87+
) -> str:
8488
start_time = time.time()
8589

86-
# shortcut if valid PYPI name and not a local path
90+
# shortcut if valid PyPI name and not a local path
8791
if valid_pypi_name(package_spec) and not Path(package_spec).exists():
8892
package_name = package_spec
8993
logging.info(f"Determined package name: {package_name}")
9094
logging.info(f"Package name determined in {time.time()-start_time:.1f}s")
9195
return package_name
9296

9397
with tempfile.TemporaryDirectory() as temp_venv_dir:
94-
venv = Venv(Path(temp_venv_dir), python=python)
98+
venv = Venv(Path(temp_venv_dir), python=python, verbose=verbose)
9599
venv.create_venv(venv_args=[], pip_args=[])
96100
package_name = venv.install_package_no_deps(
97-
package_or_url=package_spec, pip_args=[]
101+
package_or_url=package_spec, pip_args=pip_args
98102
)
99103

100104
logging.info(f"Package name determined in {time.time()-start_time:.1f}s")
@@ -205,7 +209,9 @@ def inject(
205209
# package_spec is anything pip-installable, including package_name, vcs spec,
206210
# zip file, or tar.gz file.
207211
if package_name is None:
208-
package_name = _package_name_from_spec(package_spec, venv.python)
212+
package_name = _package_name_from_spec(
213+
package_spec, venv.python, pip_args=pip_args, verbose=verbose
214+
)
209215

210216
venv.install_package(
211217
package=package_name,

src/pipx/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .util import PipxError, mkdir
2222
from .venv import VenvContainer
2323

24-
__version__ = "0.15.0.0"
24+
__version__ = "0.15.0.1"
2525

2626

2727
def simple_parse_version(s, segments=4) -> Tuple[Union[int, str], ...]:

tests/test_install.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,19 @@ def test_install_python3_5(pipx_temp_env):
148148
assert not run_pipx_cli(["install", "cowsay", "--python", PYTHON3_5])
149149
else:
150150
pytest.skip("python3.5 not on PATH")
151+
152+
153+
def test_pip_args_forwarded_to_package_name_determination(
154+
pipx_temp_env, caplog, capsys
155+
):
156+
assert run_pipx_cli(
157+
[
158+
"install",
159+
# use a valid spec and invalid pip args
160+
"https://github.com/ambv/black/archive/18.9b0.zip",
161+
"--verbose",
162+
"--pip-args='--asdf'",
163+
]
164+
)
165+
captured = capsys.readouterr()
166+
assert "Cannot determine package name from spec" in captured.err

0 commit comments

Comments
 (0)