From 3e2740bc8bd4a8d75e639ee7ce2a82b2fd1fae1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sun, 4 Oct 2020 16:37:56 +0100 Subject: [PATCH] Fixes --- .github/workflows/check.yml | 4 ++-- docs/changelog/1962.bugfix.rst | 2 +- docs/changelog/1963.bugfix.rst | 1 + src/virtualenv/seed/embed/via_app_data/via_app_data.py | 4 +--- src/virtualenv/util/path/_pathlib/__init__.py | 8 +++++--- tasks/__main__zipapp.py | 2 +- tests/integration/test_run_int.py | 7 +++++-- tests/unit/create/test_creator.py | 2 ++ tests/unit/seed/embed/test_boostrap_link_via_app_data.py | 1 + tests/unit/seed/embed/test_pip_invoke.py | 2 +- tests/unit/seed/wheels/test_periodic_update.py | 3 ++- tox.ini | 6 ++++-- 12 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 docs/changelog/1963.bugfix.rst diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0e60ac673..ab12a4290 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -29,12 +29,12 @@ jobs: - 3.7 - 3.6 - 3.5 - - 3.4 - pypy3 - 2.7 - pypy2 include: - - { os: MacOs, py: brew@py3 } + - { os: macos, py: brew@py3 } + - { os: ubuntu, py: 3.4.10 } steps: - name: Install OS dependencies run: | diff --git a/docs/changelog/1962.bugfix.rst b/docs/changelog/1962.bugfix.rst index 8dd3eba87..1832ccb86 100644 --- a/docs/changelog/1962.bugfix.rst +++ b/docs/changelog/1962.bugfix.rst @@ -1 +1 @@ -Fix Nonetype error in cygwin if POSIX path in dest - by :user:`danyeaw`. +Fix ``None`` type error in cygwin if POSIX path in dest - by :user:`danyeaw`. diff --git a/docs/changelog/1963.bugfix.rst b/docs/changelog/1963.bugfix.rst new file mode 100644 index 000000000..27027cfc7 --- /dev/null +++ b/docs/changelog/1963.bugfix.rst @@ -0,0 +1 @@ +Fix Python 3.4 incompatibilities (added back to the CI) - by :user:`gaborbernat`. diff --git a/src/virtualenv/seed/embed/via_app_data/via_app_data.py b/src/virtualenv/seed/embed/via_app_data/via_app_data.py index e59512808..1c6071946 100644 --- a/src/virtualenv/seed/embed/via_app_data/via_app_data.py +++ b/src/virtualenv/seed/embed/via_app_data/via_app_data.py @@ -8,8 +8,6 @@ from subprocess import CalledProcessError from threading import Lock, Thread -import six - from virtualenv.info import fs_supports_symlink from virtualenv.seed.embed.base_embed import BaseEmbed from virtualenv.seed.wheels import get_wheel @@ -104,7 +102,7 @@ def _get(distribution, version): if version is not None: msg += " version {}".format(version) msg += ", pip download exit code {}".format(failure.returncode) - output = failure.output if six.PY2 else (failure.output + failure.stderr) + output = failure.output if sys.version_info < (3, 5) else (failure.output + failure.stderr) if output: msg += "\n" msg += output diff --git a/src/virtualenv/util/path/_pathlib/__init__.py b/src/virtualenv/util/path/_pathlib/__init__.py index 84442b380..6bb045c2d 100644 --- a/src/virtualenv/util/path/_pathlib/__init__.py +++ b/src/virtualenv/util/path/_pathlib/__init__.py @@ -45,9 +45,11 @@ def write_bytes(self, data): return f.write(view) def mkdir(self, mode=0o777, parents=False, exist_ok=False): - if exist_ok and self.exists(): - return - super(type(BuiltinPath()), self).mkdir(mode, parents) + try: + super(type(BuiltinPath()), self).mkdir(mode, parents) + except FileExistsError as exception: + if not exist_ok: + raise exception else: diff --git a/tasks/__main__zipapp.py b/tasks/__main__zipapp.py index 26825cd3c..abf90c7a8 100644 --- a/tasks/__main__zipapp.py +++ b/tasks/__main__zipapp.py @@ -4,7 +4,7 @@ import zipfile ABS_HERE = os.path.abspath(os.path.dirname(__file__)) -NEW_IMPORT_SYSTEM = sys.version_info[0:2] > (3, 4) +NEW_IMPORT_SYSTEM = sys.version_info[0] == 3 class VersionPlatformSelect(object): diff --git a/tests/integration/test_run_int.py b/tests/integration/test_run_int.py index bf818bafb..26a6583db 100644 --- a/tests/integration/test_run_int.py +++ b/tests/integration/test_run_int.py @@ -1,19 +1,22 @@ from __future__ import absolute_import, unicode_literals +import sys + from virtualenv import cli_run from virtualenv.util.six import ensure_text from virtualenv.util.subprocess import run_cmd def test_app_data_pinning(tmp_path): - result = cli_run([ensure_text(str(tmp_path)), "--pip", "19.3.1", "--activators", "", "--seeder", "app-data"]) + version = "19.1.1" if sys.version_info[0:2] == (3, 4) else "19.3.1" + result = cli_run([ensure_text(str(tmp_path)), "--pip", version, "--activators", "", "--seeder", "app-data"]) code, out, err = run_cmd([str(result.creator.script("pip")), "list", "--disable-pip-version-check"]) assert not code assert not err for line in out.splitlines(): parts = line.split() if parts and parts[0] == "pip": - assert parts[1] == "19.3.1" + assert parts[1] == version break else: assert not out diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py index 97ab88c84..747d7935b 100644 --- a/tests/unit/create/test_creator.py +++ b/tests/unit/create/test_creator.py @@ -127,6 +127,8 @@ def system(session_app_data): ids=lambda i: "-".join(i) if isinstance(i, tuple) else i, ) def test_create_no_seed(python, creator, isolated, system, coverage_env, special_name_dir): + if creator[0] == "venv" and sys.version_info[0:2] == (3, 4): # venv on python3.4 only supports ascii chars + special_name_dir = special_name_dir.with_name(special_name_dir.name.encode("ascii", errors="ignore").decode()) dest = special_name_dir creator_key, method = creator cmd = [ diff --git a/tests/unit/seed/embed/test_boostrap_link_via_app_data.py b/tests/unit/seed/embed/test_boostrap_link_via_app_data.py index 934e007c3..d98f8dde1 100644 --- a/tests/unit/seed/embed/test_boostrap_link_via_app_data.py +++ b/tests/unit/seed/embed/test_boostrap_link_via_app_data.py @@ -22,6 +22,7 @@ def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies) bundle_ver = BUNDLE_SUPPORT[current.version_release_str] create_cmd = [ ensure_text(str(tmp_path / "en v")), # space in the name to ensure generated scripts work when path has space + "--no-periodic-update", "--seeder", "app-data", "--extra-search-dir", diff --git a/tests/unit/seed/embed/test_pip_invoke.py b/tests/unit/seed/embed/test_pip_invoke.py index 4c478dfe1..c033aa19d 100644 --- a/tests/unit/seed/embed/test_pip_invoke.py +++ b/tests/unit/seed/embed/test_pip_invoke.py @@ -41,7 +41,7 @@ def _execute(cmd, env): expected_list = list( itertools.chain.from_iterable(["--find-links", str(e)] for e in sorted(expected, key=lambda x: str(x))), ) - found = cmd[-len(expected_list) :] + found = cmd[-len(expected_list) :] if expected_list else [] assert "--no-index" not in cmd cmd.append("--no-index") assert found == expected_list diff --git a/tests/unit/seed/wheels/test_periodic_update.py b/tests/unit/seed/wheels/test_periodic_update.py index 96f2429cc..11729819d 100644 --- a/tests/unit/seed/wheels/test_periodic_update.py +++ b/tests/unit/seed/wheels/test_periodic_update.py @@ -53,8 +53,9 @@ def _do_update(distribution, for_py_version, embed_filename, app_data, search_di assert "upgrade pip" in caplog.text assert "upgraded pip" in caplog.text - assert " new entries found:\n\tNewVersion" in caplog.text assert " no new versions found" in caplog.text + assert " new entries found:\n" in caplog.text + assert "\tNewVersion(" in caplog.text packages = defaultdict(list) for i in do_update_mock.call_args_list: packages[i[1]["distribution"]].append(i[1]["for_py_version"]) diff --git a/tox.ini b/tox.ini index d1c2628fd..353032c53 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,7 @@ setenv = PYTHONIOENCODING = utf-8 _COVERAGE_SRC = {envsitepackagesdir}/virtualenv {py34,py27,pypy, upgrade}: PYTHONWARNINGS = ignore:DEPRECATION::pip._internal.cli.base_command - {pypy,py27}: PYTEST_XDIST = 0 + {py34,pypy,py27}: PYTEST_XDIST = 0 extras = testing commands = @@ -44,7 +44,9 @@ commands = python -m coverage combine python -m coverage report --skip-covered --show-missing python -m coverage xml -o {toxworkdir}/coverage.{envname}.xml - python -m coverage html -d {envtmpdir}/htmlcov --title virtualenv-{envname}-coverage + python -m coverage html -d {envtmpdir}/htmlcov \ + !py34: --show-contexts \ + --title virtualenv-{envname}-coverage install_command = python -m pip install {opts} {packages} --disable-pip-version-check [testenv:fix_lint]