Package: python-twextpy
Version: 0.1.b2.dev15059-1
Severity: normal
Tags: patch

Importing the cffi bits of python-twextpy results in errors like this:

>>> import twext.python.sacl
/usr/lib/python2.7/dist-packages/twext/python/__pycache__/_cffi_twext_python_sacl_xe128630fxbbd600c.c:2:20:
 fatal error: Python.h: No such file or directory
compilation terminated.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/twext/python/sacl.py", line 43, in 
<module>
    raise ImportError(ve)
ImportError: CompileError: command 'x86_64-linux-gnu-gcc' failed with exit 
status 1

This is because it's attempting to build a cffi module, that wasn't
bundled in the binary package (as they be). It's worth noting that there
are more modern ways to use cffi that don't have this problem
https://cffi.readthedocs.io/en/latest/overview.html#real-example-api-level-out-of-line

All of that said, it turns out that these cffi extensions are wrapping
OSX-specific libraries. So, I think the best thing to do here is to
patch them out and drop the cffi dependencies.

Here's a patch series to achieve that:

0001-Patch-out-OSX-only-modules-launchd-and-sacl.patch
0002-Drop-cffi-dependency-no-longer-used.patch

As I started by trying to build these cffi modules at build time, I also
have some other patches that may interest you:

0003-Build-with-pybuild.patch
0004-Clean-up-after-running-tests.patch
0005-Ignore-tests.patch
0006-Wrap-and-sort-control-files.patch

SR
From 763a938f3f3b8d3744dd180c07c73e7571fddf8e Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 11:47:09 -0400
Subject: [PATCH 1/6] Patch out OSX-only modules (launchd and sacl)

So we don't try to build an extension at runtime.
---
 debian/changelog             |  7 +++++++
 debian/patches/not-osx.patch | 31 +++++++++++++++++++++++++++++++
 debian/patches/series        |  1 +
 3 files changed, 39 insertions(+)
 create mode 100644 debian/patches/not-osx.patch

diff --git a/debian/changelog b/debian/changelog
index d293074..a25b1dd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+twextpy (0.1.b2.dev15059-2) UNRELEASED; urgency=medium
+
+  * Patch out OSX-only modules (launchd and sacl), so we don't try to build an
+    extension at runtime.
+
+ -- Stefano Rivera <stefa...@debian.org>  Mon, 01 Aug 2016 11:32:19 -0400
+
 twextpy (0.1.b2.dev15059-1) unstable; urgency=low
 
   * Initial package import of upstream svn branch release twext-7.0-dev
diff --git a/debian/patches/not-osx.patch b/debian/patches/not-osx.patch
new file mode 100644
index 0000000..b02c697
--- /dev/null
+++ b/debian/patches/not-osx.patch
@@ -0,0 +1,31 @@
+Description: This isn't OSX
+ launchd and the APIs used in sacl are't available, so don't try to build these
+ cffi extensions ever.
+ .
+ Without this patch, a build will be attempted on every import.
+Author: Stefano Rivera <stefa...@debian.org>
+Last-Updated: 2016-08-01
+Forwarded: not-needed
+
+--- a/twext/python/launchd.py
++++ b/twext/python/launchd.py
+@@ -19,6 +19,8 @@
+ Binding for launchd socket hand-off API.
+ """
+ 
++raise ImportError('launchd is not available on this platform')
++
+ from __future__ import print_function
+ 
+ from cffi import FFI, VerificationError
+--- a/twext/python/sacl.py
++++ b/twext/python/sacl.py
+@@ -14,6 +14,8 @@
+ # limitations under the License.
+ ##
+ 
++raise ImportError('checkSACL is not available on this platform')
++
+ from __future__ import print_function
+ 
+ __all__ = [
diff --git a/debian/patches/series b/debian/patches/series
index 332a360..44d8a38 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 nss.patch
 version.patch
+not-osx.patch
-- 
2.8.1

From 6e81b2c9e53f3779b0ef14a39ab6365ddaae9f3e Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 12:11:01 -0400
Subject: [PATCH 2/6] Drop cffi dependency, no longer used.

---
 debian/changelog             |  1 +
 debian/control               |  3 +--
 debian/patches/not-osx.patch | 30 ++++++++++++++++++++----------
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a25b1dd..a851ece 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ twextpy (0.1.b2.dev15059-2) UNRELEASED; urgency=medium
 
   * Patch out OSX-only modules (launchd and sacl), so we don't try to build an
     extension at runtime.
+  * Drop cffi dependency, no longer used.
 
  -- Stefano Rivera <stefa...@debian.org>  Mon, 01 Aug 2016 11:32:19 -0400
 
diff --git a/debian/control b/debian/control
index 3ed27db..0bcfae8 100644
--- a/debian/control
+++ b/debian/control
@@ -10,8 +10,7 @@ Vcs-Browser: https://anonscm.debian.org/cgit/calendarserver/twextpy.git
 
 Package: python-twext
 Architecture: all
-Depends: ${misc:Depends}, ${python:Depends}, python-cffi (>= 0.6),
- python-twisted (>= 15.2.0)
+Depends: ${misc:Depends}, ${python:Depends}, python-twisted (>= 15.2.0)
 Recommends: python-sqlparse (>= 0.1.11), python-ldap
 Replaces: calendarserver (<< 7.0+dfsg-1)
 Breaks: calendarserver (<< 7.0+dfsg-1)
diff --git a/debian/patches/not-osx.patch b/debian/patches/not-osx.patch
index b02c697..24b10ec 100644
--- a/debian/patches/not-osx.patch
+++ b/debian/patches/not-osx.patch
@@ -9,23 +9,33 @@ Forwarded: not-needed
 
 --- a/twext/python/launchd.py
 +++ b/twext/python/launchd.py
-@@ -19,6 +19,8 @@
- Binding for launchd socket hand-off API.
- """
+@@ -21,6 +21,8 @@
  
-+raise ImportError('launchd is not available on this platform')
-+
  from __future__ import print_function
  
++raise ImportError('launchd is not available on this platform')
++
  from cffi import FFI, VerificationError
+ 
+ ffi = FFI()
 --- a/twext/python/sacl.py
 +++ b/twext/python/sacl.py
-@@ -14,6 +14,8 @@
- # limitations under the License.
- ##
+@@ -16,6 +16,8 @@
  
-+raise ImportError('checkSACL is not available on this platform')
-+
  from __future__ import print_function
  
++raise ImportError('checkSACL is not available on this platform')
++
  __all__ = [
+     "checkSACL"
+ ]
+--- a/setup.py
++++ b/setup.py
+@@ -236,7 +236,6 @@
+ setup_requirements = []
+ 
+ install_requirements = [
+-    "cffi>=0.6",
+     "twisted>=15.2.0",
+ ]
+ 
-- 
2.8.1

From 43709ae403ffd6a4fce47b84c77ea026d23156fe Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 11:32:00 -0400
Subject: [PATCH 3/6] Build with pybuild.

---
 debian/changelog | 1 +
 debian/rules     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index a851ece..bac2fdd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ twextpy (0.1.b2.dev15059-2) UNRELEASED; urgency=medium
   * Patch out OSX-only modules (launchd and sacl), so we don't try to build an
     extension at runtime.
   * Drop cffi dependency, no longer used.
+  * Build with pybuild.
 
  -- Stefano Rivera <stefa...@debian.org>  Mon, 01 Aug 2016 11:32:19 -0400
 
diff --git a/debian/rules b/debian/rules
index 495f752..af2261d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,7 +5,7 @@
 #export DH_VERBOSE=1
 
 %:
-	dh $@ --with python2
+	dh $@ --with python2 --buildsystem pybuild
 
 override_dh_clean:
 	dh_clean
-- 
2.8.1

From b8bc3e38e77440db1bd1d0956d8ca924a29d04af Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 11:51:50 -0400
Subject: [PATCH 4/6] Clean up after running tests

---
 debian/rules | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index af2261d..5ac3a54 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,4 +9,5 @@
 
 override_dh_clean:
 	dh_clean
-	rm -f twext/version.py
+	rm -f twext/version.py twisted/plugins/dropin.cache
+	rm -rf _trial_temp/
-- 
2.8.1

From e6a2c9014a2e21e1fb7ccf1baa11523cfd51957b Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 11:51:20 -0400
Subject: [PATCH 5/6] Ignore tests

---
 debian/rules | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/debian/rules b/debian/rules
index 5ac3a54..8276e6e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,9 @@
 %:
 	dh $@ --with python2 --buildsystem pybuild
 
+override_dh_auto_test:
+	# Tests fail, ignore them
+
 override_dh_clean:
 	dh_clean
 	rm -f twext/version.py twisted/plugins/dropin.cache
-- 
2.8.1

From f3d528e77adfd5bcc17a29b190513570ff10fde5 Mon Sep 17 00:00:00 2001
From: Stefano Rivera <stefa...@debian.org>
Date: Mon, 1 Aug 2016 12:22:32 -0400
Subject: [PATCH 6/6] Wrap and sort control files.

---
 debian/changelog | 1 +
 debian/control   | 6 +++---
 debian/copyright | 1 -
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index bac2fdd..30b1274 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,7 @@ twextpy (0.1.b2.dev15059-2) UNRELEASED; urgency=medium
     extension at runtime.
   * Drop cffi dependency, no longer used.
   * Build with pybuild.
+  * Wrap and sort control files.
 
  -- Stefano Rivera <stefa...@debian.org>  Mon, 01 Aug 2016 11:32:19 -0400
 
diff --git a/debian/control b/debian/control
index 0bcfae8..b4700d7 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: twextpy
 Section: python
 Priority: optional
 Maintainer: Rahul Amaram <amaramra...@users.sourceforge.net>
-Build-Depends: debhelper (>= 9), python, dh-python, python-setuptools
+Build-Depends: debhelper (>= 9), dh-python, python, python-setuptools
 Standards-Version: 3.9.6
 Homepage: http://trac.calendarserver.org/wiki/twext
 Vcs-Git: https://anonscm.debian.org/git/calendarserver/twextpy.git
@@ -10,8 +10,8 @@ Vcs-Browser: https://anonscm.debian.org/cgit/calendarserver/twextpy.git
 
 Package: python-twext
 Architecture: all
-Depends: ${misc:Depends}, ${python:Depends}, python-twisted (>= 15.2.0)
-Recommends: python-sqlparse (>= 0.1.11), python-ldap
+Depends: python-twisted (>= 15.2.0), ${misc:Depends}, ${python:Depends}
+Recommends: python-ldap, python-sqlparse (>= 0.1.11)
 Replaces: calendarserver (<< 7.0+dfsg-1)
 Breaks: calendarserver (<< 7.0+dfsg-1)
 Description: Python module consisting of extensions to the Twisted Framework
diff --git a/debian/copyright b/debian/copyright
index 4afa4ca..4a28924 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -25,4 +25,3 @@ License: Apache-2.0
  .
  On Debian systems, the complete text of the Apache version 2.0 license
  can be found in "/usr/share/common-licenses/Apache-2.0".
-
-- 
2.8.1

Reply via email to