Skip to content

Commit

Permalink
Always build C extension on CPython but use it only if PURE_PYTHON is…
Browse files Browse the repository at this point in the history
… not set.
  • Loading branch information
Michael Howitz committed Jul 21, 2021
1 parent a2f1f0a commit 6645417
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
# PyPy won't build the extension
py_impl = getattr(platform, 'python_implementation', lambda: None)
is_pypy = py_impl() == 'PyPy'
is_pure = int(os.environ.get('PURE_PYTHON', '0'))
if is_pypy or is_pure:
if is_pypy:
ext_modules = []
else:
ext_modules = [
Expand Down
16 changes: 9 additions & 7 deletions src/Persistence/tests/test_persistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import time
import unittest

from Persistence import CAPI
from Persistence import IS_PYPY
from Persistence import Persistent
from persistent import PickleCache
from persistent.TimeStamp import TimeStamp
Expand Down Expand Up @@ -228,11 +230,11 @@ def testGetattribute(self):
# TODO: Need to decide how __setattr__ and __delattr__ should work,
# then write tests.

@unittest.skipIf(IS_PYPY, 'PyPy never has a C module.')
def test_compilation(self):
from Persistence import CAPI
if not CAPI:
with self.assertRaises((AttributeError, ImportError)):
from Persistence import _Persistence
else: # pragma: no cover
from Persistence import _Persistence
self.assertTrue(hasattr(_Persistence, 'Persistent'))
import persistent.cPersistence # noqa: F401 unused (needed for Py3)
from Persistence import _Persistence
if CAPI: # pragma: no cover
self.assertEqual(Persistent, _Persistence.Persistent)
else:
self.assertNotEqual(Persistent, _Persistence.Persistent)

0 comments on commit 6645417

Please sign in to comment.