xcoll 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xcoll might be problematic. Click here for more details.

Files changed (324) hide show
  1. xcoll/__init__.py +2 -1
  2. xcoll/beam_elements/__init__.py +7 -1
  3. xcoll/beam_elements/absorber.py +2 -2
  4. xcoll/beam_elements/base.py +105 -67
  5. xcoll/beam_elements/blowup.py +198 -0
  6. xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
  7. xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
  8. xcoll/beam_elements/elements_src/blowup.h +42 -0
  9. xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
  10. xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +19 -2
  11. xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
  12. xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
  13. xcoll/beam_elements/everest.py +5 -6
  14. xcoll/beam_elements/monitor.py +428 -0
  15. xcoll/colldb.py +103 -74
  16. xcoll/general.py +4 -4
  17. xcoll/initial_distribution.py +18 -6
  18. xcoll/install.py +3 -1
  19. xcoll/interaction_record/interaction_record.py +126 -80
  20. xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
  21. xcoll/line_tools.py +8 -9
  22. xcoll/lossmap.py +48 -38
  23. xcoll/scattering_routines/everest/amorphous.h +4 -11
  24. xcoll/scattering_routines/everest/channeling.h +3 -8
  25. xcoll/scattering_routines/everest/everest.h +4 -1
  26. xcoll/scattering_routines/everest/jaw.h +4 -3
  27. xcoll/scattering_routines/everest/materials.py +35 -15
  28. xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
  29. xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
  30. xcoll/scattering_routines/everest/properties.h +6 -1
  31. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  32. xcoll/scattering_routines/geant4/collimasim/.git +1 -0
  33. xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
  34. xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
  35. xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
  36. xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
  37. xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
  38. xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
  39. xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
  40. xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
  41. xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
  42. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
  43. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
  44. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
  45. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
  46. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
  47. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
  48. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
  49. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
  50. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
  51. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
  52. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
  53. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
  54. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
  55. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
  56. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
  57. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
  58. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
  59. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
  60. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
  61. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
  62. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
  63. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
  64. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
  65. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
  66. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
  67. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
  68. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
  69. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
  70. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
  71. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
  72. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
  73. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
  74. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
  75. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
  76. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
  77. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
  78. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
  79. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
  80. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
  81. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
  82. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
  83. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
  84. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
  85. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
  86. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
  87. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
  88. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
  89. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
  90. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
  91. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
  92. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
  93. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
  94. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
  95. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
  96. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
  97. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
  98. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
  99. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
  100. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
  101. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
  102. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
  103. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
  104. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
  105. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
  106. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
  107. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
  108. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
  109. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
  110. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
  111. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
  112. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
  113. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
  114. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
  115. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
  116. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
  117. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
  118. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
  119. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
  120. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
  121. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
  122. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
  123. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
  124. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
  125. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
  126. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
  127. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
  128. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
  129. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
  130. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
  131. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
  132. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
  133. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
  134. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
  135. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
  136. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
  137. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
  138. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
  139. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
  140. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
  141. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
  142. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
  143. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
  144. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
  145. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
  146. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
  147. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
  148. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
  149. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
  150. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
  151. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
  152. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
  153. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
  154. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
  155. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
  156. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
  157. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
  158. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
  159. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
  160. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
  161. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
  162. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
  163. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
  164. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
  165. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
  166. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
  167. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
  168. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
  169. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
  170. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
  171. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
  172. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
  173. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
  174. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
  175. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
  176. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
  177. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
  178. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
  179. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
  180. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
  181. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
  182. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
  183. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
  184. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
  185. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
  186. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
  187. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
  188. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
  189. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
  190. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
  191. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
  192. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
  193. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
  194. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
  195. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
  196. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
  197. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
  198. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
  199. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
  200. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
  201. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
  202. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
  203. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
  204. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
  205. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
  206. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
  207. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
  208. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
  209. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
  210. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
  211. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
  212. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
  213. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
  214. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
  215. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
  216. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
  217. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
  218. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
  219. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
  220. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
  221. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
  222. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
  223. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
  224. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
  225. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
  226. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
  227. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
  228. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
  229. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
  230. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
  231. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
  232. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
  233. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
  234. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
  235. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
  236. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
  237. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
  238. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
  239. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
  240. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
  241. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
  242. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
  243. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
  244. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
  245. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
  246. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
  247. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
  248. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
  249. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
  250. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
  251. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
  252. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
  253. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
  254. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
  255. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
  256. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
  257. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
  258. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
  259. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
  260. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
  261. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
  262. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
  263. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
  264. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
  265. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
  266. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
  267. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
  268. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
  269. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
  270. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
  271. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
  272. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
  273. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
  274. xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
  275. xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
  276. xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
  277. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
  278. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
  279. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
  280. xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
  281. xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
  282. xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
  283. xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
  284. xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
  285. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
  286. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
  287. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
  288. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
  289. xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
  290. xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
  291. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
  292. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
  293. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
  294. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
  295. xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
  296. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
  297. xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
  298. xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
  299. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
  300. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
  301. xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
  302. xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
  303. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
  304. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
  305. xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
  306. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
  307. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
  308. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
  309. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
  310. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
  311. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
  312. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
  313. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
  314. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
  315. xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
  316. xcoll/scattering_routines/geometry/collimator_geometry.h +9 -10
  317. xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
  318. {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
  319. xcoll-0.5.0.dist-info/RECORD +413 -0
  320. xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
  321. xcoll-0.4.0.dist-info/RECORD +0 -126
  322. {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
  323. {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
  324. {xcoll-0.4.0.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,648 @@
1
+ .. _compiling:
2
+
3
+ Build systems
4
+ #############
5
+
6
+ .. _build-setuptools:
7
+
8
+ Building with setuptools
9
+ ========================
10
+
11
+ For projects on PyPI, building with setuptools is the way to go. Sylvain Corlay
12
+ has kindly provided an example project which shows how to set up everything,
13
+ including automatic generation of documentation using Sphinx. Please refer to
14
+ the [python_example]_ repository.
15
+
16
+ .. [python_example] https://github.com/pybind/python_example
17
+
18
+ A helper file is provided with pybind11 that can simplify usage with setuptools.
19
+
20
+ To use pybind11 inside your ``setup.py``, you have to have some system to
21
+ ensure that ``pybind11`` is installed when you build your package. There are
22
+ four possible ways to do this, and pybind11 supports all four: You can ask all
23
+ users to install pybind11 beforehand (bad), you can use
24
+ :ref:`setup_helpers-pep518` (good, but very new and requires Pip 10),
25
+ :ref:`setup_helpers-setup_requires` (discouraged by Python packagers now that
26
+ PEP 518 is available, but it still works everywhere), or you can
27
+ :ref:`setup_helpers-copy-manually` (always works but you have to manually sync
28
+ your copy to get updates).
29
+
30
+ An example of a ``setup.py`` using pybind11's helpers:
31
+
32
+ .. code-block:: python
33
+
34
+ from glob import glob
35
+ from setuptools import setup
36
+ from pybind11.setup_helpers import Pybind11Extension
37
+
38
+ ext_modules = [
39
+ Pybind11Extension(
40
+ "python_example",
41
+ sorted(glob("src/*.cpp")), # Sort source files for reproducibility
42
+ ),
43
+ ]
44
+
45
+ setup(..., ext_modules=ext_modules)
46
+
47
+ If you want to do an automatic search for the highest supported C++ standard,
48
+ that is supported via a ``build_ext`` command override; it will only affect
49
+ ``Pybind11Extensions``:
50
+
51
+ .. code-block:: python
52
+
53
+ from glob import glob
54
+ from setuptools import setup
55
+ from pybind11.setup_helpers import Pybind11Extension, build_ext
56
+
57
+ ext_modules = [
58
+ Pybind11Extension(
59
+ "python_example",
60
+ sorted(glob("src/*.cpp")),
61
+ ),
62
+ ]
63
+
64
+ setup(..., cmdclass={"build_ext": build_ext}, ext_modules=ext_modules)
65
+
66
+ If you have single-file extension modules that are directly stored in the
67
+ Python source tree (``foo.cpp`` in the same directory as where a ``foo.py``
68
+ would be located), you can also generate ``Pybind11Extensions`` using
69
+ ``setup_helpers.intree_extensions``: ``intree_extensions(["path/to/foo.cpp",
70
+ ...])`` returns a list of ``Pybind11Extensions`` which can be passed to
71
+ ``ext_modules``, possibly after further customizing their attributes
72
+ (``libraries``, ``include_dirs``, etc.). By doing so, a ``foo.*.so`` extension
73
+ module will be generated and made available upon installation.
74
+
75
+ ``intree_extension`` will automatically detect if you are using a ``src``-style
76
+ layout (as long as no namespace packages are involved), but you can also
77
+ explicitly pass ``package_dir`` to it (as in ``setuptools.setup``).
78
+
79
+ Since pybind11 does not require NumPy when building, a light-weight replacement
80
+ for NumPy's parallel compilation distutils tool is included. Use it like this:
81
+
82
+ .. code-block:: python
83
+
84
+ from pybind11.setup_helpers import ParallelCompile
85
+
86
+ # Optional multithreaded build
87
+ ParallelCompile("NPY_NUM_BUILD_JOBS").install()
88
+
89
+ setup(...)
90
+
91
+ The argument is the name of an environment variable to control the number of
92
+ threads, such as ``NPY_NUM_BUILD_JOBS`` (as used by NumPy), though you can set
93
+ something different if you want; ``CMAKE_BUILD_PARALLEL_LEVEL`` is another choice
94
+ a user might expect. You can also pass ``default=N`` to set the default number
95
+ of threads (0 will take the number of threads available) and ``max=N``, the
96
+ maximum number of threads; if you have a large extension you may want set this
97
+ to a memory dependent number.
98
+
99
+ If you are developing rapidly and have a lot of C++ files, you may want to
100
+ avoid rebuilding files that have not changed. For simple cases were you are
101
+ using ``pip install -e .`` and do not have local headers, you can skip the
102
+ rebuild if an object file is newer than its source (headers are not checked!)
103
+ with the following:
104
+
105
+ .. code-block:: python
106
+
107
+ from pybind11.setup_helpers import ParallelCompile, naive_recompile
108
+
109
+ ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install()
110
+
111
+
112
+ If you have a more complex build, you can implement a smarter function and pass
113
+ it to ``needs_recompile``, or you can use [Ccache]_ instead. ``CXX="cache g++"
114
+ pip install -e .`` would be the way to use it with GCC, for example. Unlike the
115
+ simple solution, this even works even when not compiling in editable mode, but
116
+ it does require Ccache to be installed.
117
+
118
+ Keep in mind that Pip will not even attempt to rebuild if it thinks it has
119
+ already built a copy of your code, which it deduces from the version number.
120
+ One way to avoid this is to use [setuptools_scm]_, which will generate a
121
+ version number that includes the number of commits since your last tag and a
122
+ hash for a dirty directory. Another way to force a rebuild is purge your cache
123
+ or use Pip's ``--no-cache-dir`` option.
124
+
125
+ .. [Ccache] https://ccache.dev
126
+
127
+ .. [setuptools_scm] https://github.com/pypa/setuptools_scm
128
+
129
+ .. _setup_helpers-pep518:
130
+
131
+ PEP 518 requirements (Pip 10+ required)
132
+ ---------------------------------------
133
+
134
+ If you use `PEP 518's <https://www.python.org/dev/peps/pep-0518/>`_
135
+ ``pyproject.toml`` file, you can ensure that ``pybind11`` is available during
136
+ the compilation of your project. When this file exists, Pip will make a new
137
+ virtual environment, download just the packages listed here in ``requires=``,
138
+ and build a wheel (binary Python package). It will then throw away the
139
+ environment, and install your wheel.
140
+
141
+ Your ``pyproject.toml`` file will likely look something like this:
142
+
143
+ .. code-block:: toml
144
+
145
+ [build-system]
146
+ requires = ["setuptools>=42", "wheel", "pybind11~=2.6.1"]
147
+ build-backend = "setuptools.build_meta"
148
+
149
+ .. note::
150
+
151
+ The main drawback to this method is that a `PEP 517`_ compliant build tool,
152
+ such as Pip 10+, is required for this approach to work; older versions of
153
+ Pip completely ignore this file. If you distribute binaries (called wheels
154
+ in Python) using something like `cibuildwheel`_, remember that ``setup.py``
155
+ and ``pyproject.toml`` are not even contained in the wheel, so this high
156
+ Pip requirement is only for source builds, and will not affect users of
157
+ your binary wheels. If you are building SDists and wheels, then
158
+ `pypa-build`_ is the recommended official tool.
159
+
160
+ .. _PEP 517: https://www.python.org/dev/peps/pep-0517/
161
+ .. _cibuildwheel: https://cibuildwheel.readthedocs.io
162
+ .. _pypa-build: https://pypa-build.readthedocs.io/en/latest/
163
+
164
+ .. _setup_helpers-setup_requires:
165
+
166
+ Classic ``setup_requires``
167
+ --------------------------
168
+
169
+ If you want to support old versions of Pip with the classic
170
+ ``setup_requires=["pybind11"]`` keyword argument to setup, which triggers a
171
+ two-phase ``setup.py`` run, then you will need to use something like this to
172
+ ensure the first pass works (which has not yet installed the ``setup_requires``
173
+ packages, since it can't install something it does not know about):
174
+
175
+ .. code-block:: python
176
+
177
+ try:
178
+ from pybind11.setup_helpers import Pybind11Extension
179
+ except ImportError:
180
+ from setuptools import Extension as Pybind11Extension
181
+
182
+
183
+ It doesn't matter that the Extension class is not the enhanced subclass for the
184
+ first pass run; and the second pass will have the ``setup_requires``
185
+ requirements.
186
+
187
+ This is obviously more of a hack than the PEP 518 method, but it supports
188
+ ancient versions of Pip.
189
+
190
+ .. _setup_helpers-copy-manually:
191
+
192
+ Copy manually
193
+ -------------
194
+
195
+ You can also copy ``setup_helpers.py`` directly to your project; it was
196
+ designed to be usable standalone, like the old example ``setup.py``. You can
197
+ set ``include_pybind11=False`` to skip including the pybind11 package headers,
198
+ so you can use it with git submodules and a specific git version. If you use
199
+ this, you will need to import from a local file in ``setup.py`` and ensure the
200
+ helper file is part of your MANIFEST.
201
+
202
+
203
+ Closely related, if you include pybind11 as a subproject, you can run the
204
+ ``setup_helpers.py`` inplace. If loaded correctly, this should even pick up
205
+ the correct include for pybind11, though you can turn it off as shown above if
206
+ you want to input it manually.
207
+
208
+ Suggested usage if you have pybind11 as a submodule in ``extern/pybind11``:
209
+
210
+ .. code-block:: python
211
+
212
+ DIR = os.path.abspath(os.path.dirname(__file__))
213
+
214
+ sys.path.append(os.path.join(DIR, "extern", "pybind11"))
215
+ from pybind11.setup_helpers import Pybind11Extension # noqa: E402
216
+
217
+ del sys.path[-1]
218
+
219
+
220
+ .. versionchanged:: 2.6
221
+
222
+ Added ``setup_helpers`` file.
223
+
224
+ Building with cppimport
225
+ ========================
226
+
227
+ [cppimport]_ is a small Python import hook that determines whether there is a C++
228
+ source file whose name matches the requested module. If there is, the file is
229
+ compiled as a Python extension using pybind11 and placed in the same folder as
230
+ the C++ source file. Python is then able to find the module and load it.
231
+
232
+ .. [cppimport] https://github.com/tbenthompson/cppimport
233
+
234
+ .. _cmake:
235
+
236
+ Building with CMake
237
+ ===================
238
+
239
+ For C++ codebases that have an existing CMake-based build system, a Python
240
+ extension module can be created with just a few lines of code:
241
+
242
+ .. code-block:: cmake
243
+
244
+ cmake_minimum_required(VERSION 3.4...3.18)
245
+ project(example LANGUAGES CXX)
246
+
247
+ add_subdirectory(pybind11)
248
+ pybind11_add_module(example example.cpp)
249
+
250
+ This assumes that the pybind11 repository is located in a subdirectory named
251
+ :file:`pybind11` and that the code is located in a file named :file:`example.cpp`.
252
+ The CMake command ``add_subdirectory`` will import the pybind11 project which
253
+ provides the ``pybind11_add_module`` function. It will take care of all the
254
+ details needed to build a Python extension module on any platform.
255
+
256
+ A working sample project, including a way to invoke CMake from :file:`setup.py` for
257
+ PyPI integration, can be found in the [cmake_example]_ repository.
258
+
259
+ .. [cmake_example] https://github.com/pybind/cmake_example
260
+
261
+ .. versionchanged:: 2.6
262
+ CMake 3.4+ is required.
263
+
264
+ Further information can be found at :doc:`cmake/index`.
265
+
266
+ pybind11_add_module
267
+ -------------------
268
+
269
+ To ease the creation of Python extension modules, pybind11 provides a CMake
270
+ function with the following signature:
271
+
272
+ .. code-block:: cmake
273
+
274
+ pybind11_add_module(<name> [MODULE | SHARED] [EXCLUDE_FROM_ALL]
275
+ [NO_EXTRAS] [THIN_LTO] [OPT_SIZE] source1 [source2 ...])
276
+
277
+ This function behaves very much like CMake's builtin ``add_library`` (in fact,
278
+ it's a wrapper function around that command). It will add a library target
279
+ called ``<name>`` to be built from the listed source files. In addition, it
280
+ will take care of all the Python-specific compiler and linker flags as well
281
+ as the OS- and Python-version-specific file extension. The produced target
282
+ ``<name>`` can be further manipulated with regular CMake commands.
283
+
284
+ ``MODULE`` or ``SHARED`` may be given to specify the type of library. If no
285
+ type is given, ``MODULE`` is used by default which ensures the creation of a
286
+ Python-exclusive module. Specifying ``SHARED`` will create a more traditional
287
+ dynamic library which can also be linked from elsewhere. ``EXCLUDE_FROM_ALL``
288
+ removes this target from the default build (see CMake docs for details).
289
+
290
+ Since pybind11 is a template library, ``pybind11_add_module`` adds compiler
291
+ flags to ensure high quality code generation without bloat arising from long
292
+ symbol names and duplication of code in different translation units. It
293
+ sets default visibility to *hidden*, which is required for some pybind11
294
+ features and functionality when attempting to load multiple pybind11 modules
295
+ compiled under different pybind11 versions. It also adds additional flags
296
+ enabling LTO (Link Time Optimization) and strip unneeded symbols. See the
297
+ :ref:`FAQ entry <faq:symhidden>` for a more detailed explanation. These
298
+ latter optimizations are never applied in ``Debug`` mode. If ``NO_EXTRAS`` is
299
+ given, they will always be disabled, even in ``Release`` mode. However, this
300
+ will result in code bloat and is generally not recommended.
301
+
302
+ As stated above, LTO is enabled by default. Some newer compilers also support
303
+ different flavors of LTO such as `ThinLTO`_. Setting ``THIN_LTO`` will cause
304
+ the function to prefer this flavor if available. The function falls back to
305
+ regular LTO if ``-flto=thin`` is not available. If
306
+ ``CMAKE_INTERPROCEDURAL_OPTIMIZATION`` is set (either ``ON`` or ``OFF``), then
307
+ that will be respected instead of the built-in flag search.
308
+
309
+ .. note::
310
+
311
+ If you want to set the property form on targets or the
312
+ ``CMAKE_INTERPROCEDURAL_OPTIMIZATION_<CONFIG>`` versions of this, you should
313
+ still use ``set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)`` (otherwise a
314
+ no-op) to disable pybind11's ipo flags.
315
+
316
+ The ``OPT_SIZE`` flag enables size-based optimization equivalent to the
317
+ standard ``/Os`` or ``-Os`` compiler flags and the ``MinSizeRel`` build type,
318
+ which avoid optimizations that that can substantially increase the size of the
319
+ resulting binary. This flag is particularly useful in projects that are split
320
+ into performance-critical parts and associated bindings. In this case, we can
321
+ compile the project in release mode (and hence, optimize performance globally),
322
+ and specify ``OPT_SIZE`` for the binding target, where size might be the main
323
+ concern as performance is often less critical here. A ~25% size reduction has
324
+ been observed in practice. This flag only changes the optimization behavior at
325
+ a per-target level and takes precedence over the global CMake build type
326
+ (``Release``, ``RelWithDebInfo``) except for ``Debug`` builds, where
327
+ optimizations remain disabled.
328
+
329
+ .. _ThinLTO: http://clang.llvm.org/docs/ThinLTO.html
330
+
331
+ Configuration variables
332
+ -----------------------
333
+
334
+ By default, pybind11 will compile modules with the compiler default or the
335
+ minimum standard required by pybind11, whichever is higher. You can set the
336
+ standard explicitly with
337
+ `CMAKE_CXX_STANDARD <https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html>`_:
338
+
339
+ .. code-block:: cmake
340
+
341
+ set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ version selection") # or 11, 14, 17, 20
342
+ set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported
343
+ set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensions off
344
+
345
+ The variables can also be set when calling CMake from the command line using
346
+ the ``-D<variable>=<value>`` flag. You can also manually set ``CXX_STANDARD``
347
+ on a target or use ``target_compile_features`` on your targets - anything that
348
+ CMake supports.
349
+
350
+ Classic Python support: The target Python version can be selected by setting
351
+ ``PYBIND11_PYTHON_VERSION`` or an exact Python installation can be specified
352
+ with ``PYTHON_EXECUTABLE``. For example:
353
+
354
+ .. code-block:: bash
355
+
356
+ cmake -DPYBIND11_PYTHON_VERSION=3.6 ..
357
+
358
+ # Another method:
359
+ cmake -DPYTHON_EXECUTABLE=/path/to/python ..
360
+
361
+ # This often is a good way to get the current Python, works in environments:
362
+ cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") ..
363
+
364
+
365
+ find_package vs. add_subdirectory
366
+ ---------------------------------
367
+
368
+ For CMake-based projects that don't include the pybind11 repository internally,
369
+ an external installation can be detected through ``find_package(pybind11)``.
370
+ See the `Config file`_ docstring for details of relevant CMake variables.
371
+
372
+ .. code-block:: cmake
373
+
374
+ cmake_minimum_required(VERSION 3.4...3.18)
375
+ project(example LANGUAGES CXX)
376
+
377
+ find_package(pybind11 REQUIRED)
378
+ pybind11_add_module(example example.cpp)
379
+
380
+ Note that ``find_package(pybind11)`` will only work correctly if pybind11
381
+ has been correctly installed on the system, e. g. after downloading or cloning
382
+ the pybind11 repository :
383
+
384
+ .. code-block:: bash
385
+
386
+ # Classic CMake
387
+ cd pybind11
388
+ mkdir build
389
+ cd build
390
+ cmake ..
391
+ make install
392
+
393
+ # CMake 3.15+
394
+ cd pybind11
395
+ cmake -S . -B build
396
+ cmake --build build -j 2 # Build on 2 cores
397
+ cmake --install build
398
+
399
+ Once detected, the aforementioned ``pybind11_add_module`` can be employed as
400
+ before. The function usage and configuration variables are identical no matter
401
+ if pybind11 is added as a subdirectory or found as an installed package. You
402
+ can refer to the same [cmake_example]_ repository for a full sample project
403
+ -- just swap out ``add_subdirectory`` for ``find_package``.
404
+
405
+ .. _Config file: https://github.com/pybind/pybind11/blob/master/tools/pybind11Config.cmake.in
406
+
407
+
408
+ .. _find-python-mode:
409
+
410
+ FindPython mode
411
+ ---------------
412
+
413
+ CMake 3.12+ (3.15+ recommended, 3.18.2+ ideal) added a new module called
414
+ FindPython that had a highly improved search algorithm and modern targets
415
+ and tools. If you use FindPython, pybind11 will detect this and use the
416
+ existing targets instead:
417
+
418
+ .. code-block:: cmake
419
+
420
+ cmake_minimum_required(VERSION 3.15...3.19)
421
+ project(example LANGUAGES CXX)
422
+
423
+ find_package(Python COMPONENTS Interpreter Development REQUIRED)
424
+ find_package(pybind11 CONFIG REQUIRED)
425
+ # or add_subdirectory(pybind11)
426
+
427
+ pybind11_add_module(example example.cpp)
428
+
429
+ You can also use the targets (as listed below) with FindPython. If you define
430
+ ``PYBIND11_FINDPYTHON``, pybind11 will perform the FindPython step for you
431
+ (mostly useful when building pybind11's own tests, or as a way to change search
432
+ algorithms from the CMake invocation, with ``-DPYBIND11_FINDPYTHON=ON``.
433
+
434
+ .. warning::
435
+
436
+ If you use FindPython2 and FindPython3 to dual-target Python, use the
437
+ individual targets listed below, and avoid targets that directly include
438
+ Python parts.
439
+
440
+ There are `many ways to hint or force a discovery of a specific Python
441
+ installation <https://cmake.org/cmake/help/latest/module/FindPython.html>`_),
442
+ setting ``Python_ROOT_DIR`` may be the most common one (though with
443
+ virtualenv/venv support, and Conda support, this tends to find the correct
444
+ Python version more often than the old system did).
445
+
446
+ .. warning::
447
+
448
+ When the Python libraries (i.e. ``libpythonXX.a`` and ``libpythonXX.so``
449
+ on Unix) are not available, as is the case on a manylinux image, the
450
+ ``Development`` component will not be resolved by ``FindPython``. When not
451
+ using the embedding functionality, CMake 3.18+ allows you to specify
452
+ ``Development.Module`` instead of ``Development`` to resolve this issue.
453
+
454
+ .. versionadded:: 2.6
455
+
456
+ Advanced: interface library targets
457
+ -----------------------------------
458
+
459
+ Pybind11 supports modern CMake usage patterns with a set of interface targets,
460
+ available in all modes. The targets provided are:
461
+
462
+ ``pybind11::headers``
463
+ Just the pybind11 headers and minimum compile requirements
464
+
465
+ ``pybind11::python2_no_register``
466
+ Quiets the warning/error when mixing C++14 or higher and Python 2
467
+
468
+ ``pybind11::pybind11``
469
+ Python headers + ``pybind11::headers`` + ``pybind11::python2_no_register`` (Python 2 only)
470
+
471
+ ``pybind11::python_link_helper``
472
+ Just the "linking" part of pybind11:module
473
+
474
+ ``pybind11::module``
475
+ Everything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython CMake 3.15+) or ``pybind11::python_link_helper``
476
+
477
+ ``pybind11::embed``
478
+ Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Embed`` (FindPython) or Python libs
479
+
480
+ ``pybind11::lto`` / ``pybind11::thin_lto``
481
+ An alternative to `INTERPROCEDURAL_OPTIMIZATION` for adding link-time optimization.
482
+
483
+ ``pybind11::windows_extras``
484
+ ``/bigobj`` and ``/mp`` for MSVC.
485
+
486
+ ``pybind11::opt_size``
487
+ ``/Os`` for MSVC, ``-Os`` for other compilers. Does nothing for debug builds.
488
+
489
+ Two helper functions are also provided:
490
+
491
+ ``pybind11_strip(target)``
492
+ Strips a target (uses ``CMAKE_STRIP`` after the target is built)
493
+
494
+ ``pybind11_extension(target)``
495
+ Sets the correct extension (with SOABI) for a target.
496
+
497
+ You can use these targets to build complex applications. For example, the
498
+ ``add_python_module`` function is identical to:
499
+
500
+ .. code-block:: cmake
501
+
502
+ cmake_minimum_required(VERSION 3.4)
503
+ project(example LANGUAGES CXX)
504
+
505
+ find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
506
+
507
+ add_library(example MODULE main.cpp)
508
+
509
+ target_link_libraries(example PRIVATE pybind11::module pybind11::lto pybind11::windows_extras)
510
+
511
+ pybind11_extension(example)
512
+ pybind11_strip(example)
513
+
514
+ set_target_properties(example PROPERTIES CXX_VISIBILITY_PRESET "hidden"
515
+ CUDA_VISIBILITY_PRESET "hidden")
516
+
517
+ Instead of setting properties, you can set ``CMAKE_*`` variables to initialize these correctly.
518
+
519
+ .. warning::
520
+
521
+ Since pybind11 is a metatemplate library, it is crucial that certain
522
+ compiler flags are provided to ensure high quality code generation. In
523
+ contrast to the ``pybind11_add_module()`` command, the CMake interface
524
+ provides a *composable* set of targets to ensure that you retain flexibility.
525
+ It can be especially important to provide or set these properties; the
526
+ :ref:`FAQ <faq:symhidden>` contains an explanation on why these are needed.
527
+
528
+ .. versionadded:: 2.6
529
+
530
+ .. _nopython-mode:
531
+
532
+ Advanced: NOPYTHON mode
533
+ -----------------------
534
+
535
+ If you want complete control, you can set ``PYBIND11_NOPYTHON`` to completely
536
+ disable Python integration (this also happens if you run ``FindPython2`` and
537
+ ``FindPython3`` without running ``FindPython``). This gives you complete
538
+ freedom to integrate into an existing system (like `Scikit-Build's
539
+ <https://scikit-build.readthedocs.io>`_ ``PythonExtensions``).
540
+ ``pybind11_add_module`` and ``pybind11_extension`` will be unavailable, and the
541
+ targets will be missing any Python specific behavior.
542
+
543
+ .. versionadded:: 2.6
544
+
545
+ Embedding the Python interpreter
546
+ --------------------------------
547
+
548
+ In addition to extension modules, pybind11 also supports embedding Python into
549
+ a C++ executable or library. In CMake, simply link with the ``pybind11::embed``
550
+ target. It provides everything needed to get the interpreter running. The Python
551
+ headers and libraries are attached to the target. Unlike ``pybind11::module``,
552
+ there is no need to manually set any additional properties here. For more
553
+ information about usage in C++, see :doc:`/advanced/embedding`.
554
+
555
+ .. code-block:: cmake
556
+
557
+ cmake_minimum_required(VERSION 3.4...3.18)
558
+ project(example LANGUAGES CXX)
559
+
560
+ find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
561
+
562
+ add_executable(example main.cpp)
563
+ target_link_libraries(example PRIVATE pybind11::embed)
564
+
565
+ .. _building_manually:
566
+
567
+ Building manually
568
+ =================
569
+
570
+ pybind11 is a header-only library, hence it is not necessary to link against
571
+ any special libraries and there are no intermediate (magic) translation steps.
572
+
573
+ On Linux, you can compile an example such as the one given in
574
+ :ref:`simple_example` using the following command:
575
+
576
+ .. code-block:: bash
577
+
578
+ $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
579
+
580
+ The flags given here assume that you're using Python 3. For Python 2, just
581
+ change the executable appropriately (to ``python`` or ``python2``).
582
+
583
+ The ``python3 -m pybind11 --includes`` command fetches the include paths for
584
+ both pybind11 and Python headers. This assumes that pybind11 has been installed
585
+ using ``pip`` or ``conda``. If it hasn't, you can also manually specify
586
+ ``-I <path-to-pybind11>/include`` together with the Python includes path
587
+ ``python3-config --includes``.
588
+
589
+ Note that Python 2.7 modules don't use a special suffix, so you should simply
590
+ use ``example.so`` instead of ``example$(python3-config --extension-suffix)``.
591
+ Besides, the ``--extension-suffix`` option may or may not be available, depending
592
+ on the distribution; in the latter case, the module extension can be manually
593
+ set to ``.so``.
594
+
595
+ On macOS: the build command is almost the same but it also requires passing
596
+ the ``-undefined dynamic_lookup`` flag so as to ignore missing symbols when
597
+ building the module:
598
+
599
+ .. code-block:: bash
600
+
601
+ $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
602
+
603
+ In general, it is advisable to include several additional build parameters
604
+ that can considerably reduce the size of the created binary. Refer to section
605
+ :ref:`cmake` for a detailed example of a suitable cross-platform CMake-based
606
+ build system that works on all platforms including Windows.
607
+
608
+ .. note::
609
+
610
+ On Linux and macOS, it's better to (intentionally) not link against
611
+ ``libpython``. The symbols will be resolved when the extension library
612
+ is loaded into a Python binary. This is preferable because you might
613
+ have several different installations of a given Python version (e.g. the
614
+ system-provided Python, and one that ships with a piece of commercial
615
+ software). In this way, the plugin will work with both versions, instead
616
+ of possibly importing a second Python library into a process that already
617
+ contains one (which will lead to a segfault).
618
+
619
+
620
+ Building with Bazel
621
+ ===================
622
+
623
+ You can build with the Bazel build system using the `pybind11_bazel
624
+ <https://github.com/pybind/pybind11_bazel>`_ repository.
625
+
626
+ Generating binding code automatically
627
+ =====================================
628
+
629
+ The ``Binder`` project is a tool for automatic generation of pybind11 binding
630
+ code by introspecting existing C++ codebases using LLVM/Clang. See the
631
+ [binder]_ documentation for details.
632
+
633
+ .. [binder] http://cppbinder.readthedocs.io/en/latest/about.html
634
+
635
+ [AutoWIG]_ is a Python library that wraps automatically compiled libraries into
636
+ high-level languages. It parses C++ code using LLVM/Clang technologies and
637
+ generates the wrappers using the Mako templating engine. The approach is automatic,
638
+ extensible, and applies to very complex C++ libraries, composed of thousands of
639
+ classes or incorporating modern meta-programming constructs.
640
+
641
+ .. [AutoWIG] https://github.com/StatisKit/AutoWIG
642
+
643
+ [robotpy-build]_ is a is a pure python, cross platform build tool that aims to
644
+ simplify creation of python wheels for pybind11 projects, and provide
645
+ cross-project dependency management. Additionally, it is able to autogenerate
646
+ customizable pybind11-based wrappers by parsing C++ header files.
647
+
648
+ .. [robotpy-build] https://robotpy-build.readthedocs.io