Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore python3.4 support (add it back to CI) #1965

Merged
merged 7 commits into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,5 @@ source =
[coverage:run]
branch = false
parallel = true
dynamic_context = test_function
source =
${_COVERAGE_SRC}

[coverage:html]
show_contexts = true
3 changes: 2 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
- 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: |
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog/1962.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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`.
1 change: 1 addition & 0 deletions docs/changelog/1963.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Python 3.4 incompatibilities (added back to the CI) - by :user:`gaborbernat`.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ docs =
sphinx-rtd-theme>=0.4.3
towncrier>=19.9.0rc1
testing =
coverage>=5
coverage>=4
coverage_enable_subprocess>=1
flaky>=3
pytest>=4
Expand Down
4 changes: 1 addition & 3 deletions src/virtualenv/seed/embed/via_app_data/via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/virtualenv/seed/wheels/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import sys
from operator import eq, lt

import six

from virtualenv.util.path import Path
from virtualenv.util.six import ensure_str
from virtualenv.util.subprocess import Popen, subprocess
Expand Down Expand Up @@ -62,7 +60,7 @@ def download_wheel(distribution, version_spec, for_py_version, search_dirs, app_
out, err = process.communicate()
if process.returncode != 0:
kwargs = {"output": out}
if six.PY2:
if sys.version_info < (3, 5):
kwargs["output"] += err
else:
kwargs["stderr"] = err
Expand Down
24 changes: 21 additions & 3 deletions src/virtualenv/util/path/_pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def read_text(self, encoding=None, errors=None):
with self.open(mode="r", encoding=encoding, errors=errors) as f:
return f.read()

def read_bytes(self):
"""
Open the file in bytes mode, read it, and close the file.
"""
with self.open(mode="rb") as f:
return f.read()

def write_text(self, data, encoding=None, errors=None):
"""
Open the file in text mode, write to it, and close the file.
Expand All @@ -28,10 +35,21 @@ def write_text(self, data, encoding=None, errors=None):
with self.open(mode="w", encoding=encoding, errors=errors) as f:
return f.write(data)

def write_bytes(self, data):
"""
Open the file in bytes mode, write to it, and close the file.
"""
# type-check for the buffer interface before truncating the file
view = memoryview(data)
with self.open(mode="wb") as f:
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:
Expand Down
2 changes: 1 addition & 1 deletion tasks/__main__zipapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions tests/integration/test_run_int.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tests/unit/create/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions tests/unit/seed/embed/test_boostrap_link_via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/seed/embed/test_pip_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/seed/wheels/test_acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import pytest

from virtualenv.info import PY2
from virtualenv.seed.wheels.acquire import download_wheel, pip_wheel_env_run
from virtualenv.seed.wheels.embed import BUNDLE_FOLDER, get_embed_wheel
from virtualenv.seed.wheels.util import discover_wheels
Expand Down Expand Up @@ -44,7 +43,7 @@ def test_download_fails(mocker, for_py_version, session_app_data):
with pytest.raises(CalledProcessError) as context:
download_wheel("pip", "==1", for_py_version, [], session_app_data, as_path),
exc = context.value
if PY2:
if sys.version_info < (3, 5):
assert exc.output == "outerr"
else:
assert exc.output == "out"
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/seed/wheels/test_periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ envlist =
docs
isolated_build = true
skip_missing_interpreters = true
minversion = 3.14.0
minversion = 3.14

[testenv]
description = run tests with {basepython}
Expand All @@ -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 =
Expand All @@ -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
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]
Expand Down