blob: b7612057374c02b7da6d5b6d25ee1c3f30e06045 [file] [log] [blame]
Andreas Sandbergc79706f2017-02-27 13:17:51 +00001#!/usr/bin/env python
2
3# Setup script for PyPI; use CMakeFile.txt to build extension modules
4
5from setuptools import setup
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -08006from distutils.command.install_headers import install_headers
Andreas Sandbergc79706f2017-02-27 13:17:51 +00007from pybind11 import __version__
Andreas Sandberg6914a222017-05-09 19:22:53 +01008import os
Andreas Sandbergc79706f2017-02-27 13:17:51 +00009
Andreas Sandberg6914a222017-05-09 19:22:53 +010010# Prevent installation of pybind11 headers by setting
11# PYBIND11_USE_CMAKE.
12if os.environ.get('PYBIND11_USE_CMAKE'):
13 headers = []
14else:
15 headers = [
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080016 'include/pybind11/detail/class.h',
17 'include/pybind11/detail/common.h',
18 'include/pybind11/detail/descr.h',
19 'include/pybind11/detail/init.h',
20 'include/pybind11/detail/internals.h',
21 'include/pybind11/detail/typeid.h',
Andreas Sandbergc79706f2017-02-27 13:17:51 +000022 'include/pybind11/attr.h',
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080023 'include/pybind11/buffer_info.h',
Andreas Sandbergc79706f2017-02-27 13:17:51 +000024 'include/pybind11/cast.h',
25 'include/pybind11/chrono.h',
26 'include/pybind11/common.h',
27 'include/pybind11/complex.h',
Andreas Sandbergc79706f2017-02-27 13:17:51 +000028 'include/pybind11/eigen.h',
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080029 'include/pybind11/embed.h',
Andreas Sandbergc79706f2017-02-27 13:17:51 +000030 'include/pybind11/eval.h',
31 'include/pybind11/functional.h',
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080032 'include/pybind11/iostream.h',
Andreas Sandbergc79706f2017-02-27 13:17:51 +000033 'include/pybind11/numpy.h',
34 'include/pybind11/operators.h',
35 'include/pybind11/options.h',
36 'include/pybind11/pybind11.h',
37 'include/pybind11/pytypes.h',
38 'include/pybind11/stl.h',
39 'include/pybind11/stl_bind.h',
Andreas Sandberg6914a222017-05-09 19:22:53 +010040 ]
41
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080042
43class InstallHeaders(install_headers):
44 """Use custom header installer because the default one flattens subdirectories"""
45 def run(self):
46 if not self.distribution.headers:
47 return
48
49 for header in self.distribution.headers:
50 subdir = os.path.dirname(os.path.relpath(header, 'include/pybind11'))
51 install_dir = os.path.join(self.install_dir, subdir)
52 self.mkpath(install_dir)
53
54 (out, _) = self.copy_file(header, install_dir)
55 self.outfiles.append(out)
56
57
Andreas Sandberg6914a222017-05-09 19:22:53 +010058setup(
59 name='pybind11',
60 version=__version__,
61 description='Seamless operability between C++11 and Python',
62 author='Wenzel Jakob',
63 author_email='wenzel.jakob@epfl.ch',
64 url='https://github.com/wjakob/pybind11',
65 download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
66 packages=['pybind11'],
67 license='BSD',
68 headers=headers,
Jason Lowe-Powerf07d5062017-11-17 17:02:05 -080069 cmdclass=dict(install_headers=InstallHeaders),
Andreas Sandbergc79706f2017-02-27 13:17:51 +000070 classifiers=[
71 'Development Status :: 5 - Production/Stable',
72 'Intended Audience :: Developers',
73 'Topic :: Software Development :: Libraries :: Python Modules',
74 'Topic :: Utilities',
75 'Programming Language :: C++',
76 'Programming Language :: Python :: 2.7',
77 'Programming Language :: Python :: 3',
78 'Programming Language :: Python :: 3.2',
79 'Programming Language :: Python :: 3.3',
80 'Programming Language :: Python :: 3.4',
81 'Programming Language :: Python :: 3.5',
Andreas Sandberg6914a222017-05-09 19:22:53 +010082 'Programming Language :: Python :: 3.6',
83 'License :: OSI Approved :: BSD License'
Andreas Sandbergc79706f2017-02-27 13:17:51 +000084 ],
85 keywords='C++11, Python bindings',
Andreas Sandberg6914a222017-05-09 19:22:53 +010086 long_description="""pybind11 is a lightweight header-only library that
87exposes C++ types in Python and vice versa, mainly to create Python bindings of
Andreas Sandbergc79706f2017-02-27 13:17:51 +000088existing C++ code. Its goals and syntax are similar to the excellent
Andreas Sandberg6914a222017-05-09 19:22:53 +010089Boost.Python by David Abrahams: to minimize boilerplate code in traditional
90extension modules by inferring type information using compile-time
Andreas Sandbergc79706f2017-02-27 13:17:51 +000091introspection.
92
93The main issue with Boost.Python-and the reason for creating such a similar
94project-is Boost. Boost is an enormously large and complex suite of utility
95libraries that works with almost every C++ compiler in existence. This
96compatibility has its cost: arcane template tricks and workarounds are
97necessary to support the oldest and buggiest of compiler specimens. Now that
98C++11-compatible compilers are widely available, this heavy machinery has
99become an excessively large and unnecessary dependency.
100
101Think of this library as a tiny self-contained version of Boost.Python with
102everything stripped away that isn't relevant for binding generation. Without
Andreas Sandberg6914a222017-05-09 19:22:53 +0100103comments, the core header files only require ~4K lines of code and depend on
104Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This
105compact implementation was possible thanks to some of the new C++11 language
106features (specifically: tuples, lambda functions and variadic templates). Since
107its creation, this library has grown beyond Boost.Python in many ways, leading
108to dramatically simpler binding code in many common situations.""")