8000 DEV, BUILD: add pypy3 to azure CI by mattip · Pull Request #12594 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DEV, BUILD: add pypy3 to azure CI #12594

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

Merged
merged 4 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TEST: update for PyPy
  • Loading branch information
mattip committed Apr 17, 2019
commit e67f8c7f78291cec03de944ed121d3e0f2a89c36
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ cythonize.dat
numpy/random/mtrand/mtrand.c
numpy/random/mtrand/randint_helpers.pxi
# CI run of PyPy
pypy3.5-latest
pypy3
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ jobs:
failTaskOnFailedTests: true
testRunTitle: 'Publish test results for Python $(PYTHON_VERSION) $(BITS)-bit $(TEST_MODE) Windows'

- job: Linux_PyPy3_latest_nightly
- job: Linux_PyPy3
pool:
vmIMage: 'ubuntu-16.04'
steps:
- script: source tools/azure-pypy-test.sh
displayName: 'Run PyPy3.5 Build / Tests'
- script: source tools/pypy-test.sh
displayName: 'Run PyPy3 Build / Tests'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-*.xml'
testRunTitle: 'Publish test results for PyPy3.5'
testRunTitle: 'Publish test results for PyPy3'
8 changes: 7 additions & 1 deletion numpy/core/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import re
import sys
import platform

from numpy.compat import unicode
from .multiarray import dtype, array, ndarray
Expand All @@ -16,6 +17,8 @@
except ImportError:
ctypes = None

IS_PYPY = platform.python_implementation() == 'PyPy'

if (sys.byteorder == 'little'):
_nbo = b'<'
else:
Expand Down Expand Up @@ -865,7 +868,10 @@ def npy_ctypes_check(cls):
try:
# ctypes class are new-style, so have an __mro__. This probably fails
# for ctypes classes with multiple inheritance.
ctype_base = cls.__mro__[-2]
if IS_PYPY:
ctype_base = cls.__mro__[-3]
else:
ctype_base = cls.__mro__[-2]
# right now, they're part of the _ctypes module
return 'ctypes' in ctype_base.__module__
except Exception:
Expand Down
15 changes: 8 additions & 7 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_writeable_from_buffer(self):
assert_(vals.flags.writeable)

@pytest.mark.skipif(sys.version_info[0] < 3, reason="Python 2 always copies")
@pytest.mark.skipif(IS_PYPY, reason="PyPy always copies")
def test_writeable_pickle(self):
import pickle
# Small arrays will be copied without setting base.
Expand Down Expand Up @@ -3783,7 +3784,7 @@ def test_roundtrip(self):
a, pickle.loads(pickle.dumps(a, protocol=proto)),
err_msg="%r" % a)
del a, DATA, carray
gc.collect()
gc.collect(); gc.collect(); gc.collect()
# check for reference leaks (gh-12793)
for ref in refs:
assert ref() is None
Expand Down Expand Up @@ -7180,7 +7181,7 @@ def test_mem_seteventhook(self):
# needs to be larger then limit of small memory cacher in ctors.c
a = np.zeros(1000)
del a
gc.collect()
gc.collect(); gc.collect(); gc.collect()
_multiarray_tests.test_pydatamem_seteventhook_end()

class TestMapIter(object):
Expand Down Expand Up @@ -7752,12 +7753,12 @@ def test_ctypes_data_as_holds_reference(self, arr):

# `ctypes_ptr` should hold onto `arr`
del arr
gc.collect()
gc.collect(); gc.collect(); gc.collect()
assert_(arr_ref() is not None, "ctypes pointer did not hold onto a reference")

# but when the `ctypes_ptr` object dies, so should `arr`
del ctypes_ptr
gc.collect()
gc.collect(); gc.collect(); gc.collect()
assert_(arr_ref() is None, "unknowable whether ctypes pointer holds a reference")


Expand Down Expand Up @@ -7939,15 +7940,15 @@ class Dummy(object): pass
assert_(isinstance(obj_subarray, RaisesInFinalize))

# reference should still be held by obj_arr
gc.collect()
gc.collect(); gc.collect(); gc.collect()
assert_(obj_ref() is not None, "object should not already be dead")

del obj_arr
gc.collect()
gc.collect(); gc.collect(); gc.collect()
assert_(obj_ref() is not None, "obj_arr should not hold the last reference")

del obj_subarray
gc.collect()
gc.collect(); gc.collect(); gc.collect()
assert_(obj_ref() is None, "no references should remain")


Expand Down
3 changes: 2 additions & 1 deletion numpy/core/tests/test_numerictypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises
from numpy.testing import assert_, assert_equal, assert_raises, IS_PYPY

# This is the structure of the table used for plain objects:
#
Expand Down Expand Up @@ -491,6 +491,7 @@ def test_issctype(rep, expected):

@pytest.mark.skipif(sys.flags.optimize > 1,
reason="no docstrings present to inspect when PYTHONOPTIMIZE/Py_OptimizeFlag > 1")
@pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc")
class TestDocStrings(object):
def test_platform_dependent_aliases(self):
if np.int64 is np.int_:
Expand Down
3 changes: 2 additions & 1 deletion numpy/f2py/tests/test_block_docstring.py
D8F7
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from . import util

from numpy.testing import assert_equal
from numpy.testing import assert_equal, IS_PYPY

class TestBlockDocString(util.F2PyTest):
code = """
Expand All @@ -18,6 +18,7 @@ class TestBlockDocString(util.F2PyTest):

@pytest.mark.skipif(sys.platform=='win32',
reason='Fails with MinGW64 Gfortran (Issue #9673)')
@pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc")
def test_block_docstring(self):
expected = "'i'-array(2,3)\n"
assert_equal(self.module.block.__doc__, expected)
3 changes: 2 additions & 1 deletion numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from numpy import ma
from numpy.testing import (
assert_, assert_equal, assert_array_equal, assert_almost_equal,
assert_array_almost_equal, assert_raises, assert_allclose,
assert_array_almost_equal, assert_raises, assert_allclose, IS_PYPY,
assert_warns, assert_raises_regex, suppress_warnings, HAS_REFCOUNT,
)
import numpy.lib.function_base as nfb
Expand Down Expand Up @@ -3177,6 +3177,7 @@ def test_string_arg(self):
class TestAdd_newdoc(object):

@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
@pytest.mark.xfail(IS_PYPY, reason="PyPy does not modify tp_doc")
def test_add_doc(self):
# test np.add_newdoc
tgt = "Current flat index into the array."
Expand Down
10 changes: 0 additions & 10 deletions tools/azure-pypy-test.sh

This file was deleted.

11 changes: 11 additions & 0 deletions tools/pypy-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

apt-get -yq update
apt-get -yq install libatlas-dev libatlas-base-dev liblapack-dev
wget http://buildbot.pypy.org/nightly/py3.6/pypy-c-jit-latest-linux64.tar.bz2 -O pypy.tar.bz2
mkdir -p pypy3
(cd pypy3; tar --strip-components=1 -xf ../pypy.tar.bz2)
pypy3/bin/pypy3 -mensurepip
pypy3/bin/pypy3 -m pip install --upgrade pip setuptools
pypy3/bin/pypy3 -m pip install --user cython==0.29.0 pytest pytz --no-warn-script-location
pypy3/bin/pypy3 runtests.py -- -rsx --junitxml=junit/test-results.xml --durations 10
0