[pkg] Add an env var to force building the binary extension stable
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 07 Aug 2013 12:49:56 +0200
branchstable
changeset 714 2218f38af251
parent 713 428421ffeb06
child 715 042ea5e6e08c
[pkg] Add an env var to force building the binary extension And use it in the Debian packaging to make sure we don't end up with a disfunctional package. Closes #159003
debian/rules
setup.py
--- a/debian/rules	Fri Aug 02 18:20:33 2013 +0200
+++ b/debian/rules	Wed Aug 07 12:49:56 2013 +0200
@@ -15,7 +15,7 @@
 build-stamp:
 	dh_testdir
 	for PYTHON in `pyversions -r`; do \
-	    NO_SETUPTOOLS=1 $${PYTHON} setup.py build || exit; done
+	    RQL_FORCE_GECODE=1 NO_SETUPTOOLS=1 $${PYTHON} setup.py build || exit; done
 	$(MAKE) -C doc html || true
 	touch build-stamp
 
--- a/setup.py	Fri Aug 02 18:20:33 2013 +0200
+++ b/setup.py	Wed Aug 07 12:49:56 2013 +0200
@@ -161,25 +161,27 @@
                 dest = join(self.install_dir, base, directory)
                 export(directory, dest, verbose=False)
 
-class MyBuildExt(build_ext.build_ext):
-    """Extend build_ext command to pass through compilation error.
-    In fact, if gecode extension fail, rql will use logilab.constraint
-    """
-    def run(self):
-        try:
-            build_ext.build_ext.run(self)
-        except Exception:
-            import traceback
-            traceback.print_exc()
-            sys.stderr.write('================================\n'
-                             'The compilation of the gecode C extension failed. '
-                             'rql will use logilab.constraint which is a pure '
-                             'python implementation. '
-                             'Please note that the C extension run faster. '
-                             'So, install a compiler then install rql again with'
-                             ' the "force" option for better performance.\n'
-                             '================================\n')
-            pass
+if os.environ.get('RQL_FORCE_GECODE'):
+    MyBuildExt = build_ext.build_ext
+else:
+    class MyBuildExt(build_ext.build_ext):
+        """Extend build_ext command to pass through compilation error.
+        In fact, if gecode extension fail, rql will use logilab.constraint
+        """
+        def run(self):
+            try:
+                build_ext.build_ext.run(self)
+            except Exception:
+                import traceback
+                traceback.print_exc()
+                sys.stderr.write('================================\n'
+                                 'The compilation of the gecode C extension failed. '
+                                 'rql will use logilab.constraint which is a pure '
+                                 'python implementation. '
+                                 'Please note that the C extension run faster. '
+                                 'So, install a compiler then install rql again with'
+                                 ' the "force" option for better performance.\n'
+                                 '================================\n')
 
 def install(**kwargs):
     """setup entry point"""