setup.py 4.4 KB

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