Skip to content

Commit

Permalink
Move py launch finder to main module
Browse files Browse the repository at this point in the history
  • Loading branch information
danyeaw committed Jun 18, 2023
1 parent 1dceb7a commit a497ed7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/pipx/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pipx import constants
from pipx.commands.common import package_name_from_spec, run_post_install_actions
from pipx.constants import EXIT_CODE_INSTALL_VENV_EXISTS, EXIT_CODE_OK, ExitCode
from pipx.interpreter import find_py_launcher_python
from pipx.util import pipx_wrap
from pipx.venv import Venv, VenvContainer

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

if constants.WINDOWS and python and not Path(python).is_file():
py_launcher = find_py_launcher_python(python)
if py_launcher:
python = py_launcher

if package_name is None:
package_name = package_name_from_spec(
package_spec, python, pip_args=pip_args, verbose=verbose
Expand Down
6 changes: 5 additions & 1 deletion src/pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pipx.colors import bold, green
from pipx.constants import WINDOWS, ExitCode
from pipx.emojis import hazard
from pipx.interpreter import DEFAULT_PYTHON
from pipx.interpreter import DEFAULT_PYTHON, find_py_launcher_python
from pipx.util import PipxError, mkdir, pipx_wrap, rmdir
from pipx.venv import VenvContainer
from pipx.version import __version__
Expand Down Expand Up @@ -181,6 +181,10 @@ def run_pipx_command(args: argparse.Namespace) -> ExitCode: # noqa: C901
logger.info(f"Virtual Environment location is {venv_dir}")
if "skip" in args:
skip_list = [canonicalize_name(x) for x in args.skip]
if "python" in args and WINDOWS and not Path(args.python).is_file():
py_launcher = find_py_launcher_python(args.python)
if py_launcher:
args.python = py_launcher

if args.command == "run":
commands.run(
Expand Down
9 changes: 0 additions & 9 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,3 @@ def test_install_local_archive(pipx_temp_env, monkeypatch, capsys):
assert not run_pipx_cli(["install", "repeatme-0.1-py3-none-any.whl"])
captured = capsys.readouterr()
assert f"- {app_name('repeatme')}\n" in captured.out


@pytest.mark.skipif(
not sys.platform.startswith("win"), reason="uses windows version format"
)
def test_install_with_python_windows(capsys, pipx_temp_env):
run_pipx_cli(["install", "pycowsay", "--python", "3.11"])
captured = capsys.readouterr()
assert "Python 3.11" in captured.out

0 comments on commit a497ed7

Please sign in to comment.