Merge pull request #3025 from Kriechi/py36

Python 3.5 is dead -- long live Python 3.6!
This commit is contained in:
Aldo Cortesi 2018-04-01 08:59:47 +12:00 committed by GitHub
commit 53827a36ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 49 deletions

View File

@ -22,9 +22,6 @@ matrix:
osx_image: xcode7.3 osx_image: xcode7.3
language: generic language: generic
env: TOXENV=py36 BDIST=1 env: TOXENV=py36 BDIST=1
- python: 3.5
env: TOXENV=py35
dist: precise
- python: 3.6 - python: 3.6
env: TOXENV=py36 BDIST=1 WHEEL=1 env: TOXENV=py36 BDIST=1 WHEEL=1
- python: 3.6 - python: 3.6
@ -61,9 +58,9 @@ install:
brew update || brew update brew update || brew update
brew outdated pyenv || brew upgrade pyenv brew outdated pyenv || brew upgrade pyenv
eval "$(pyenv init -)" eval "$(pyenv init -)"
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing 3.6.4 env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing 3.6.5
pyenv global 3.6.4 pyenv global 3.6.5
pyenv shell 3.6.4 pyenv shell 3.6.5
fi fi
- pip install tox virtualenv setuptools - pip install tox virtualenv setuptools

View File

@ -73,14 +73,14 @@ security considerations apply as for our binary packages.
## Installation on Linux via pip3 ## Installation on Linux via pip3
Please make sure to install Python 3.5 (or higher) and pip3 for your Please make sure to install Python 3.6 (or higher) and pip3 for your
distribution. If your distribution does not provide a suitable Python distribution. If your distribution does not provide a suitable Python
version, you can use [pyenv](https://github.com/yyuu/pyenv) to get a version, you can use [pyenv](https://github.com/yyuu/pyenv) to get a
recent Python environment. recent Python environment.
{{< highlight bash >}} {{< highlight bash >}}
sudo apt install python3-pip # Debian 8 or higher, Ubuntu 16.04 or higher sudo apt install python3-pip # Debian 10 or higher, Ubuntu 17.10 or higher
sudo dnf install python3-pip # Fedora 24 or higher sudo dnf install python3-pip # Fedora 26 or higher
sudo pacman -S python-pip # Arch Linux sudo pacman -S python-pip # Arch Linux
{{< / highlight >}} {{< / highlight >}}
@ -98,7 +98,7 @@ sudo pip3 install mitmproxy
## Installation on Windows via pip3 ## Installation on Windows via pip3
First, install the latest version of Python 3.5 or higher from the First, install the latest version of Python 3.6 or higher from the
[Python website](https://www.python.org/downloads/windows/). During [Python website](https://www.python.org/downloads/windows/). During
installation, make sure to select Add Python to PATH. There are no other installation, make sure to select Add Python to PATH. There are no other
dependencies on Windows. dependencies on Windows.

View File

@ -19,7 +19,7 @@ from mitmproxy.coretypes import basethread
socket_fileobject = socket.SocketIO socket_fileobject = socket.SocketIO
# workaround for https://bugs.python.org/issue29515 # workaround for https://bugs.python.org/issue29515
# Python 3.5 and 3.6 for Windows is missing a constant # Python 3.6 for Windows is missing a constant
IPPROTO_IPV6 = getattr(socket, "IPPROTO_IPV6", 41) IPPROTO_IPV6 = getattr(socket, "IPPROTO_IPV6", 41)
EINTR = 4 EINTR = 4

View File

@ -2,11 +2,11 @@ from __future__ import print_function # this is here for the version check to w
import sys import sys
if sys.version_info < (3, 5): if sys.version_info < (3, 6):
# This must be before any mitmproxy imports, as they already break! # This must be before any mitmproxy imports, as they already break!
# Keep all other imports below with the 'noqa' magic comment. # Keep all other imports below with the 'noqa' magic comment.
print("#" * 49, file=sys.stderr) print("#" * 49, file=sys.stderr)
print("# mitmproxy only supports Python 3.5 and above! #", file=sys.stderr) print("# mitmproxy requires Python 3.6 or higher! #", file=sys.stderr)
print("#" * 49, file=sys.stderr) print("#" * 49, file=sys.stderr)
import argparse # noqa import argparse # noqa

View File

@ -7,26 +7,17 @@ Type = typing.Union[
def sequence_type(typeinfo: typing.Type[typing.List]) -> Type: def sequence_type(typeinfo: typing.Type[typing.List]) -> Type:
"""Return the type of a sequence, e.g. typing.List""" """Return the type of a sequence, e.g. typing.List"""
try:
return typeinfo.__args__[0] # type: ignore return typeinfo.__args__[0] # type: ignore
except AttributeError: # Python 3.5.0
return typeinfo.__parameters__[0] # type: ignore
def tuple_types(typeinfo: typing.Type[typing.Tuple]) -> typing.Sequence[Type]: def tuple_types(typeinfo: typing.Type[typing.Tuple]) -> typing.Sequence[Type]:
"""Return the types of a typing.Tuple""" """Return the types of a typing.Tuple"""
try:
return typeinfo.__args__ # type: ignore return typeinfo.__args__ # type: ignore
except AttributeError: # Python 3.5.x
return typeinfo.__tuple_params__ # type: ignore
def union_types(typeinfo: typing.Type[typing.Tuple]) -> typing.Sequence[Type]: def union_types(typeinfo: typing.Type[typing.Tuple]) -> typing.Sequence[Type]:
"""return the types of a typing.Union""" """return the types of a typing.Union"""
try:
return typeinfo.__args__ # type: ignore return typeinfo.__args__ # type: ignore
except AttributeError: # Python 3.5.x
return typeinfo.__union_params__ # type: ignore
def mapping_types(typeinfo: typing.Type[typing.Mapping]) -> typing.Tuple[Type, Type]: def mapping_types(typeinfo: typing.Type[typing.Mapping]) -> typing.Tuple[Type, Type]:

View File

@ -27,7 +27,7 @@ Make sure run all these steps on the correct branch you want to create a new rel
- Create a new branch based of master for major versions. - Create a new branch based of master for major versions.
- Update the dependencies in [alpine/requirements.txt](https://github.com/mitmproxy/docker-releases/commit/3d6a9989fde068ad0aea257823ac3d7986ff1613#diff-9b7e0eea8ae74688b1ac13ea080549ba) - Update the dependencies in [alpine/requirements.txt](https://github.com/mitmproxy/docker-releases/commit/3d6a9989fde068ad0aea257823ac3d7986ff1613#diff-9b7e0eea8ae74688b1ac13ea080549ba)
* Creating a fresh venv, pip-installing the new wheel in there, and then export all packages: * Creating a fresh venv, pip-installing the new wheel in there, and then export all packages:
* `virtualenv -ppython3.5 venv && source venv/bin/activate && pip install mitmproxy && pip freeze` * `virtualenv -ppython3.6 venv && source venv/bin/activate && pip install mitmproxy && pip freeze`
- Tag the commit with the correct version - Tag the commit with the correct version
* `2.0.0` for new major versions * `2.0.0` for new major versions
* `2.0.2` for new patch versions * `2.0.2` for new patch versions

View File

@ -35,7 +35,6 @@ setup(
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: CPython",
"Topic :: Security", "Topic :: Security",

2
test/filename_matching.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import os import os
import re import re
import glob import glob

2
test/individual_coverage.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import io import io
import contextlib import contextlib
import os import os

View File

@ -1,6 +1,5 @@
import io import io
import typing import typing
from unittest import mock
import pytest import pytest
from mitmproxy.utils import typecheck from mitmproxy.utils import typecheck
@ -32,12 +31,6 @@ def test_check_union():
with pytest.raises(TypeError): with pytest.raises(TypeError):
typecheck.check_option_type("foo", [], typing.Union[int, str]) typecheck.check_option_type("foo", [], typing.Union[int, str])
# Python 3.5 only defines __union_params__
m = mock.Mock()
m.__str__ = lambda self: "typing.Union"
m.__union_params__ = (int,)
typecheck.check_option_type("foo", 42, m)
def test_check_tuple(): def test_check_tuple():
typecheck.check_option_type("foo", (42, "42"), typing.Tuple[int, str]) typecheck.check_option_type("foo", (42, "42"), typing.Tuple[int, str])
@ -50,12 +43,6 @@ def test_check_tuple():
with pytest.raises(TypeError): with pytest.raises(TypeError):
typecheck.check_option_type("foo", ("42", 42), typing.Tuple[int, str]) typecheck.check_option_type("foo", ("42", 42), typing.Tuple[int, str])
# Python 3.5 only defines __tuple_params__
m = mock.Mock()
m.__str__ = lambda self: "typing.Tuple"
m.__tuple_params__ = (int, str)
typecheck.check_option_type("foo", (42, "42"), m)
def test_check_sequence(): def test_check_sequence():
typecheck.check_option_type("foo", [10], typing.Sequence[int]) typecheck.check_option_type("foo", [10], typing.Sequence[int])
@ -68,12 +55,6 @@ def test_check_sequence():
with pytest.raises(TypeError): with pytest.raises(TypeError):
typecheck.check_option_type("foo", "foo", typing.Sequence[str]) typecheck.check_option_type("foo", "foo", typing.Sequence[str])
# Python 3.5 only defines __parameters__
m = mock.Mock()
m.__str__ = lambda self: "typing.Sequence"
m.__parameters__ = (int,)
typecheck.check_option_type("foo", [10], m)
def test_check_io(): def test_check_io():
typecheck.check_option_type("foo", io.StringIO(), typing.IO[str]) typecheck.check_option_type("foo", io.StringIO(), typing.IO[str])

View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py35, py36, lint envlist = py36, lint
skipsdist = True skipsdist = True
toxworkdir={env:TOX_WORK_DIR:.tox} toxworkdir={env:TOX_WORK_DIR:.tox}
@ -21,7 +21,7 @@ commands =
commands = commands =
mitmdump --version mitmdump --version
flake8 --jobs 8 mitmproxy pathod examples test release flake8 --jobs 8 mitmproxy pathod examples test release
python test/filename_matching.py python ./test/filename_matching.py
rstcheck README.rst rstcheck README.rst
mypy --ignore-missing-imports ./mitmproxy ./pathod mypy --ignore-missing-imports ./mitmproxy ./pathod
mypy --ignore-missing-imports --follow-imports=skip ./examples/simple/ ./examples/pathod/ ./examples/complex/ mypy --ignore-missing-imports --follow-imports=skip ./examples/simple/ ./examples/pathod/ ./examples/complex/
@ -30,7 +30,7 @@ commands =
deps = deps =
-rrequirements.txt -rrequirements.txt
commands = commands =
python test/individual_coverage.py python ./test/individual_coverage.py
[testenv:cibuild] [testenv:cibuild]
passenv = TRAVIS_* AWS_* APPVEYOR_* RTOOL_KEY WHEEL passenv = TRAVIS_* AWS_* APPVEYOR_* RTOOL_KEY WHEEL