Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Dean Moldovan | a0c1ccf | 2016-08-12 13:50:00 +0200 | [diff] [blame] | 3 | # Setup script for PyPI; use CMakeFile.txt to build extension modules |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 4 | |
| 5 | from setuptools import setup |
Dean Moldovan | 1913f25 | 2017-08-23 14:20:53 +0200 | [diff] [blame] | 6 | from distutils.command.install_headers import install_headers |
Wenzel Jakob | 4f972c0 | 2016-03-01 10:36:10 +0100 | [diff] [blame] | 7 | from pybind11 import __version__ |
Sylvain Corlay | d5ce82b | 2017-02-14 13:16:14 +0100 | [diff] [blame] | 8 | import os |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 9 | |
Sylvain Corlay | d5ce82b | 2017-02-14 13:16:14 +0100 | [diff] [blame] | 10 | # Prevent installation of pybind11 headers by setting |
| 11 | # PYBIND11_USE_CMAKE. |
| 12 | if os.environ.get('PYBIND11_USE_CMAKE'): |
| 13 | headers = [] |
| 14 | else: |
| 15 | headers = [ |
Dean Moldovan | f580649 | 2017-08-14 00:35:53 +0200 | [diff] [blame] | 16 | 'include/pybind11/detail/class.h', |
| 17 | 'include/pybind11/detail/common.h', |
| 18 | 'include/pybind11/detail/descr.h', |
Jason Rhinelander | 464d989 | 2017-06-12 21:52:48 -0400 | [diff] [blame] | 19 | 'include/pybind11/detail/init.h', |
Dean Moldovan | 024932b | 2017-08-20 16:15:33 +0200 | [diff] [blame] | 20 | 'include/pybind11/detail/internals.h', |
Dean Moldovan | 1913f25 | 2017-08-23 14:20:53 +0200 | [diff] [blame] | 21 | 'include/pybind11/detail/typeid.h', |
Wenzel Jakob | 48548ea | 2016-01-17 22:36:44 +0100 | [diff] [blame] | 22 | 'include/pybind11/attr.h', |
Jason Rhinelander | 2b941b3 | 2017-05-07 12:19:19 -0400 | [diff] [blame] | 23 | 'include/pybind11/buffer_info.h', |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 24 | 'include/pybind11/cast.h', |
Alessandro Bacchini | 9f13a30 | 2016-12-01 15:22:17 +0100 | [diff] [blame] | 25 | 'include/pybind11/chrono.h', |
Dean Moldovan | a80af95 | 2017-09-04 23:22:22 +0200 | [diff] [blame] | 26 | 'include/pybind11/common.h', |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 27 | 'include/pybind11/complex.h', |
Wenzel Jakob | 9e0a056 | 2016-05-05 20:33:54 +0200 | [diff] [blame] | 28 | 'include/pybind11/eigen.h', |
Dean Moldovan | 22c413b | 2017-03-30 00:20:42 +0200 | [diff] [blame] | 29 | 'include/pybind11/embed.h', |
Alessandro Bacchini | 9f13a30 | 2016-12-01 15:22:17 +0100 | [diff] [blame] | 30 | 'include/pybind11/eval.h', |
| 31 | 'include/pybind11/functional.h', |
Henry Schreiner | 8b40505 | 2017-08-24 17:12:43 -0700 | [diff] [blame] | 32 | 'include/pybind11/iostream.h', |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 33 | 'include/pybind11/numpy.h', |
Alessandro Bacchini | 9f13a30 | 2016-12-01 15:22:17 +0100 | [diff] [blame] | 34 | 'include/pybind11/operators.h', |
| 35 | 'include/pybind11/options.h', |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 36 | 'include/pybind11/pybind11.h', |
Alessandro Bacchini | 9f13a30 | 2016-12-01 15:22:17 +0100 | [diff] [blame] | 37 | 'include/pybind11/pytypes.h', |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 38 | 'include/pybind11/stl.h', |
Wenzel Jakob | 25c03ce | 2016-05-15 20:50:38 +0200 | [diff] [blame] | 39 | 'include/pybind11/stl_bind.h', |
Sylvain Corlay | d5ce82b | 2017-02-14 13:16:14 +0100 | [diff] [blame] | 40 | ] |
| 41 | |
Dean Moldovan | 1913f25 | 2017-08-23 14:20:53 +0200 | [diff] [blame] | 42 | |
| 43 | class 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 | |
Sylvain Corlay | d5ce82b | 2017-02-14 13:16:14 +0100 | [diff] [blame] | 58 | setup( |
| 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', |
Maciek Starzyk | 9b02856 | 2018-06-02 20:21:19 +0200 | [diff] [blame] | 64 | url='https://github.com/pybind/pybind11', |
| 65 | download_url='https://github.com/pybind/pybind11/tarball/v' + __version__, |
Sylvain Corlay | d5ce82b | 2017-02-14 13:16:14 +0100 | [diff] [blame] | 66 | packages=['pybind11'], |
| 67 | license='BSD', |
| 68 | headers=headers, |
Dean Moldovan | 1913f25 | 2017-08-23 14:20:53 +0200 | [diff] [blame] | 69 | cmdclass=dict(install_headers=InstallHeaders), |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 70 | 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', |
Wenzel Jakob | b456ec7 | 2015-10-15 22:43:55 +0200 | [diff] [blame] | 81 | 'Programming Language :: Python :: 3.5', |
Wenzel Jakob | 2723a38 | 2017-01-01 17:14:27 +0100 | [diff] [blame] | 82 | 'Programming Language :: Python :: 3.6', |
| 83 | 'License :: OSI Approved :: BSD License' |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 84 | ], |
| 85 | keywords='C++11, Python bindings', |
Wenzel Jakob | 2723a38 | 2017-01-01 17:14:27 +0100 | [diff] [blame] | 86 | long_description="""pybind11 is a lightweight header-only library that |
| 87 | exposes C++ types in Python and vice versa, mainly to create Python bindings of |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 88 | existing C++ code. Its goals and syntax are similar to the excellent |
Wenzel Jakob | 2723a38 | 2017-01-01 17:14:27 +0100 | [diff] [blame] | 89 | Boost.Python by David Abrahams: to minimize boilerplate code in traditional |
| 90 | extension modules by inferring type information using compile-time |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 91 | introspection. |
| 92 | |
Wenzel Jakob | 0f294e2 | 2017-01-04 15:17:18 +0100 | [diff] [blame] | 93 | The main issue with Boost.Python-and the reason for creating such a similar |
| 94 | project-is Boost. Boost is an enormously large and complex suite of utility |
Wenzel Jakob | 929fd7e | 2015-10-15 18:24:12 +0200 | [diff] [blame] | 95 | libraries that works with almost every C++ compiler in existence. This |
| 96 | compatibility has its cost: arcane template tricks and workarounds are |
| 97 | necessary to support the oldest and buggiest of compiler specimens. Now that |
| 98 | C++11-compatible compilers are widely available, this heavy machinery has |
| 99 | become an excessively large and unnecessary dependency. |
| 100 | |
| 101 | Think of this library as a tiny self-contained version of Boost.Python with |
Wenzel Jakob | 48548ea | 2016-01-17 22:36:44 +0100 | [diff] [blame] | 102 | everything stripped away that isn't relevant for binding generation. Without |
Wenzel Jakob | 2723a38 | 2017-01-01 17:14:27 +0100 | [diff] [blame] | 103 | comments, the core header files only require ~4K lines of code and depend on |
| 104 | Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This |
| 105 | compact implementation was possible thanks to some of the new C++11 language |
| 106 | features (specifically: tuples, lambda functions and variadic templates). Since |
| 107 | its creation, this library has grown beyond Boost.Python in many ways, leading |
| 108 | to dramatically simpler binding code in many common situations.""") |