2007-03-01 00:35:54 +00:00
|
|
|
#!/usr/bin/env python
|
2009-03-30 21:35:00 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
2016-02-02 16:57:03 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-01 00:35:54 +00:00
|
|
|
#
|
2009-03-30 21:35:00 +00:00
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
2007-03-01 00:35:54 +00:00
|
|
|
#
|
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
import sys
|
2011-08-17 19:00:33 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
except:
|
2016-02-02 16:57:03 +00:00
|
|
|
from distutils.core import setup, Extension
|
2011-11-26 05:23:09 +00:00
|
|
|
|
|
|
|
from distutils.command.build_ext import build_ext
|
|
|
|
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
|
2007-08-25 18:01:30 +00:00
|
|
|
|
2014-07-10 13:18:42 +00:00
|
|
|
# Fix to build sdist under vagrant
|
|
|
|
import os
|
|
|
|
if 'vagrant' in str(os.environ):
|
|
|
|
del os.link
|
|
|
|
|
2016-02-11 04:58:39 +00:00
|
|
|
include_dirs = ['src']
|
2011-09-13 13:54:05 +00:00
|
|
|
if sys.platform == 'win32':
|
|
|
|
include_dirs.append('compat/win32')
|
2011-11-26 05:23:09 +00:00
|
|
|
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError, IOError)
|
|
|
|
else:
|
|
|
|
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
|
|
|
|
|
2016-02-02 16:57:03 +00:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
class BuildFailed(Exception):
|
|
|
|
pass
|
|
|
|
|
2016-02-02 16:57:03 +00:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
class ve_build_ext(build_ext):
|
|
|
|
def run(self):
|
|
|
|
try:
|
|
|
|
build_ext.run(self)
|
2016-02-02 16:57:03 +00:00
|
|
|
except DistutilsPlatformError:
|
2011-11-26 05:23:09 +00:00
|
|
|
raise BuildFailed()
|
|
|
|
|
|
|
|
def build_extension(self, ext):
|
|
|
|
try:
|
|
|
|
build_ext.build_extension(self, ext)
|
2016-02-02 16:57:03 +00:00
|
|
|
except ext_errors:
|
2011-11-26 05:23:09 +00:00
|
|
|
raise BuildFailed()
|
|
|
|
|
2016-02-02 16:57:03 +00:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
def run_setup(with_binary):
|
|
|
|
if with_binary:
|
|
|
|
extensions = dict(
|
2016-02-02 16:57:03 +00:00
|
|
|
ext_modules=[
|
|
|
|
Extension('thrift.protocol.fastbinary',
|
2016-02-11 04:58:39 +00:00
|
|
|
sources=[
|
|
|
|
'src/ext/module.cpp',
|
|
|
|
'src/ext/types.cpp',
|
|
|
|
'src/ext/binary.cpp',
|
|
|
|
'src/ext/compact.cpp',
|
|
|
|
],
|
2016-02-02 16:57:03 +00:00
|
|
|
include_dirs=include_dirs,
|
|
|
|
)
|
2011-11-26 05:23:09 +00:00
|
|
|
],
|
|
|
|
cmdclass=dict(build_ext=ve_build_ext)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
extensions = dict()
|
2015-11-06 12:24:16 +00:00
|
|
|
|
2016-09-04 09:49:21 +00:00
|
|
|
ssl_deps = []
|
|
|
|
if sys.version_info[0] == 2:
|
|
|
|
ssl_deps.append('ipaddress')
|
|
|
|
if sys.hexversion < 0x03050000:
|
|
|
|
ssl_deps.append('backports.ssl_match_hostname>=3.5')
|
|
|
|
tornado_deps = ['tornado>=4.0']
|
|
|
|
twisted_deps = ['twisted']
|
|
|
|
|
2016-02-02 16:57:03 +00:00
|
|
|
setup(name='thrift',
|
|
|
|
version='1.0.0-dev',
|
|
|
|
description='Python bindings for the Apache Thrift RPC system',
|
|
|
|
author='Thrift Developers',
|
|
|
|
author_email='dev@thrift.apache.org',
|
|
|
|
url='http://thrift.apache.org',
|
|
|
|
license='Apache License 2.0',
|
|
|
|
install_requires=['six>=1.7.2'],
|
2016-09-04 09:49:21 +00:00
|
|
|
extras_require={
|
|
|
|
'ssl': ssl_deps,
|
|
|
|
'tornado': tornado_deps,
|
|
|
|
'twisted': twisted_deps,
|
|
|
|
'all': ssl_deps + tornado_deps + twisted_deps,
|
|
|
|
},
|
2016-02-02 16:57:03 +00:00
|
|
|
packages=[
|
|
|
|
'thrift',
|
|
|
|
'thrift.protocol',
|
|
|
|
'thrift.transport',
|
|
|
|
'thrift.server',
|
|
|
|
],
|
|
|
|
package_dir={'thrift': 'src'},
|
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
'Environment :: Console',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Topic :: Software Development :: Libraries',
|
|
|
|
'Topic :: System :: Networking'
|
|
|
|
],
|
|
|
|
**extensions
|
|
|
|
)
|
2006-09-03 21:13:07 +00:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
try:
|
2016-02-11 07:21:01 +00:00
|
|
|
with_binary = True
|
2015-11-06 12:24:16 +00:00
|
|
|
run_setup(with_binary)
|
2011-11-26 05:23:09 +00:00
|
|
|
except BuildFailed:
|
2014-03-27 17:56:04 +00:00
|
|
|
print()
|
|
|
|
print('*' * 80)
|
2014-11-24 09:55:31 +00:00
|
|
|
print("An error occurred while trying to compile with the C extension enabled")
|
2014-03-27 17:56:04 +00:00
|
|
|
print("Attempting to build without the extension now")
|
|
|
|
print('*' * 80)
|
|
|
|
print()
|
2006-09-03 21:13:07 +00:00
|
|
|
|
2011-11-26 05:23:09 +00:00
|
|
|
run_setup(False)
|