blob: 473ea1ee082f59f16c5568a9ef66ef4ae1c19706 [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
Isuru Fernando37352492019-11-28 01:59:23 -06007from distutils.command.build_py import build_py
Wenzel Jakob4f972c02016-03-01 10:36:10 +01008from pybind11 import __version__
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +01009import os
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020010
Isuru Fernando37352492019-11-28 01:59:23 -060011package_data = [
12 'include/pybind11/detail/class.h',
13 'include/pybind11/detail/common.h',
14 'include/pybind11/detail/descr.h',
15 'include/pybind11/detail/init.h',
16 'include/pybind11/detail/internals.h',
17 'include/pybind11/detail/typeid.h',
18 'include/pybind11/attr.h',
19 'include/pybind11/buffer_info.h',
20 'include/pybind11/cast.h',
21 'include/pybind11/chrono.h',
22 'include/pybind11/common.h',
23 'include/pybind11/complex.h',
24 'include/pybind11/eigen.h',
25 'include/pybind11/embed.h',
26 'include/pybind11/eval.h',
27 'include/pybind11/functional.h',
28 'include/pybind11/iostream.h',
29 'include/pybind11/numpy.h',
30 'include/pybind11/operators.h',
31 'include/pybind11/options.h',
32 'include/pybind11/pybind11.h',
33 'include/pybind11/pytypes.h',
34 'include/pybind11/stl.h',
35 'include/pybind11/stl_bind.h',
36]
37
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010038# Prevent installation of pybind11 headers by setting
39# PYBIND11_USE_CMAKE.
40if os.environ.get('PYBIND11_USE_CMAKE'):
41 headers = []
42else:
Isuru Fernando37352492019-11-28 01:59:23 -060043 headers = package_data
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010044
Dean Moldovan1913f252017-08-23 14:20:53 +020045
46class InstallHeaders(install_headers):
47 """Use custom header installer because the default one flattens subdirectories"""
48 def run(self):
49 if not self.distribution.headers:
50 return
51
52 for header in self.distribution.headers:
53 subdir = os.path.dirname(os.path.relpath(header, 'include/pybind11'))
54 install_dir = os.path.join(self.install_dir, subdir)
55 self.mkpath(install_dir)
56
57 (out, _) = self.copy_file(header, install_dir)
58 self.outfiles.append(out)
59
60
Isuru Fernando37352492019-11-28 01:59:23 -060061# Install the headers inside the package as well
62class BuildPy(build_py):
63 def build_package_data(self):
64 build_py.build_package_data(self)
65 for header in package_data:
66 target = os.path.join(self.build_lib, 'pybind11', header)
67 self.mkpath(os.path.dirname(target))
68 self.copy_file(header, target, preserve_mode=False)
69
70
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010071setup(
72 name='pybind11',
73 version=__version__,
74 description='Seamless operability between C++11 and Python',
75 author='Wenzel Jakob',
76 author_email='wenzel.jakob@epfl.ch',
Maciek Starzyk9b028562018-06-02 20:21:19 +020077 url='https://github.com/pybind/pybind11',
78 download_url='https://github.com/pybind/pybind11/tarball/v' + __version__,
Sylvain Corlayd5ce82b2017-02-14 13:16:14 +010079 packages=['pybind11'],
80 license='BSD',
81 headers=headers,
Isuru Fernando37352492019-11-28 01:59:23 -060082 zip_safe=False,
83 cmdclass=dict(install_headers=InstallHeaders, build_py=BuildPy),
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020084 classifiers=[
85 'Development Status :: 5 - Production/Stable',
86 'Intended Audience :: Developers',
87 'Topic :: Software Development :: Libraries :: Python Modules',
88 'Topic :: Utilities',
89 'Programming Language :: C++',
90 'Programming Language :: Python :: 2.7',
91 'Programming Language :: Python :: 3',
92 'Programming Language :: Python :: 3.2',
93 'Programming Language :: Python :: 3.3',
94 'Programming Language :: Python :: 3.4',
Wenzel Jakobb456ec72015-10-15 22:43:55 +020095 'Programming Language :: Python :: 3.5',
Wenzel Jakob2723a382017-01-01 17:14:27 +010096 'Programming Language :: Python :: 3.6',
97 'License :: OSI Approved :: BSD License'
Wenzel Jakob929fd7e2015-10-15 18:24:12 +020098 ],
99 keywords='C++11, Python bindings',
Wenzel Jakob2723a382017-01-01 17:14:27 +0100100 long_description="""pybind11 is a lightweight header-only library that
101exposes C++ types in Python and vice versa, mainly to create Python bindings of
Wenzel Jakob929fd7e2015-10-15 18:24:12 +0200102existing C++ code. Its goals and syntax are similar to the excellent
Wenzel Jakob2723a382017-01-01 17:14:27 +0100103Boost.Python by David Abrahams: to minimize boilerplate code in traditional
104extension modules by inferring type information using compile-time
Wenzel Jakob929fd7e2015-10-15 18:24:12 +0200105introspection.
106
Wenzel Jakob0f294e22017-01-04 15:17:18 +0100107The main issue with Boost.Python-and the reason for creating such a similar
108project-is Boost. Boost is an enormously large and complex suite of utility
Wenzel Jakob929fd7e2015-10-15 18:24:12 +0200109libraries that works with almost every C++ compiler in existence. This
110compatibility has its cost: arcane template tricks and workarounds are
111necessary to support the oldest and buggiest of compiler specimens. Now that
112C++11-compatible compilers are widely available, this heavy machinery has
113become an excessively large and unnecessary dependency.
114
115Think of this library as a tiny self-contained version of Boost.Python with
Wenzel Jakob48548ea2016-01-17 22:36:44 +0100116everything stripped away that isn't relevant for binding generation. Without
Wenzel Jakob2723a382017-01-01 17:14:27 +0100117comments, the core header files only require ~4K lines of code and depend on
118Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This
119compact implementation was possible thanks to some of the new C++11 language
120features (specifically: tuples, lambda functions and variadic templates). Since
121its creation, this library has grown beyond Boost.Python in many ways, leading
122to dramatically simpler binding code in many common situations.""")