Skip to content

Commit 542351d

Browse files
committed
Use diff instead of patch
1 parent 1d0d7cd commit 542351d

File tree

3 files changed

+188
-394
lines changed

3 files changed

+188
-394
lines changed

recipe/gh2146.diff

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
diff --git a/.travis.yml b/.travis.yml
2+
index d81cd8c7b..959e602d0 100644
3+
--- a/.travis.yml
4+
+++ b/.travis.yml
5+
@@ -143,8 +143,19 @@ matrix:
6+
# Test a PyPy 2.7 build
7+
- os: linux
8+
dist: trusty
9+
- env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
10+
- name: PyPy 5.8, Python 2.7, c++11, gcc 4.8
11+
+ env: PYPY=5.8.0 PYTHON=2.7 CPP=11 GCC=4.8
12+
+ name: PyPy 5.8.0, Python 2.7, c++11, gcc 4.8
13+
+ addons:
14+
+ apt:
15+
+ packages:
16+
+ - libblas-dev
17+
+ - liblapack-dev
18+
+ - gfortran
19+
+ # Test a PyPy 3.6 build
20+
+ - os: linux
21+
+ dist: trusty
22+
+ env: PYPY=7.3.0 PYTHON=3.6 CPP=11 GCC=4.8
23+
+ name: PyPy 7.3.0, Python 3.6, c++11, gcc 4.8
24+
addons:
25+
apt:
26+
packages:
27+
@@ -211,10 +222,17 @@ before_install:
28+
SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
29+
$SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
30+
else
31+
- if [ "$PYPY" = "5.8" ]; then
32+
+ if [ "$PYPY" = "5.8.0" ]; then
33+
curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
34+
PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
35+
CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
36+
+ elif [ -n "$PYPY" ]; then
37+
+ curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy${PYTHON:0:3}-v${PYPY}-linux64.tar.bz2 | tar xj
38+
+ PY_CMD=$PWD/pypy${PYTHON:0:3}-v${PYPY}-linux64/bin/pypy
39+
+ if [ "${PYTHON:0:1}" = "3" ]; then
40+
+ PY_CMD="${PY_CMD}3"
41+
+ fi
42+
+ CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
43+
else
44+
PY_CMD=python$PYTHON
45+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
46+
@@ -252,16 +270,14 @@ install:
47+
export CXXFLAGS="-stdlib=libc++"
48+
fi
49+
50+
- export NPY_NUM_BUILD_JOBS=2
51+
- echo "Installing pytest, numpy, scipy..."
52+
local PIP_CMD=""
53+
- if [ -n $PYPY ]; then
54+
- # For expediency, install only versions that are available on the extra index.
55+
- travis_wait 30 \
56+
- $PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
57+
- pytest numpy==1.15.4 scipy==1.2.0
58+
+ export NPY_NUM_BUILD_JOBS=2
59+
+ if [ -n "$PYPY" ]; then
60+
+ echo Installing "pytest"
61+
+ $PY_CMD -m pip install --user --upgrade pytest
62+
else
63+
- $PY_CMD -m pip install --user --upgrade pytest numpy scipy
64+
+ echo "Installing pytest, numpy, scipy..."
65+
+ $PY_CMD -m pip install --user --upgrade pytest numpy scipy
66+
fi
67+
echo "done."
68+
69+
diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h
70+
index edfa7de68..6fc9862fa 100644
71+
--- a/include/pybind11/detail/class.h
72+
+++ b/include/pybind11/detail/class.h
73+
@@ -15,7 +15,7 @@
74+
NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
75+
NAMESPACE_BEGIN(detail)
76+
77+
-#if PY_VERSION_HEX >= 0x03030000
78+
+#if PY_VERSION_HEX >= 0x03030000 && !defined(PYPY_VERSION)
79+
# define PYBIND11_BUILTIN_QUALNAME
80+
# define PYBIND11_SET_OLDPY_QUALNAME(obj, nameobj)
81+
#else
82+
@@ -448,7 +448,7 @@ extern "C" inline int pybind11_clear(PyObject *self) {
83+
/// Give instances of this type a `__dict__` and opt into garbage collection.
84+
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
85+
auto type = &heap_type->ht_type;
86+
-#if defined(PYPY_VERSION)
87+
+#if defined(PYPY_VERSION) && (PYPY_VERSION_NUM < 0x06000000)
88+
pybind11_fail(std::string(type->tp_name) + ": dynamic attributes are "
89+
"currently not supported in "
90+
"conjunction with PyPy!");
91+
diff --git a/include/pybind11/eval.h b/include/pybind11/eval.h
92+
index ea85ba1db..422e629f5 100644
93+
--- a/include/pybind11/eval.h
94+
+++ b/include/pybind11/eval.h
95+
@@ -66,6 +66,20 @@ void exec(const char (&s)[N], object global = globals(), object local = object()
96+
eval<eval_statements>(s, global, local);
97+
}
98+
99+
+#if defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x3000000
100+
+template <eval_mode mode = eval_statements>
101+
+object eval_file(str, object, object) {
102+
+ pybind11_fail("eval_file not supported in PyPy3. Use eval");
103+
+}
104+
+template <eval_mode mode = eval_statements>
105+
+object eval_file(str, object) {
106+
+ pybind11_fail("eval_file not supported in PyPy3. Use eval");
107+
+}
108+
+template <eval_mode mode = eval_statements>
109+
+object eval_file(str) {
110+
+ pybind11_fail("eval_file not supported in PyPy3. Use eval");
111+
+}
112+
+#else
113+
template <eval_mode mode = eval_statements>
114+
object eval_file(str fname, object global = globals(), object local = object()) {
115+
if (!local)
116+
@@ -113,5 +127,6 @@ object eval_file(str fname, object global = globals(), object local = object())
117+
throw error_already_set();
118+
return reinterpret_steal<object>(result);
119+
}
120+
+#endif
121+
122+
NAMESPACE_END(PYBIND11_NAMESPACE)
123+
diff --git a/tests/conftest.py b/tests/conftest.py
124+
index 57f681c66..82f9a0ed1 100644
125+
--- a/tests/conftest.py
126+
+++ b/tests/conftest.py
127+
@@ -215,6 +215,10 @@ def pytest_configure():
128+
pytest.requires_eigen_and_scipy = skipif(
129+
not have_eigen or not scipy, reason="eigen and/or scipy are not installed")
130+
pytest.unsupported_on_pypy = skipif(pypy, reason="unsupported on PyPy")
131+
+ pytest.unsupported_on_pypy3 = skipif(pypy and sys.version_info.major >= 3,
132+
+ reason="unsupported on PyPy3")
133+
+ pytest.unsupported_on_pypy_lt_6 = skipif(pypy and sys.pypy_version_info[0] < 6,
134+
+ reason="unsupported on PyPy<6")
135+
pytest.unsupported_on_py2 = skipif(sys.version_info.major < 3,
136+
reason="unsupported on Python 2.x")
137+
pytest.gc_collect = gc_collect
138+
diff --git a/tests/test_eval.py b/tests/test_eval.py
139+
index bda4ef6bf..94228e7d2 100644
140+
--- a/tests/test_eval.py
141+
+++ b/tests/test_eval.py
142+
@@ -1,4 +1,5 @@
143+
import os
144+
+import pytest
145+
from pybind11_tests import eval_ as m
146+
147+
148+
@@ -10,8 +11,12 @@ def test_evals(capture):
149+
assert m.test_eval()
150+
assert m.test_eval_single_statement()
151+
152+
+ assert m.test_eval_failure()
153+
+
154+
+
155+
+@pytest.unsupported_on_pypy3
156+
+def test_eval_file():
157+
filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py")
158+
assert m.test_eval_file(filename)
159+
160+
- assert m.test_eval_failure()
161+
assert m.test_eval_file_failure()
162+
diff --git a/tests/test_multiple_inheritance.cpp b/tests/test_multiple_inheritance.cpp
163+
index ba1674fb2..70e341785 100644
164+
--- a/tests/test_multiple_inheritance.cpp
165+
+++ b/tests/test_multiple_inheritance.cpp
166+
@@ -193,7 +193,7 @@ TEST_SUBMODULE(multiple_inheritance, m) {
167+
.def_readwrite_static("static_value", &VanillaStaticMix2::static_value);
168+
169+
170+
-#if !defined(PYPY_VERSION)
171+
+#if !(defined(PYPY_VERSION) && (PYPY_VERSION_NUM < 0x06000000))
172+
struct WithDict { };
173+
struct VanillaDictMix1 : Vanilla, WithDict { };
174+
struct VanillaDictMix2 : WithDict, Vanilla { };
175+
diff --git a/tests/test_multiple_inheritance.py b/tests/test_multiple_inheritance.py
176+
index 475dd3b3d..1c493f397 100644
177+
--- a/tests/test_multiple_inheritance.py
178+
+++ b/tests/test_multiple_inheritance.py
179+
@@ -253,7 +253,7 @@ def test_mi_static_properties():
180+
assert d.static_value == 0
181+
182+
183+
-@pytest.unsupported_on_pypy
184+
+@pytest.unsupported_on_pypy_lt_6
185+
def test_mi_dynamic_attributes():
186+
"""Mixing bases with and without dynamic attribute support"""
187+

0 commit comments

Comments
 (0)