From 7a66bec717f8b12830de27214b0ad605fd212dfb Mon Sep 17 00:00:00 2001 From: Matthew Clapp Date: Sat, 19 Oct 2019 22:00:27 -0700 Subject: [PATCH] Merge pull request #251 from itsayellow/fix_logging --- docs/docs.md | 4 ++-- pipx/SharedLibs.py | 4 ++-- pipx/main.py | 4 ++-- pipx/venv_metadata_inspector.py | 6 ++++-- tests/test_install.py | 12 ++++++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 7a8b5d2eb9..5e078bdff7 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -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. @@ -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. diff --git a/pipx/SharedLibs.py b/pipx/SharedLibs.py index 041a7cdf8c..50bb850730 100644 --- a/pipx/SharedLibs.py +++ b/pipx/SharedLibs.py @@ -39,9 +39,9 @@ def is_valid(self): def upgrade(self, pip_args: List[str], verbose: bool = False): # Don't try to upgrade multiple times per run if self.has_been_updated_this_run: - logging.info("Already upgraded libraries in", self.root) + logging.info(f"Already upgraded libraries in {self.root}") return - logging.info("Upgrading shared libraries in", self.root) + logging.info(f"Upgrading shared libraries in {self.root}") ignored_args = ["--editable"] _pip_args = [arg for arg in pip_args if arg not in ignored_args] diff --git a/pipx/main.py b/pipx/main.py index a84d3f8f70..fc7503c8ba 100644 --- a/pipx/main.py +++ b/pipx/main.py @@ -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) @@ -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) diff --git a/pipx/venv_metadata_inspector.py b/pipx/venv_metadata_inspector.py index 4224efa21f..020addd666 100644 --- a/pipx/venv_metadata_inspector.py +++ b/pipx/venv_metadata_inspector.py @@ -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 ) @@ -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)) diff --git a/tests/test_install.py b/tests/test_install.py index f52eec8c20..8df13cb8f3 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -3,6 +3,8 @@ import os import sys from unittest import mock +from shutil import which + import pytest # type: ignore @@ -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( @@ -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")