Skip to content

Commit

Permalink
Support PURE_PYTHON at runtime.
Browse files Browse the repository at this point in the history
Add failing tests and then fix them. Use a common function to DRY in
all the modules.

Fixes #78

Also use zope.testrunner in tox (and travis) because it allows passing
arguments to select what tests to run, see slow tests, etc.

Simplify setup.py to always build the C modules and avoid polluting
wheel caches (the same as zope.security and other projects that have
been worked on lately).

Bump the minimum 'persistent' requirement to one that actually works
in PURE_PYTHON mode (plus fix wheel metadata; otherwise we need
environment markers).

Test PURE_PYTHON in environments on Travis. Do some minor tuning to
eliminate redundant test cases and speed up test time.
  • Loading branch information
jamadden committed Mar 7, 2018
1 parent 822181c commit 5ddd044
Show file tree
Hide file tree
Showing 19 changed files with 289 additions and 443 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ matrix:
include:
- os: linux
python: 2.7
- os: linux
python: 2.7
env: PURE_PYTHON=1
- os: linux
python: 3.3
- os: linux
Expand All @@ -12,10 +15,13 @@ matrix:
python: 3.5
- os: linux
python: 3.6
- os: linux
python: 3.6
env: PURE_PYTHON=1
- os: linux
python: pypy
- os: linux
python: pypy3.3-5.2-alpha1
python: pypy3
# It's important to use 'macpython' builds to get the least
# restrictive wheel tag. It's also important to avoid
# 'homebrew 3' because it floats instead of being a specific version.
Expand Down Expand Up @@ -45,7 +51,7 @@ matrix:
before_install:
- if [[ $TRAVIS_TAG ]]; then bash .manylinux.sh; fi
- exit 0

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git clone https://github.com/MacPython/terryfy; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source terryfy/travis_tools.sh; fi
Expand All @@ -58,9 +64,9 @@ install:
# (https://travis-ci.org/zopefoundation/BTrees/jobs/192340692) so
# we install with pip manually.
- pip install -U persistent
- pip install -e .[ZODB]
- pip install -e .[test,ZODB]
script:
- python setup.py -q test -q
- zope-testrunner --test-path=. --auto-color --auto-progress
notifications:
email: false
after_success:
Expand Down
32 changes: 2 additions & 30 deletions BTrees/IFBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 120
_TREE_SIZE = 500
Expand Down Expand Up @@ -104,36 +105,7 @@ class IFTreeIteratorPy(_TreeIterator):
weightedUnionPy = _set_operation(_weightedUnion, IFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IFSetPy)

try:
from ._IFBTree import IFBucket
except ImportError: #pragma NO COVER w/ C extensions
IFBucket = IFBucketPy
IFSet = IFSetPy
IFBTree = IFBTreePy
IFTreeSet = IFTreeSetPy
IFTreeIterator = IFTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
weightedUnion = weightedUnionPy
weightedIntersection = weightedIntersectionPy
else: #pragma NO COVER w/o C extensions
from ._IFBTree import IFSet
from ._IFBTree import IFBTree
from ._IFBTree import IFTreeSet
from ._IFBTree import IFTreeIterator
from ._IFBTree import difference
from ._IFBTree import union
from ._IFBTree import intersection
from ._IFBTree import multiunion
from ._IFBTree import weightedUnion
from ._IFBTree import weightedIntersection

Bucket = IFBucket
Set = IFSet
BTree = IFBTree
TreeSet = IFTreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
34 changes: 3 additions & 31 deletions BTrees/IIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_int as _to_value
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 120
_TREE_SIZE = 500
Expand Down Expand Up @@ -105,36 +106,7 @@ class IITreeIteratorPy(_TreeIterator):
weightedUnionPy = _set_operation(_weightedUnion, IISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IISetPy)

try:
from ._IIBTree import IIBucket
except ImportError: #pragma NO COVER w/ C extensions
IIBucket = IIBucketPy
IISet = IISetPy
IIBTree = IIBTreePy
IITreeSet = IITreeSetPy
IITreeIterator = IITreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
weightedUnion = weightedUnionPy
weightedIntersection = weightedIntersectionPy
else: #pragma NO COVER w/o C extensions
from ._IIBTree import IISet
from ._IIBTree import IIBTree
from ._IIBTree import IITreeSet
from ._IIBTree import IITreeIterator
from ._IIBTree import difference
from ._IIBTree import union
from ._IIBTree import intersection
from ._IIBTree import multiunion
from ._IIBTree import weightedUnion
from ._IIBTree import weightedIntersection

Bucket = IIBucket
Set = IISet
BTree = IIBTree
TreeSet = IITreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
28 changes: 2 additions & 26 deletions BTrees/IOBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 60
_TREE_SIZE = 500
Expand Down Expand Up @@ -87,32 +88,7 @@ class IOTreeIteratorPy(_TreeIterator):
intersectionPy = _set_operation(_intersection, IOSetPy)
multiunionPy = _set_operation(_multiunion, IOSetPy)

try:
from ._IOBTree import IOBucket
except ImportError: #pragma NO COVER w/ C extensions
IOBucket = IOBucketPy
IOSet = IOSetPy
IOBTree = IOBTreePy
IOTreeSet = IOTreeSetPy
IOTreeIterator = IOTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
else: #pragma NO COVER w/o C extensions
from ._IOBTree import IOSet
from ._IOBTree import IOBTree
from ._IOBTree import IOTreeSet
from ._IOBTree import IOTreeIterator
from ._IOBTree import difference
from ._IOBTree import union
from ._IOBTree import intersection
from ._IOBTree import multiunion

Bucket = IOBucket
Set = IOSet
BTree = IOBTree
TreeSet = IOTreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
32 changes: 2 additions & 30 deletions BTrees/LFBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 120
_TREE_SIZE = 500
Expand Down Expand Up @@ -105,36 +106,7 @@ class LFTreeIteratorPy(_TreeIterator):
weightedUnionPy = _set_operation(_weightedUnion, LFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LFSetPy)

try:
from ._LFBTree import LFBucket
except ImportError: #pragma NO COVER w/ C extensions
LFBucket = LFBucketPy
LFSet = LFSetPy
LFBTree = LFBTreePy
LFTreeSet = LFTreeSetPy
LFTreeIterator = LFTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
weightedUnion = weightedUnionPy
weightedIntersection = weightedIntersectionPy
else: #pragma NO COVER w/o C extensions
from ._LFBTree import LFSet
from ._LFBTree import LFBTree
from ._LFBTree import LFTreeSet
from ._LFBTree import LFTreeIterator
from ._LFBTree import difference
from ._LFBTree import union
from ._LFBTree import intersection
from ._LFBTree import multiunion
from ._LFBTree import weightedUnion
from ._LFBTree import weightedIntersection

Bucket = LFBucket
Set = LFSet
BTree = LFBTree
TreeSet = LFTreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
32 changes: 2 additions & 30 deletions BTrees/LLBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 120
_TREE_SIZE = 500
Expand Down Expand Up @@ -105,36 +106,7 @@ class LLTreeIteratorPy(_TreeIterator):
weightedUnionPy = _set_operation(_weightedUnion, LLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LLSetPy)

try:
from ._LLBTree import LLBucket
except ImportError: #pragma NO COVER w/ C extensions
LLBucket = LLBucketPy
LLSet = LLSetPy
LLBTree = LLBTreePy
LLTreeSet = LLTreeSetPy
LLTreeIterator = LLTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
weightedUnion = weightedUnionPy
weightedIntersection = weightedIntersectionPy
else: #pragma NO COVER w/o C extensions
from ._LLBTree import LLSet
from ._LLBTree import LLBTree
from ._LLBTree import LLTreeSet
from ._LLBTree import LLTreeIterator
from ._LLBTree import difference
from ._LLBTree import union
from ._LLBTree import intersection
from ._LLBTree import multiunion
from ._LLBTree import weightedUnion
from ._LLBTree import weightedIntersection

Bucket = LLBucket
Set = LLSet
BTree = LLBTree
TreeSet = LLTreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
28 changes: 2 additions & 26 deletions BTrees/LOBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 60
_TREE_SIZE = 500
Expand Down Expand Up @@ -88,32 +89,7 @@ class LOTreeIteratorPy(_TreeIterator):
intersectionPy = _set_operation(_intersection, LOSetPy)
multiunionPy = _set_operation(_multiunion, LOSetPy)

try:
from ._LOBTree import LOBucket
except ImportError: #pragma NO COVER w/ C extensions
LOBucket = LOBucketPy
LOSet = LOSetPy
LOBTree = LOBTreePy
LOTreeSet = LOTreeSetPy
LOTreeIterator = LOTreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
multiunion = multiunionPy
else: #pragma NO COVER w/o C extensions
from ._LOBTree import LOSet
from ._LOBTree import LOBTree
from ._LOBTree import LOTreeSet
from ._LOBTree import LOTreeIterator
from ._LOBTree import difference
from ._LOBTree import union
from ._LOBTree import intersection
from ._LOBTree import multiunion

Bucket = LOBucket
Set = LOSet
BTree = LOBTree
TreeSet = LOTreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
31 changes: 2 additions & 29 deletions BTrees/OIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension

_BUCKET_SIZE = 60
_TREE_SIZE = 250
Expand Down Expand Up @@ -102,35 +103,7 @@ class OITreeIteratorPy(_TreeIterator):
weightedUnionPy = _set_operation(_weightedUnion, OISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OISetPy)

try:
from ._OIBTree import OIBucket
except ImportError: #pragma NO COVER w/ C extensions
OIBucket = OIBucketPy
OISet = OISetPy
OIBTree = OIBTreePy
OITreeSet = OITreeSetPy
OITreeIterator = OITreeIteratorPy
difference = differencePy
union = unionPy
intersection = intersectionPy
weightedUnion = weightedUnionPy
weightedIntersection = weightedIntersectionPy
else: #pragma NO COVER w/o C extensions
from ._OIBTree import OISet
from ._OIBTree import OIBTree
from ._OIBTree import OITreeSet
from ._OIBTree import OITreeIterator
from ._OIBTree import difference
from ._OIBTree import union
from ._OIBTree import intersection
from ._OIBTree import weightedUnion
from ._OIBTree import weightedIntersection


Bucket = OIBucket
Set = OISet
BTree = OIBTree
TreeSet = OITreeSet
import_c_extension(globals())

_fix_pickle(globals(), __name__)

Expand Down
Loading

0 comments on commit 5ddd044

Please sign in to comment.