Skip to content

Commit a497ed7

Browse files
committed
Move py launch finder to main module
1 parent 1dceb7a commit a497ed7

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

src/pipx/commands/install.py

-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pipx import constants
55
from pipx.commands.common import package_name_from_spec, run_post_install_actions
66
from pipx.constants import EXIT_CODE_INSTALL_VENV_EXISTS, EXIT_CODE_OK, ExitCode
7-
from pipx.interpreter import find_py_launcher_python
87
from pipx.util import pipx_wrap
98
from pipx.venv import Venv, VenvContainer
109

@@ -27,11 +26,6 @@ def install(
2726
# package_spec is anything pip-installable, including package_name, vcs spec,
2827
# zip file, or tar.gz file.
2928

30-
if constants.WINDOWS and python and not Path(python).is_file():
31-
py_launcher = find_py_launcher_python(python)
32-
if py_launcher:
33-
python = py_launcher
34-
3529
if package_name is None:
3630
package_name = package_name_from_spec(
3731
package_spec, python, pip_args=pip_args, verbose=verbose

src/pipx/main.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pipx.colors import bold, green
2626
from pipx.constants import WINDOWS, ExitCode
2727
from pipx.emojis import hazard
28-
from pipx.interpreter import DEFAULT_PYTHON
28+
from pipx.interpreter import DEFAULT_PYTHON, find_py_launcher_python
2929
from pipx.util import PipxError, mkdir, pipx_wrap, rmdir
3030
from pipx.venv import VenvContainer
3131
from pipx.version import __version__
@@ -181,6 +181,10 @@ def run_pipx_command(args: argparse.Namespace) -> ExitCode: # noqa: C901
181181
logger.info(f"Virtual Environment location is {venv_dir}")
182182
if "skip" in args:
183183
skip_list = [canonicalize_name(x) for x in args.skip]
184+
if "python" in args and WINDOWS and not Path(args.python).is_file():
185+
py_launcher = find_py_launcher_python(args.python)
186+
if py_launcher:
187+
args.python = py_launcher
184188

185189
if args.command == "run":
186190
commands.run(

tests/test_install.py

-9
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,3 @@ def test_install_local_archive(pipx_temp_env, monkeypatch, capsys):
262262
assert not run_pipx_cli(["install", "repeatme-0.1-py3-none-any.whl"])
263263
captured = capsys.readouterr()
264264
assert f"- {app_name('repeatme')}\n" in captured.out
265-
266-
267-
@pytest.mark.skipif(
268-
not sys.platform.startswith("win"), reason="uses windows version format"
269-
)
270-
def test_install_with_python_windows(capsys, pipx_temp_env):
271-
run_pipx_cli(["install", "pycowsay", "--python", "3.11"])
272-
captured = capsys.readouterr()
273-
assert "Python 3.11" in captured.out

0 commit comments

Comments
 (0)