blob: e24f34b9ce81e09679fcc0de75191b69229c45fd [file] [log] [blame]
Wenzel Jakob929fd7e2015-10-15 18:24:12 +02001#!/usr/bin/env python
2
Dean Moldovana0c1ccf2016-08-12 13:50:00 +02003# Setup script for PyPI; use CMakeFile.txt to build extension modules
Wenzel Jakob929fd7e2015-10-15 18:24:12 +02004
5from setuptools import setup
Dean Moldovan1913f252017-08-23 14:20:53 +02006from distutils.command.install_headers import install_headers
Wenzel Jakob4f972c02016-03-01 10:36:10 +01007from pybind11 import __version__
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +01008import os
Wenzel Jakob929fd7e2015-10-15 18:24:12 +02009
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010010# Prevent installation of pybind11 headers by setting
11# PYBIND11_USE_CMAKE.
12if os.environ.get('PYBIND11_USE_CMAKE'):
13 headers = []
14else:
15 headers = [
Dean Moldovanf5806492017-08-14 00:35:53 +020016 'include/pybind11/detail/class.h',
17 'include/pybind11/detail/common.h',
18 'include/pybind11/detail/descr.h',
Jason Rhinelander464d9892017-06-12 21:52:48 -040019 'include/pybind11/detail/init.h',
Dean Moldovan024932b2017-08-20 16:15:33 +020020 'include/pybind11/detail/internals.h',
Dean Moldovan1913f252017-08-23 14:20:53 +020021 'include/pybind11/detail/typeid.h',
Wenzel Jakob48548ea2016-01-17 22:36:44 +010022 'include/pybind11/attr.h',
Jason Rhinelander2b941b32017-05-07 12:19:19 -040023 'include/pybind11/buffer_info.h',
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020024 'include/pybind11/cast.h',
Alessandro Bacchini9f13a302016-12-01 15:22:17 +010025 'include/pybind11/chrono.h',
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020026 'include/pybind11/complex.h',
Wenzel Jakob9e0a0562016-05-05 20:33:54 +020027 'include/pybind11/eigen.h',
Dean Moldovan22c413b2017-03-30 00:20:42 +020028 'include/pybind11/embed.h',
Alessandro Bacchini9f13a302016-12-01 15:22:17 +010029 'include/pybind11/eval.h',
30 'include/pybind11/functional.h',
Henry Schreiner8b405052017-08-24 17:12:43 -070031 'include/pybind11/iostream.h',
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020032 'include/pybind11/numpy.h',
Alessandro Bacchini9f13a302016-12-01 15:22:17 +010033 'include/pybind11/operators.h',
34 'include/pybind11/options.h',
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020035 'include/pybind11/pybind11.h',
Alessandro Bacchini9f13a302016-12-01 15:22:17 +010036 'include/pybind11/pytypes.h',
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020037 'include/pybind11/stl.h',
Wenzel Jakob25c03ce2016-05-15 20:50:38 +020038 'include/pybind11/stl_bind.h',
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010039 ]
40
Dean Moldovan1913f252017-08-23 14:20:53 +020041
42class InstallHeaders(install_headers):
43 """Use custom header installer because the default one flattens subdirectories"""
44 def run(self):
45 if not self.distribution.headers:
46 return
47
48 for header in self.distribution.headers:
49 subdir = os.path.dirname(os.path.relpath(header, 'include/pybind11'))
50 install_dir = os.path.join(self.install_dir, subdir)
51 self.mkpath(install_dir)
52
53 (out, _) = self.copy_file(header, install_dir)
54 self.outfiles.append(out)
55
56
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010057setup(
58 name='pybind11',
59 version=__version__,
60 description='Seamless operability between C++11 and Python',
61 author='Wenzel Jakob',
62 author_email='wenzel.jakob@epfl.ch',
63 url='https://github.com/wjakob/pybind11',
64 download_url='https://github.com/wjakob/pybind11/tarball/v' + __version__,
65 packages=['pybind11'],
66 license='BSD',
67 headers=headers,
Dean Moldovan1913f252017-08-23 14:20:53 +020068 cmdclass=dict(install_headers=InstallHeaders),
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020069 classifiers=[
70 'Development Status :: 5 - Production/Stable',
71 'Intended Audience :: Developers',
72 'Topic :: Software Development :: Libraries :: Python Modules',
73 'Topic :: Utilities',
74 'Programming Language :: C++',
75 'Programming Language :: Python :: 2.7',
76 'Programming Language :: Python :: 3',
77 'Programming Language :: Python :: 3.2',
78 'Programming Language :: Python :: 3.3',
79 'Programming Language :: Python :: 3.4',
Wenzel Jakobb456ec72015-10-15 22:43:55 +020080 'Programming Language :: Python :: 3.5',
Wenzel Jakob2723a382017-01-01 17:14:27 +010081 'Programming Language :: Python :: 3.6',
82 'License :: OSI Approved :: BSD License'
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020083 ],
84 keywords='C++11, Python bindings',
Wenzel Jakob2723a382017-01-01 17:14:27 +010085 long_description="""pybind11 is a lightweight header-only library that
86exposes C++ types in Python and vice versa, mainly to create Python bindings of
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020087existing C++ code. Its goals and syntax are similar to the excellent
Wenzel Jakob2723a382017-01-01 17:14:27 +010088Boost.Python by David Abrahams: to minimize boilerplate code in traditional
89extension modules by inferring type information using compile-time
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020090introspection.
91
Wenzel Jakob0f294e22017-01-04 15:17:18 +010092The main issue with Boost.Python-and the reason for creating such a similar
93project-is Boost. Boost is an enormously large and complex suite of utility
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020094libraries that works with almost every C++ compiler in existence. This
95compatibility has its cost: arcane template tricks and workarounds are
96necessary to support the oldest and buggiest of compiler specimens. Now that
97C++11-compatible compilers are widely available, this heavy machinery has
98become an excessively large and unnecessary dependency.
99
100Think of this library as a tiny self-contained version of Boost.Python with
Wenzel Jakob48548ea2016-01-17 22:36:44 +0100101everything stripped away that isn't relevant for binding generation. Without
Wenzel Jakob2723a382017-01-01 17:14:27 +0100102comments, the core header files only require ~4K lines of code and depend on
103Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This
104compact implementation was possible thanks to some of the new C++11 language
105features (specifically: tuples, lambda functions and variadic templates). Since
106its creation, this library has grown beyond Boost.Python in many ways, leading
107to dramatically simpler binding code in many common situations.""")