From f71df6f9addca10b562bb22890b5ea1c37efde5c Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Mon, 25 Dec 2017 13:46:22 +0300 Subject: [PATCH 1/3] Run tests for PyPy3 --- .travis.yml | 9 +++++++++ tox.ini | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index e2e9e0cc1..6635f5d3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ matrix: env: TOXENV=jessie - python: 2.7 env: TOXENV=pypy + - python: 2.7 + env: TOXENV=pypy3 - python: 3.4 env: TOXENV=py34 - python: 3.5 @@ -30,6 +32,13 @@ install: virtualenv --python="$PYPY_VERSION/bin/pypy" "$HOME/virtualenvs/$PYPY_VERSION" source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" fi + if [ "$TOXENV" = "pypy3" ]; then + export PYPY_VERSION="pypy3.5-5.9-beta-linux_x86_64-portable" + wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2" + tar -jxf ${PYPY_VERSION}.tar.bz2 + virtualenv --python="$PYPY_VERSION/bin/pypy3" "$HOME/virtualenvs/$PYPY_VERSION" + source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate" + fi - pip install -U tox twine wheel codecov script: tox diff --git a/tox.ini b/tox.ini index 5c543475c..60ff8c15e 100644 --- a/tox.ini +++ b/tox.ini @@ -79,6 +79,12 @@ deps = {[testenv:py34]deps} basepython = python3.6 deps = {[testenv:py34]deps} +[testenv:pypy3] +basepython = pypy3 +deps = {[testenv:py34]deps} +commands = + py.test {posargs:scrapy tests} + [docs] changedir = docs deps = From 041308afe7c40de7088f75b0e0c312ecd5de428a Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Mon, 25 Dec 2017 14:27:20 +0300 Subject: [PATCH 2/3] Fix get_func_args test for pypy3 These built-in functions are exposed as methods in PyPy3. For scrapy this does not matter as: 1) they do not work for CPython at all 2) get_func_args is checked for presense of an argument in scrapy, extra "self" does not matter. But it still makes sense to leave these tests so that we know we shouldn't use get_func_args for built-in functions/methods. --- tests/test_utils_python.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_utils_python.py b/tests/test_utils_python.py index 115f523e9..f6133657b 100644 --- a/tests/test_utils_python.py +++ b/tests/test_utils_python.py @@ -219,9 +219,12 @@ class UtilsPythonTestCase(unittest.TestCase): self.assertEqual(get_func_args(" ".join), []) self.assertEqual(get_func_args(operator.itemgetter(2)), []) else: - self.assertEqual(get_func_args(six.text_type.split), ['sep', 'maxsplit']) - self.assertEqual(get_func_args(" ".join), ['list']) - self.assertEqual(get_func_args(operator.itemgetter(2)), ['obj']) + stripself = not six.PY2 # PyPy3 exposes them as methods + self.assertEqual( + get_func_args(six.text_type.split, stripself), ['sep', 'maxsplit']) + self.assertEqual(get_func_args(" ".join, stripself), ['list']) + self.assertEqual( + get_func_args(operator.itemgetter(2), stripself), ['obj']) def test_without_none_values(self): From bb1f31189128cb2272c1302350387075fbbb730a Mon Sep 17 00:00:00 2001 From: Konstantin Lopuhin Date: Mon, 25 Dec 2017 15:46:05 +0300 Subject: [PATCH 3/3] Add PyPy3 support to faq and install doc --- docs/faq.rst | 4 ++-- docs/intro/install.rst | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index 7eecc999f..7a0628f88 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -70,10 +70,10 @@ What Python versions does Scrapy support? ----------------------------------------- Scrapy is supported under Python 2.7 and Python 3.4+ -under CPython (default Python implementation) and PyPy (only for Python 2.7). +under CPython (default Python implementation) and PyPy (starting with PyPy 5.9). Python 2.6 support was dropped starting at Scrapy 0.20. Python 3 support was added in Scrapy 1.1. -PyPy support was added in Scrapy 1.4, PyPy version tested is PyPy2-v5.9.0. +PyPy support was added in Scrapy 1.4, PyPy3 support was added in Scrapy 1.5. .. note:: For Python 3 support on Windows, it is recommended to use diff --git a/docs/intro/install.rst b/docs/intro/install.rst index b00dc2cd6..4a9aa3cfb 100644 --- a/docs/intro/install.rst +++ b/docs/intro/install.rst @@ -8,7 +8,7 @@ Installing Scrapy ================= Scrapy runs on Python 2.7 and Python 3.4 or above -under CPython (default Python implementation) and PyPy (only for Python 2.7). +under CPython (default Python implementation) and PyPy (starting with PyPy 5.9). If you're using `Anaconda`_ or `Miniconda`_, you can install the package from the `conda-forge`_ channel, which has up-to-date packages for Linux, Windows @@ -227,7 +227,8 @@ After any of these workarounds you should be able to install Scrapy:: PyPy ---- -We recommend using the latest PyPy version. The version tested is PyPy2-v5.9.0. +We recommend using the latest PyPy version. The version tested is 5.9.0. +For PyPy3, only Linux installation was tested. Most scrapy dependencides now have binary wheels for CPython, but not for PyPy. This means that these dependecies will be built during installation.