| Mark Slee | fb40c19 | 2007-03-01 00:35:54 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python | 
| David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 2 |  | 
| Mark Slee | fb40c19 | 2007-03-01 00:35:54 +0000 | [diff] [blame] | 3 | # | 
| David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 4 | # Licensed to the Apache Software Foundation (ASF) under one | 
|  | 5 | # or more contributor license agreements. See the NOTICE file | 
|  | 6 | # distributed with this work for additional information | 
|  | 7 | # regarding copyright ownership. The ASF licenses this file | 
|  | 8 | # to you under the Apache License, Version 2.0 (the | 
|  | 9 | # "License"); you may not use this file except in compliance | 
|  | 10 | # with the License. You may obtain a copy of the License at | 
| Mark Slee | fb40c19 | 2007-03-01 00:35:54 +0000 | [diff] [blame] | 11 | # | 
| Jake Farrell | ff1c69b | 2011-08-17 19:00:33 +0000 | [diff] [blame] | 12 | #	http://www.apache.org/licenses/LICENSE-2.0 | 
| David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 13 | # | 
|  | 14 | # Unless required by applicable law or agreed to in writing, | 
|  | 15 | # software distributed under the License is distributed on an | 
|  | 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | 
|  | 17 | # KIND, either express or implied. See the License for the | 
|  | 18 | # specific language governing permissions and limitations | 
|  | 19 | # under the License. | 
|  | 20 | # | 
| Mark Slee | fb40c19 | 2007-03-01 00:35:54 +0000 | [diff] [blame] | 21 |  | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 22 | import sys | 
| Jake Farrell | ff1c69b | 2011-08-17 19:00:33 +0000 | [diff] [blame] | 23 | try: | 
|  | 24 | from setuptools import setup, Extension | 
|  | 25 | except: | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 26 | from distutils.core import setup, Extension, Command | 
|  | 27 |  | 
|  | 28 | from distutils.command.build_ext import build_ext | 
|  | 29 | from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError | 
| David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 30 |  | 
| Roger Meier | c3f033f | 2011-09-13 13:54:05 +0000 | [diff] [blame] | 31 | include_dirs = [] | 
|  | 32 | if sys.platform == 'win32': | 
|  | 33 | include_dirs.append('compat/win32') | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 34 | ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError) | 
|  | 35 | else: | 
|  | 36 | ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) | 
|  | 37 |  | 
|  | 38 | class BuildFailed(Exception): | 
|  | 39 | pass | 
|  | 40 |  | 
|  | 41 | class ve_build_ext(build_ext): | 
|  | 42 | def run(self): | 
|  | 43 | try: | 
|  | 44 | build_ext.run(self) | 
|  | 45 | except DistutilsPlatformError, x: | 
|  | 46 | raise BuildFailed() | 
|  | 47 |  | 
|  | 48 | def build_extension(self, ext): | 
|  | 49 | try: | 
|  | 50 | build_ext.build_extension(self, ext) | 
|  | 51 | except ext_errors, x: | 
|  | 52 | raise BuildFailed() | 
|  | 53 |  | 
|  | 54 | def run_setup(with_binary): | 
|  | 55 | if with_binary: | 
|  | 56 | extensions = dict( | 
|  | 57 | ext_modules = [ | 
|  | 58 | Extension('thrift.protocol.fastbinary', | 
|  | 59 | sources = ['src/protocol/fastbinary.c'], | 
| Roger Meier | c3f033f | 2011-09-13 13:54:05 +0000 | [diff] [blame] | 60 | include_dirs = include_dirs, | 
| Jake Farrell | ff1c69b | 2011-08-17 19:00:33 +0000 | [diff] [blame] | 61 | ) | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 62 | ], | 
|  | 63 | cmdclass=dict(build_ext=ve_build_ext) | 
|  | 64 | ) | 
|  | 65 | else: | 
|  | 66 | extensions = dict() | 
|  | 67 |  | 
|  | 68 | setup(name = 'thrift', | 
| jfarrell | ff980c1 | 2013-08-18 19:54:39 -0400 | [diff] [blame^] | 69 | version = '0.9.1', | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 70 | description = 'Python bindings for the Apache Thrift RPC system', | 
|  | 71 | author = ['Thrift Developers'], | 
|  | 72 | author_email = ['dev@thrift.apache.org'], | 
|  | 73 | url = 'http://thrift.apache.org', | 
|  | 74 | license = 'Apache License 2.0', | 
|  | 75 | packages = [ | 
|  | 76 | 'thrift', | 
|  | 77 | 'thrift.protocol', | 
|  | 78 | 'thrift.transport', | 
|  | 79 | 'thrift.server', | 
|  | 80 | ], | 
|  | 81 | package_dir = {'thrift' : 'src'}, | 
|  | 82 | classifiers = [ | 
|  | 83 | 'Development Status :: 5 - Production/Stable', | 
|  | 84 | 'Environment :: Console', | 
|  | 85 | 'Intended Audience :: Developers', | 
|  | 86 | 'Programming Language :: Python', | 
|  | 87 | 'Programming Language :: Python :: 2', | 
|  | 88 | 'Topic :: Software Development :: Libraries', | 
|  | 89 | 'Topic :: System :: Networking' | 
|  | 90 | ], | 
|  | 91 | **extensions | 
|  | 92 | ) | 
| Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 93 |  | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 94 | try: | 
|  | 95 | run_setup(True) | 
|  | 96 | except BuildFailed: | 
|  | 97 | print | 
|  | 98 | print '*' * 80 | 
|  | 99 | print "An error occured while trying to compile with the C extension enabled" | 
|  | 100 | print "Attempting to build without the extension now" | 
|  | 101 | print '*' * 80 | 
|  | 102 | print | 
| Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 103 |  | 
| Jake Farrell | a0dd75d | 2011-11-26 05:23:09 +0000 | [diff] [blame] | 104 | run_setup(False) |