Commit 889b615c authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #79 from zopefoundation/issue75

Build CFFI modules the modern way.
parents 57a4e83f a925272c
......@@ -9,6 +9,7 @@ for PYBIN in /opt/python/*/bin; do
[[ "${PYBIN}" == *"cp35"* ]] || \
[[ "${PYBIN}" == *"cp36"* ]] || \
[[ "${PYBIN}" == *"cp37"* ]]; then
"${PYBIN}/pip" install -U pip setuptools wheel cffi
"${PYBIN}/pip" install -e /io/
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
rm -rf /io/build /io/*.egg-info
......
......@@ -56,7 +56,7 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source terryfy/travis_tools.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then get_python_environment $TERRYFY_PYTHON venv; fi
install:
- pip install -U pip setuptools
- pip install -U pip setuptools cffi wheel
- pip install -U -e .[test]
script:
- python --version
......
......@@ -6,6 +6,16 @@
- Add support for Python 3.7 and drop support for Python 3.3.
- Build the CFFI modules (used on PyPy or when PURE_PYTHON is set) `at
installation or wheel building time
<https://cffi.readthedocs.io/en/latest/cdef.html#ffibuilder-set-source-preparing-out-of-line-modules>`_
when CFFI is available. This replaces `the deprecated way
<https://cffi.readthedocs.io/en/latest/overview.html#abi-versus-api>`_
of building them at import time. If binary wheels are distributed,
it eliminates the need to have a functioning C compiler to use PyPy.
See `issue 75
<https://github.com/zopefoundation/persistent/issues/75>`_.
4.3.0 (2018-07-30)
------------------
......
......@@ -18,7 +18,7 @@ environment:
install:
- "SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH%"
- echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
- python -m pip install -U pip setuptools wheel
- python -m pip install -U pip setuptools wheel cffi
- pip install -e .[test]
build_script:
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2018 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
from __future__ import absolute_import, print_function, division
import os
from cffi import FFI
this_dir = os.path.dirname(os.path.abspath(__file__))
ffi = FFI()
with open(os.path.join(this_dir, 'ring.h')) as f:
ffi.cdef(f.read())
ffi.set_source('persistent._ring',
'#include "ring.c"',
include_dirs=[this_dir])
if __name__ == '__main__':
ffi.compile()
......@@ -144,21 +144,12 @@ class _DequeRing(object):
try:
from cffi import FFI
from persistent import _ring
except ImportError: # pragma: no cover
_CFFIRing = None
else:
import os
this_dir = os.path.dirname(os.path.abspath(__file__))
ffi = FFI()
with open(os.path.join(this_dir, 'ring.h')) as f:
ffi.cdef(f.read())
_FFI_RING = ffi.verify("""
#include "ring.c"
""", include_dirs=[this_dir])
ffi = _ring.ffi
_FFI_RING = _ring.lib
_OGA = object.__getattribute__
_OSA = object.__setattr__
......
......@@ -1055,7 +1055,7 @@ class PickleCacheTests(unittest.TestCase):
if _is_pypy:
self.assertIs(ring.Ring, ring._CFFIRing)
elif ring._CFFIRing is not None:
elif ring._CFFIRing is not None or os.environ.get('USING_CFFI'):
self.assertIs(ring.Ring, ring._CFFIRing)
else:
self.assertIs(ring.Ring, ring._DequeRing)
......
......@@ -110,6 +110,7 @@ setup(name='persistent',
include_package_data=True,
zip_safe=False,
ext_modules=ext_modules,
cffi_modules=['persistent/_ring_build.py:ffi'],
headers=headers,
extras_require={
'test': [
......
......@@ -7,6 +7,7 @@ envlist =
[testenv]
deps =
cffi
.[test]
commands =
zope-testrunner --test-path=.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment