Skip to content

Commit f7c0bd3

Browse files
sontekaholmberg
authored andcommitted
Enable C extensions on pypy and add pypy3 support
Conflicts: tox.ini
1 parent 376cb0c commit f7c0bd3

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

cassandra/murmur3.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ typedef int Py_ssize_t;
2020
#define PY_SSIZE_T_MIN INT_MIN
2121
#endif
2222

23+
#ifdef PYPY_VERSION
24+
#define COMPILING_IN_PYPY 1
25+
#define COMPILING_IN_CPYTHON 0
26+
#else
27+
#define COMPILING_IN_PYPY 0
28+
#define COMPILING_IN_CPYTHON 1
29+
#endif
2330
//-----------------------------------------------------------------------------
2431
// Platform-specific functions and macros
2532

@@ -179,7 +186,8 @@ struct module_state {
179186
PyObject *error;
180187
};
181188

182-
#if PY_MAJOR_VERSION >= 3
189+
// pypy3 doesn't have GetState yet.
190+
#if COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
183191
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
184192
#else
185193
#define GETSTATE(m) (&_state)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def run_setup(extensions):
235235
**kw)
236236

237237
is_windows = os.name == 'nt'
238+
238239
if is_windows:
239240
build_extensions.error_message = """
240241
===============================================================================
@@ -291,8 +292,7 @@ def run_setup(extensions):
291292

292293
if extensions:
293294
if (sys.platform.startswith("java")
294-
or sys.platform == "cli"
295-
or "PyPy" in sys.version):
295+
or sys.platform == "cli"):
296296
sys.stderr.write(platform_unsupported_msg)
297297
extensions = ()
298298
elif sys.byteorder == "big":

tox.ini

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{26,27,33,34},pypy
2+
envlist = py{26,27,33,34},pypy,pypy3
33

44
[base]
55
deps = nose
@@ -20,6 +20,13 @@ commands = nosetests --verbosity=2 --no-path-adjustment {toxinidir}/tests/unit/
2020

2121
[testenv:pypy]
2222
deps = {[base]deps}
23-
commands = nosetests --verbosity=2 {toxinidir}/tests/unit/
23+
commands = {envpython} setup.py build_ext --inplace
24+
nosetests --verbosity=2 tests/unit/
25+
26+
[testenv:pypy3]
27+
deps = {[base]deps}
28+
commands = {envpython} setup.py build_ext --inplace
29+
nosetests --verbosity=2 tests/unit/
30+
2431
# cqlengine/test_timestamp.py uses sure, which fails in pypy presently
2532
# could remove sure usage

0 commit comments

Comments
 (0)