Date: Wed, 11 Feb 2015 09:32:44 +0000 (UTC) From: Kubilay Kocak <koobs@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r378825 - in head/devel/py-cffi: . files Message-ID: <201502110932.t1B9Wi7t079515@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: koobs Date: Wed Feb 11 09:32:43 2015 New Revision: 378825 URL: https://svnweb.freebsd.org/changeset/ports/378825 QAT: https://qat.redports.org/buildarchive/r378825/ Log: devel/py-cffi: Backport upstream pull request #56 Backport upstream pull request #56 [1] which fixes (double) building for Python packackges that use py-cffi to compile their modules. This issue manifested itself in the 'install' target (stage) of Python port building, causing the module that was already built at the 'build' stage to be built again, except *without* the build arguments provided in the build stage. These symptoms were observable in security/py-cryptography [2] While I'm here: - Add regression-test target and TEST_DEPENDS unit tests: 1 failed, 1033 passed, 80 skipped in 70.56 seconds Note: Failure in test_array_type already exists in current version, and has been reported upstream [3] [1] https://bitbucket.org/cffi/cffi/pull-request/56/ [2] https://github.com/pyca/cryptography/pull/1635 [3] https://bitbucket.org/cffi/cffi/issue/178/ Approved by: wg (maintainer) Added: head/devel/py-cffi/files/ head/devel/py-cffi/files/patch-cffi_verifier.py (contents, props changed) Modified: head/devel/py-cffi/Makefile Modified: head/devel/py-cffi/Makefile ============================================================================== --- head/devel/py-cffi/Makefile Wed Feb 11 09:20:20 2015 (r378824) +++ head/devel/py-cffi/Makefile Wed Feb 11 09:32:43 2015 (r378825) @@ -3,7 +3,7 @@ PORTNAME= cffi PORTVERSION= 0.8.6 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= devel python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} @@ -16,6 +16,7 @@ LICENSE_FILE= ${WRKSRC}/LICENSE LIB_DEPENDS= libffi.so:${PORTSDIR}/devel/libffi RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pycparser>=2.10:${PORTSDIR}/devel/py-pycparser +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>0:${PORTSDIR}/devel/py-pytest CFLAGS+= -I${LOCALBASE}/include -Wl,-rpath,${LOCALBASE}/lib LDFLAGS+= -L${LOCALBASE}/lib @@ -23,4 +24,8 @@ LDFLAGS+= -L${LOCALBASE}/lib USES= python USE_PYTHON= autoplist distutils +regression-test: patch + cd ${WRKSRC} && ${PYTHON_CMD} ${PYDISTUTILS_SETUP} build_ext -i && + ${LOCALBASE}/bin/py.test + .include <bsd.port.mk> Added: head/devel/py-cffi/files/patch-cffi_verifier.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/py-cffi/files/patch-cffi_verifier.py Wed Feb 11 09:32:43 2015 (r378825) @@ -0,0 +1,68 @@ +# Backport: PR #56: Actually check if the file exists rather than assume it doesn't +# https://bitbucket.org/cffi/cffi/pull-request/56/ + +--- cffi/verifier.py.orig 2015-02-11 08:57:05 UTC ++++ cffi/verifier.py +@@ -1,7 +1,16 @@ +-import sys, os, binascii, imp, shutil ++import sys, os, binascii, imp, shutil, io + from . import __version__ + from . import ffiplatform + ++if sys.version_info >= (3,): ++ NativeIO = io.StringIO ++else: ++ class NativeIO(io.BytesIO): ++ def write(self, s): ++ if isinstance(s, unicode): ++ s = s.encode('ascii') ++ super(NativeIO, self).write(s) ++ + + class Verifier(object): + +@@ -118,19 +127,36 @@ class Verifier(object): + self._vengine.collect_types() + self._has_module = True + +- def _write_source(self, file=None): +- must_close = (file is None) +- if must_close: +- _ensure_dir(self.sourcefilename) +- file = open(self.sourcefilename, 'w') ++ def _write_source_to(self, file): + self._vengine._f = file + try: + self._vengine.write_source_to_f() + finally: + del self._vengine._f +- if must_close: +- file.close() +- if must_close: ++ ++ def _write_source(self, file=None): ++ if file is not None: ++ self._write_source_to(file) ++ else: ++ # Write our source file to an in memory file. ++ f = NativeIO() ++ self._write_source_to(f) ++ source_data = f.getvalue() ++ ++ # Determine if this matches the current file ++ if os.path.exists(self.sourcefilename): ++ with open(self.sourcefilename, "r") as fp: ++ needs_written = not (fp.read() == source_data) ++ else: ++ needs_written = True ++ ++ # Actually write the file out if it doesn't match ++ if needs_written: ++ _ensure_dir(self.sourcefilename) ++ with open(self.sourcefilename, "w") as fp: ++ fp.write(source_data) ++ ++ # Set this flag + self._has_source = True + + def _compile_module(self):
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502110932.t1B9Wi7t079515>