pycapnp/setup.py

137 lines
4.7 KiB
Python
Raw Normal View History

#!/usr/bin/env python
from __future__ import print_function
try:
from Cython.Build import cythonize
import Cython
except ImportError:
raise RuntimeError('No cython installed. Please run `pip install cython`')
if Cython.__version__ < '0.19.1':
raise RuntimeError('Old cython installed (%s). Please run `pip install -U cython`' % Cython.__version__)
import pkg_resources
setuptools_version = pkg_resources.get_distribution("setuptools").version
if setuptools_version < '0.8':
2013-11-05 15:37:51 -08:00
raise RuntimeError('Old setuptools installed (%s). Please run `pip install -U setuptools`. Running `pip install pycapnp` will not work alone, since setuptools needs to be upgraded before installing anything else.' % setuptools_version)
from distutils.core import setup
2013-07-07 00:12:15 -07:00
import os
from buildutils import test_build, fetch_libcapnp, build_libcapnp, info
from distutils.errors import CompileError
from distutils.extension import Extension
from Cython.Distutils import build_ext as build_ext_c
_this_dir = os.path.dirname(__file__)
MAJOR = 0
2013-11-05 15:37:51 -08:00
MINOR = 4
MICRO = 6
2013-12-12 11:56:31 -08:00
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
# Write version info
def write_version_py(filename=None):
cnt = """\
version = '%s'
short_version = '%s'
from .lib.capnp import _CAPNP_VERSION_MAJOR as LIBCAPNP_VERSION_MAJOR
from .lib.capnp import _CAPNP_VERSION_MINOR as LIBCAPNP_VERSION_MINOR
from .lib.capnp import _CAPNP_VERSION_MICRO as LIBCAPNP_VERSION_MICRO
from .lib.capnp import _CAPNP_VERSION as LIBCAPNP_VERSION
"""
if not filename:
filename = os.path.join(
os.path.dirname(__file__), 'capnp', 'version.py')
a = open(filename, 'w')
try:
a.write(cnt % (VERSION, VERSION))
finally:
a.close()
2013-07-07 00:12:15 -07:00
write_version_py()
# Try to convert README using pandoc
2013-08-12 12:39:35 -07:00
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
long_description = ''
# Clean command, invoked with `python setup.py clean`
from distutils.command.clean import clean as _clean
class clean(_clean):
def run(self):
_clean.run(self)
for x in [ 'capnp/lib/capnp.cpp', 'capnp/lib/capnp.h', 'capnp/version.py' ]:
print('removing %s' % x)
try:
os.remove(x)
except OSError:
pass
class build_libcapnp_ext(build_ext_c):
def build_extension(self, ext):
build_ext_c.build_extension(self, ext)
def run(self):
try:
test_build()
except CompileError:
info("*WARNING* no libcapnp detected. Will download and build it from source now. If you have C++ Cap'n Proto installed, it may be out of date or is not being detected. Downloading and building libcapnp may take a while.")
bundle_dir = os.path.join(_this_dir, "bundled")
if not os.path.exists(bundle_dir):
os.mkdir(bundle_dir)
build_dir = os.path.join(_this_dir, "build")
if not os.path.exists(build_dir):
os.mkdir(build_dir)
fetch_libcapnp(bundle_dir)
build_libcapnp(bundle_dir, build_dir)
self.include_dirs += [os.path.join(build_dir, 'include')]
self.library_dirs += [os.path.join(build_dir, 'lib')]
return build_ext_c.run(self)
setup(
name="pycapnp",
packages=["capnp"],
2013-08-12 11:56:44 -07:00
version=VERSION,
package_data={'capnp': ['*.pxd', '*.h', '*.capnp', 'helpers/*.pxd', 'helpers/*.h', 'includes/*.pxd', 'lib/*.pxd', 'lib/*.py', 'lib/*.pyx']},
2014-09-10 10:48:23 -07:00
ext_modules=cythonize('capnp/lib/*.pyx'),
cmdclass = {
'clean': clean,
'build_ext': build_libcapnp_ext
},
2013-08-18 00:25:51 -07:00
install_requires=[
2014-09-10 10:48:23 -07:00
'cython >= 0.21',
2013-08-18 00:25:51 -07:00
'setuptools >= 0.8'],
2013-08-12 11:56:44 -07:00
# PyPi info
2013-11-05 15:37:51 -08:00
description="A cython wrapping of the C++ Cap'n Proto library",
2013-08-12 12:39:35 -07:00
long_description=long_description,
2013-08-12 13:03:43 -07:00
license='BSD',
2013-08-12 11:56:44 -07:00
author="Jason Paryani",
author_email="pypi-contact@jparyani.com",
url = 'https://github.com/jparyani/pycapnp',
download_url = 'https://github.com/jparyani/pycapnp/archive/v%s.zip' % VERSION,
keywords = ['capnp', 'capnproto', "Cap'n Proto"],
2013-08-12 12:39:35 -07:00
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
2013-08-12 13:03:43 -07:00
'Programming Language :: C++',
'Programming Language :: Cython',
2013-08-12 12:39:35 -07:00
'Programming Language :: Python :: 2',
2013-08-12 17:48:20 -07:00
'Programming Language :: Python :: 2.6',
2013-08-12 12:39:35 -07:00
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
2013-08-12 17:48:20 -07:00
'Programming Language :: Python :: 3.2',
2013-08-12 12:39:35 -07:00
'Programming Language :: Python :: 3.3',
2013-08-15 15:44:54 -07:00
'Programming Language :: Python :: Implementation :: PyPy',
2013-08-12 12:39:35 -07:00
'Topic :: Communications'],
)