[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

authorJulien Cristau <julien.cristau@logilab.fr>
changeset2218f38af251
branchstable
phasepublic
hiddenno
parent revision#428421ffeb06 [debian] don't use sub-shells, and don't ignore errors from loops
child revision#042ea5e6e08c Add EXISTS, ILIKE, DISTINCT to KEYWORDS (closes #165898)
files modified by this revision
debian/rules
setup.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1375872596 -7200
# Wed Aug 07 12:49:56 2013 +0200
# Branch stable
# Node ID 2218f38af2519d6a3ae84e0781577a961ede5e88
# Parent 428421ffeb0682a7e2705fbb23b6b1ad7ee0ae0b
[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

diff --git a/debian/rules b/debian/rules
@@ -13,11 +13,11 @@
1 
2  build: build-stamp
3  build-stamp:
4  	dh_testdir
5  	for PYTHON in `pyversions -r`; do \
6 -	    NO_SETUPTOOLS=1 $${PYTHON} setup.py build || exit; done
7 +	    RQL_FORCE_GECODE=1 NO_SETUPTOOLS=1 $${PYTHON} setup.py build || exit; done
8  	$(MAKE) -C doc html || true
9  	touch build-stamp
10 
11  clean:
12  	dh_testdir
diff --git a/setup.py b/setup.py
@@ -159,29 +159,31 @@
13                  base = modname
14              for directory in include_dirs:
15                  dest = join(self.install_dir, base, directory)
16                  export(directory, dest, verbose=False)
17 
18 -class MyBuildExt(build_ext.build_ext):
19 -    """Extend build_ext command to pass through compilation error.
20 -    In fact, if gecode extension fail, rql will use logilab.constraint
21 -    """
22 -    def run(self):
23 -        try:
24 -            build_ext.build_ext.run(self)
25 -        except Exception:
26 -            import traceback
27 -            traceback.print_exc()
28 -            sys.stderr.write('================================\n'
29 -                             'The compilation of the gecode C extension failed. '
30 -                             'rql will use logilab.constraint which is a pure '
31 -                             'python implementation. '
32 -                             'Please note that the C extension run faster. '
33 -                             'So, install a compiler then install rql again with'
34 -                             ' the "force" option for better performance.\n'
35 -                             '================================\n')
36 -            pass
37 +if os.environ.get('RQL_FORCE_GECODE'):
38 +    MyBuildExt = build_ext.build_ext
39 +else:
40 +    class MyBuildExt(build_ext.build_ext):
41 +        """Extend build_ext command to pass through compilation error.
42 +        In fact, if gecode extension fail, rql will use logilab.constraint
43 +        """
44 +        def run(self):
45 +            try:
46 +                build_ext.build_ext.run(self)
47 +            except Exception:
48 +                import traceback
49 +                traceback.print_exc()
50 +                sys.stderr.write('================================\n'
51 +                                 'The compilation of the gecode C extension failed. '
52 +                                 'rql will use logilab.constraint which is a pure '
53 +                                 'python implementation. '
54 +                                 'Please note that the C extension run faster. '
55 +                                 'So, install a compiler then install rql again with'
56 +                                 ' the "force" option for better performance.\n'
57 +                                 '================================\n')
58 
59  def install(**kwargs):
60      """setup entry point"""
61      if USE_SETUPTOOLS:
62          if '--force-manifest' in sys.argv: