Skip to content

Commit

Permalink
Change venv_metadata_inspector to support venv python 3.5+ (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsayellow authored and Chad Smith committed Oct 20, 2019
1 parent cf2a9ee commit e835671
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ optional arguments:
PIPX_BIN_DIR
--python PYTHON The Python executable used to create the Virtual
Environment and run the associated app/apps. Must be
v3.3+.
v3.5+.
--system-site-packages
Give the virtual environment access to the system
site-packages dir.
Expand Down Expand Up @@ -152,7 +152,7 @@ optional arguments:
git+https://github.com/user/repo.git@branch`
--verbose
--python PYTHON The Python version to run package's CLI app with. Must
be v3.3+.
be v3.5+.
--system-site-packages
Give the virtual environment access to the system
site-packages dir.
Expand Down
4 changes: 2 additions & 2 deletions pipx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _add_install(subparsers):
default=constants.DEFAULT_PYTHON,
help=(
"The Python executable used to create the Virtual Environment and run the "
"associated app/apps. Must be v3.3+."
"associated app/apps. Must be v3.5+."
),
)
add_pip_venv_args(p)
Expand Down Expand Up @@ -469,7 +469,7 @@ def _add_run(subparsers):
p.add_argument(
"--python",
default=constants.DEFAULT_PYTHON,
help="The Python version to run package's CLI app with. Must be v3.3+.",
help="The Python version to run package's CLI app with. Must be v3.5+.",
)
add_pip_venv_args(p)

Expand Down
6 changes: 4 additions & 2 deletions pipx/venv_metadata_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def main():

apps = get_apps(package, bin_path)
app_paths = [str(Path(bin_path) / app) for app in apps]
app_paths_of_dependencies: Dict[str, List[str]] = {}
app_paths_of_dependencies = {} # type: Dict[str, List[str]]
app_paths_of_dependencies = _dfs_package_apps(
bin_path, package, app_paths_of_dependencies
)
Expand All @@ -96,7 +96,9 @@ def main():
"app_paths": app_paths,
"app_paths_of_dependencies": app_paths_of_dependencies,
"package_version": get_package_version(package),
"python_version": f"Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
"python_version": "Python {}.{}.{}".format(
sys.version_info.major, sys.version_info.minor, sys.version_info.micro
),
}

print(json.dumps(output))
Expand Down
12 changes: 12 additions & 0 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
import sys
from unittest import mock
from shutil import which


import pytest # type: ignore

Expand All @@ -12,6 +14,9 @@
assert_not_in_virtualenv()


PYTHON3_5 = which("python3.5")


def test_help_text(monkeypatch, capsys):
mock_exit = mock.Mock(side_effect=ValueError("raised in test to exit early"))
with mock.patch.object(sys, "exit", mock_exit), pytest.raises(
Expand Down Expand Up @@ -122,3 +127,10 @@ def test_existing_symlink_points_to_nothing(pipx_temp_env, caplog, capsys):
# pipx should realize the symlink points to nothing and replace it,
# so no warning should be present
assert "symlink missing or pointing to unexpected location" not in captured.out


def test_install_python3_5(pipx_temp_env):
if PYTHON3_5:
assert not run_pipx_cli(["install", "cowsay", "--python", PYTHON3_5])
else:
pytest.skip("python3.5 not on PATH")

0 comments on commit e835671

Please sign in to comment.