|
1 | | -# Copyright 2010-2012 RethinkDB, all rights reserved. |
| 1 | +# Copyright 2010-2013 RethinkDB, all rights reserved. |
2 | 2 |
|
3 | 3 | from setuptools import setup, Extension |
4 | 4 | from distutils.command.build_ext import build_ext |
5 | | -from distutils.errors import DistutilsPlatformError, CCompilerError, DistutilsExecError |
6 | | -import sys |
| 5 | +import os |
| 6 | +from subprocess import check_call |
7 | 7 |
|
8 | | -class build_ext_nofail(build_ext): |
9 | | - # This class can replace the build_ext command with one that does not fail |
10 | | - # when the extension fails to build. |
11 | | - |
12 | | - def run(self): |
13 | | - try: |
14 | | - build_ext.run(self) |
15 | | - except DistutilsPlatformError as e: |
16 | | - self._failed(e) |
| 8 | +class build_ext_genproto(build_ext): |
| 9 | + # This class replaces the build_ext command with one that |
| 10 | + # first generates the ql2.pb.{cpp,h} files if the correct |
| 11 | + # environment variable is set. |
17 | 12 |
|
18 | 13 | def build_extension(self, ext): |
19 | | - try: |
| 14 | + if os.environ.get('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION') == 'cpp': |
| 15 | + print "Calling protoc to generate ql2.pb.cc and ql2.pb.h" |
| 16 | + check_call(['protoc', 'ql2.proto', '--cpp_out=.']) |
| 17 | + ext.sources = ['./ql2.pb.cc'] + ext.sources |
20 | 18 | build_ext.build_extension(self, ext) |
21 | | - except (CCompilerError, DistutilsExecError) as e: |
22 | | - self._failed(e) |
23 | 19 | else: |
24 | | - try: |
25 | | - import google.protobuf.internal.cpp_message |
26 | | - except ImportError: |
27 | | - sys.stderr.write("*** WARNING: The installed protobuf library does not seem to include the C++ extension\n") |
28 | | - sys.stderr.write("*** WARNING: The RethinkDB driver will fallback to using the pure python implementation\n") |
29 | | - |
30 | | - def _failed(self, e): |
31 | | - sys.stderr.write("*** WARNING: Unable to compile the C++ extension\n") |
32 | | - sys.stderr.write(str(e) + "\n") |
33 | | - sys.stderr.write("*** WARNING: Defaulting to the python implementation\n") |
| 20 | + print "* * * * * * * * * * * * * * * * *" |
| 21 | + print "* WARNING: The faster C++ protobuf backend is not enabled." |
| 22 | + print "* WARNING: To enable it, run `export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp' and reinstall the rethinkdb package." |
| 23 | + print "* WARNING: See http://rethinkdb.com/docs/driver-performance/ for more information." |
| 24 | + print "* * * * * * * * * * * * * * * * *" |
34 | 25 |
|
35 | 26 | setup(name="rethinkdb" |
36 | | - ,version="1.10.0-0" |
37 | | - ,description="This package provides the Python driver library for the RethinkDB database server." |
38 | | - ,url="http://rethinkdb.com" |
39 | | - ,maintainer="RethinkDB Inc." |
40 | | - ,maintainer_email="bugs@rethinkdb.com" |
41 | | - ,packages=['rethinkdb'] |
42 | | - ,install_requires=['protobuf'] |
43 | | - ,ext_modules=[Extension('rethinkdb_pbcpp', sources=['./rethinkdb/pbcpp.cpp', './rethinkdb/ql2.pb.cc'], |
44 | | - include_dirs=['./rethinkdb'], libraries=['protobuf'])] |
45 | | - ,cmdclass={"build_ext":build_ext_nofail} |
46 | | - ,entry_points={'console_scripts': [ |
47 | | - 'rethinkdb-import = rethinkdb._import:main', |
48 | | - 'rethinkdb-dump = rethinkdb._dump:main', |
49 | | - 'rethinkdb-export = rethinkdb._export:main', |
50 | | - 'rethinkdb-restore = rethinkdb._restore:main']} |
51 | | -) |
| 27 | + ,version = "1.10.0-999" |
| 28 | + ,description = "This package provides the Python driver library for the RethinkDB database server." |
| 29 | + ,url = "http://rethinkdb.com" |
| 30 | + ,maintainer = "RethinkDB Inc." |
| 31 | + ,maintainer_email = "bugs@rethinkdb.com" |
| 32 | + ,packages = ['rethinkdb'] |
| 33 | + ,install_requires = ['protobuf'] |
| 34 | + ,entry_points = {'console_scripts': [ |
| 35 | + 'rethinkdb-import = rethinkdb._import:main', |
| 36 | + 'rethinkdb-dump = rethinkdb._dump:main', |
| 37 | + 'rethinkdb-export = rethinkdb._export:main', |
| 38 | + 'rethinkdb-restore = rethinkdb._restore:main']} |
| 39 | + ,cmdclass = {"build_ext":build_ext_genproto} |
| 40 | + ,ext_modules = [Extension( |
| 41 | + 'rethinkdb/_pbcpp', |
| 42 | + sources=['./rethinkdb/_pbcpp.cpp'], |
| 43 | + include_dirs=['./'], |
| 44 | + libraries=['protobuf'])]) |
0 commit comments