xcoll 0.3.6__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.
- xcoll/__init__.py +13 -4
- xcoll/beam_elements/__init__.py +14 -6
- xcoll/beam_elements/absorber.py +41 -7
- xcoll/beam_elements/base.py +1202 -247
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/elements_src/black_absorber.h +136 -0
- xcoll/beam_elements/elements_src/black_crystal.h +129 -0
- xcoll/beam_elements/elements_src/blowup.h +42 -0
- xcoll/beam_elements/elements_src/emittance_monitor.h +109 -0
- xcoll/beam_elements/{collimators_src → elements_src}/everest_block.h +59 -30
- xcoll/beam_elements/elements_src/everest_collimator.h +237 -0
- xcoll/beam_elements/elements_src/everest_crystal.h +280 -0
- xcoll/beam_elements/everest.py +65 -119
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +276 -747
- xcoll/general.py +5 -5
- xcoll/headers/checks.h +1 -1
- xcoll/headers/particle_states.h +2 -2
- xcoll/initial_distribution.py +207 -0
- xcoll/install.py +179 -0
- xcoll/interaction_record/__init__.py +1 -0
- xcoll/interaction_record/interaction_record.py +298 -0
- xcoll/interaction_record/interaction_record_src/interaction_record.h +98 -0
- xcoll/{impacts → interaction_record}/interaction_types.py +11 -4
- xcoll/line_tools.py +82 -0
- xcoll/lossmap.py +219 -0
- xcoll/manager.py +2 -937
- xcoll/rf_sweep.py +1 -1
- xcoll/scattering_routines/everest/amorphous.h +232 -0
- xcoll/scattering_routines/everest/channeling.h +240 -0
- xcoll/scattering_routines/everest/crystal_parameters.h +137 -0
- xcoll/scattering_routines/everest/everest.h +11 -30
- xcoll/scattering_routines/everest/everest.py +13 -10
- xcoll/scattering_routines/everest/jaw.h +28 -197
- xcoll/scattering_routines/everest/materials.py +37 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +31 -10
- xcoll/scattering_routines/everest/nuclear_interaction.h +86 -0
- xcoll/scattering_routines/everest/properties.h +6 -1
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/geant4/collimasim/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/.gitignore +12 -0
- xcoll/scattering_routines/geant4/collimasim/.gitmodules +3 -0
- xcoll/scattering_routines/geant4/collimasim/CMakeLists.txt +26 -0
- xcoll/scattering_routines/geant4/collimasim/README.md +21 -0
- xcoll/scattering_routines/geant4/collimasim/docs/Makefile +20 -0
- xcoll/scattering_routines/geant4/collimasim/docs/make.bat +35 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/collimasim.rst +10 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/conf.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/docs/source/index.rst +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.appveyor.yml +37 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-format +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.clang-tidy +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.cmake-format.yaml +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.git +1 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CODEOWNERS +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/CONTRIBUTING.md +386 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/ISSUE_TEMPLATE/config.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/dependabot.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler.yml +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/labeler_merged.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/pull_request_template.md +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/ci.yml +969 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/configure.yml +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/format.yml +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/labeler.yml +16 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.github/workflows/pip.yml +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.gitignore +45 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.pre-commit-config.yaml +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/.readthedocs.yml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/CMakeLists.txt +297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/LICENSE +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/MANIFEST.in +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/README.rst +180 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Doxyfile +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/Makefile +192 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/_static/theme_overrides.css +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/chrono.rst +81 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/custom.rst +93 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/eigen.rst +310 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/functional.rst +109 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/index.rst +43 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/overview.rst +171 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/stl.rst +251 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/cast/strings.rst +305 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/classes.rst +1297 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/embedding.rst +262 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/exceptions.rst +396 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/functions.rst +568 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/misc.rst +337 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/index.rst +13 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/numpy.rst +463 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/object.rst +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/pycpp/utilities.rst +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/advanced/smart_ptrs.rst +174 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/basics.rst +308 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.py +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/benchmark.rst +95 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/changelog.rst +2050 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/classes.rst +542 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/cmake/index.rst +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/compiling.rst +648 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/conf.py +381 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/faq.rst +343 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/index.rst +48 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/installing.rst +105 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/limitations.rst +72 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11-logo.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python1.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.png +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/pybind11_vs_boost_python2.svg +427 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/reference.rst +130 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/release.rst +96 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/requirements.txt +8 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/docs/upgrade.rst +548 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/attr.h +605 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/buffer_info.h +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/cast.h +1432 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/chrono.h +213 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/common.h +2 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/complex.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/class.h +709 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/common.h +1021 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/descr.h +104 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/init.h +346 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/internals.h +467 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/type_caster_base.h +978 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/detail/typeid.h +55 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eigen.h +606 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/embed.h +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/eval.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/functional.h +121 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/gil.h +193 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/iostream.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/numpy.h +1741 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/operators.h +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/options.h +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pybind11.h +2497 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/pytypes.h +1879 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl/filesystem.h +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl.h +375 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/include/pybind11/stl_bind.h +747 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/noxfile.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__init__.py +11 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/__main__.py +52 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.py +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/_version.pyi +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/commands.py +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/py.typed +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.py +482 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pybind11/setup_helpers.pyi +63 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/pyproject.toml +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.cfg +56 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/setup.py +155 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/CMakeLists.txt +503 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/conftest.py +208 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/constructor_stats.h +275 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/cross_module_gil_utils.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/env.py +33 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_python_package/test_files.py +279 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/pytest.ini +0 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/extra_setuptools/test_setuphelper.py +143 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/local_bindings.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/object.h +179 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_cross_module_tests.cpp +151 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.cpp +91 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pybind11_tests.h +85 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/pytest.ini +19 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/requirements.txt +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.cpp +26 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_async.py +25 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.cpp +216 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_buffers.py +163 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.cpp +286 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_builtin_casters.py +536 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_call_policies.py +248 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.cpp +227 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_callbacks.py +202 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.cpp +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_chrono.py +210 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.cpp +550 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_class.py +473 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/CMakeLists.txt +84 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/embed.cpp +21 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt +28 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt +46 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/main.cpp +6 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt +35 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_cmake_build/test.py +10 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.cpp +165 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_constants_and_functions.py +53 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.cpp +238 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_copy_move.py +126 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.cpp +141 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_casters.py +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.cpp +41 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_custom_type_setup.py +50 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.cpp +69 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_docstring_options.py +42 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.cpp +348 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eigen.py +771 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/CMakeLists.txt +47 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/catch.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/external_module.cpp +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.cpp +326 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_embed/test_interpreter.py +15 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.cpp +148 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_enum.py +272 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.cpp +119 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval.py +51 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_eval_call.py +5 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.cpp +285 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.h +12 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_exceptions.py +265 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.cpp +397 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_factory_constructors.py +520 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.cpp +49 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_gil_scoped.py +94 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.cpp +125 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_iostream.py +331 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.cpp +153 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_kwargs_and_defaults.py +284 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.cpp +107 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_local_bindings.py +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.cpp +412 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_methods_and_attributes.py +517 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.cpp +102 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_modules.py +92 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.cpp +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_multiple_inheritance.py +360 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.cpp +472 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_array.py +593 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.cpp +524 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_dtypes.py +441 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.cpp +103 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_numpy_vectorize.py +267 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.cpp +73 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_opaque_types.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.cpp +235 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_operator_overloading.py +146 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.cpp +189 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pickling.py +82 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.cpp +560 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_pytypes.py +651 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.cpp +500 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_sequences_and_iterators.py +253 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.cpp +452 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_smart_ptr.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.cpp +342 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl.py +291 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.cpp +131 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_stl_binders.py +318 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.cpp +144 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_tagbased_polymorphic.py +29 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.cpp +66 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_thread.py +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.cpp +22 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_union.py +9 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.cpp +510 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/test_virtual_functions.py +408 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-numpy-scipy.supp +140 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tests/valgrind-python.supp +117 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindCatch.cmake +70 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindEigen3.cmake +86 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/FindPythonLibsNew.cmake +257 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/check-style.sh +44 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/cmake_uninstall.cmake.in +23 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/libsize.py +39 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/make_changelog.py +64 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Common.cmake +402 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Config.cmake.in +233 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11NewTools.cmake +276 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pybind11Tools.cmake +214 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/pyproject.toml +3 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_global.py.in +65 -0
- xcoll/scattering_routines/geant4/collimasim/lib/pybind11/tools/setup_main.py.in +41 -0
- xcoll/scattering_routines/geant4/collimasim/pyproject.toml +8 -0
- xcoll/scattering_routines/geant4/collimasim/setup.py +144 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.cpp +403 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSPyATInterface.hh +100 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.cpp +763 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/BDSXtrackInterface.hh +118 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/__init__.py +8 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/bindings.cpp +63 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/pyCollimatorPass.py +142 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim/xtrack_collimator.py +556 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/PKG-INFO +6 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/SOURCES.txt +24 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/dependency_links.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/not-zip-safe +1 -0
- xcoll/scattering_routines/geant4/collimasim/src/collimasim.egg-info/top_level.txt +1 -0
- xcoll/scattering_routines/geant4/collimasim/tests/README.md +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_forions.dat +25 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_new_example.dat +18 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_old_example.dat +68 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_testing.dat +15 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/CollDB_yaml_example.yaml +110 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps.dat +7 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collgaps_pyat_test.dat +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/collonly_twiss_file_example.tfs +54 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_black_absorber.gmad +3 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/settings_ions.gmad +5 -0
- xcoll/scattering_routines/geant4/collimasim/tests/resources/twiss_file_testing.tfs +51 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat.py +65 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_passmethod.py +59 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_pyat_tracking.py +102 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack.py +75 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_angle.py +74 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_colldb_load.py +84 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction.py +159 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_interaction_ion.py +99 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_ions.py +78 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_lost_energy.py +88 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tilt.py +80 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking.py +97 -0
- xcoll/scattering_routines/geant4/collimasim/tests/test_xtrack_tracking_ions.py +96 -0
- xcoll/scattering_routines/geometry/__init__.py +6 -0
- xcoll/scattering_routines/geometry/collimator_geometry.h +218 -0
- xcoll/scattering_routines/geometry/crystal_geometry.h +153 -0
- xcoll/scattering_routines/geometry/geometry.py +26 -0
- xcoll/scattering_routines/geometry/get_s.h +92 -0
- xcoll/scattering_routines/geometry/methods.h +111 -0
- xcoll/scattering_routines/geometry/objects.h +154 -0
- xcoll/scattering_routines/geometry/rotation.h +23 -0
- xcoll/scattering_routines/geometry/segments.h +226 -0
- xcoll/scattering_routines/geometry/sort.h +184 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/METADATA +1 -1
- xcoll-0.5.0.dist-info/RECORD +413 -0
- xcoll/beam_elements/collimators_src/absorber.h +0 -141
- xcoll/beam_elements/collimators_src/everest_collimator.h +0 -142
- xcoll/beam_elements/collimators_src/everest_crystal.h +0 -115
- xcoll/collimator_settings.py +0 -457
- xcoll/impacts/__init__.py +0 -1
- xcoll/impacts/impacts.py +0 -102
- xcoll/impacts/impacts_src/impacts.h +0 -99
- xcoll/scattering_routines/everest/crystal.h +0 -1302
- xcoll/scattering_routines/everest/scatter.h +0 -169
- xcoll/scattering_routines/everest/scatter_crystal.h +0 -260
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.3.6.dist-info/RECORD +0 -111
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/LICENSE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/NOTICE +0 -0
- {xcoll-0.3.6.dist-info → xcoll-0.5.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
Frequently asked questions
|
|
2
|
+
##########################
|
|
3
|
+
|
|
4
|
+
"ImportError: dynamic module does not define init function"
|
|
5
|
+
===========================================================
|
|
6
|
+
|
|
7
|
+
1. Make sure that the name specified in PYBIND11_MODULE is identical to the
|
|
8
|
+
filename of the extension library (without suffixes such as ``.so``).
|
|
9
|
+
|
|
10
|
+
2. If the above did not fix the issue, you are likely using an incompatible
|
|
11
|
+
version of Python (for instance, the extension library was compiled against
|
|
12
|
+
Python 2, while the interpreter is running on top of some version of Python
|
|
13
|
+
3, or vice versa).
|
|
14
|
+
|
|
15
|
+
"Symbol not found: ``__Py_ZeroStruct`` / ``_PyInstanceMethod_Type``"
|
|
16
|
+
========================================================================
|
|
17
|
+
|
|
18
|
+
See the first answer.
|
|
19
|
+
|
|
20
|
+
"SystemError: dynamic module not initialized properly"
|
|
21
|
+
======================================================
|
|
22
|
+
|
|
23
|
+
See the first answer.
|
|
24
|
+
|
|
25
|
+
The Python interpreter immediately crashes when importing my module
|
|
26
|
+
===================================================================
|
|
27
|
+
|
|
28
|
+
See the first answer.
|
|
29
|
+
|
|
30
|
+
.. _faq_reference_arguments:
|
|
31
|
+
|
|
32
|
+
Limitations involving reference arguments
|
|
33
|
+
=========================================
|
|
34
|
+
|
|
35
|
+
In C++, it's fairly common to pass arguments using mutable references or
|
|
36
|
+
mutable pointers, which allows both read and write access to the value
|
|
37
|
+
supplied by the caller. This is sometimes done for efficiency reasons, or to
|
|
38
|
+
realize functions that have multiple return values. Here are two very basic
|
|
39
|
+
examples:
|
|
40
|
+
|
|
41
|
+
.. code-block:: cpp
|
|
42
|
+
|
|
43
|
+
void increment(int &i) { i++; }
|
|
44
|
+
void increment_ptr(int *i) { (*i)++; }
|
|
45
|
+
|
|
46
|
+
In Python, all arguments are passed by reference, so there is no general
|
|
47
|
+
issue in binding such code from Python.
|
|
48
|
+
|
|
49
|
+
However, certain basic Python types (like ``str``, ``int``, ``bool``,
|
|
50
|
+
``float``, etc.) are **immutable**. This means that the following attempt
|
|
51
|
+
to port the function to Python doesn't have the same effect on the value
|
|
52
|
+
provided by the caller -- in fact, it does nothing at all.
|
|
53
|
+
|
|
54
|
+
.. code-block:: python
|
|
55
|
+
|
|
56
|
+
def increment(i):
|
|
57
|
+
i += 1 # nope..
|
|
58
|
+
|
|
59
|
+
pybind11 is also affected by such language-level conventions, which means that
|
|
60
|
+
binding ``increment`` or ``increment_ptr`` will also create Python functions
|
|
61
|
+
that don't modify their arguments.
|
|
62
|
+
|
|
63
|
+
Although inconvenient, one workaround is to encapsulate the immutable types in
|
|
64
|
+
a custom type that does allow modifications.
|
|
65
|
+
|
|
66
|
+
An other alternative involves binding a small wrapper lambda function that
|
|
67
|
+
returns a tuple with all output arguments (see the remainder of the
|
|
68
|
+
documentation for examples on binding lambda functions). An example:
|
|
69
|
+
|
|
70
|
+
.. code-block:: cpp
|
|
71
|
+
|
|
72
|
+
int foo(int &i) { i++; return 123; }
|
|
73
|
+
|
|
74
|
+
and the binding code
|
|
75
|
+
|
|
76
|
+
.. code-block:: cpp
|
|
77
|
+
|
|
78
|
+
m.def("foo", [](int i) { int rv = foo(i); return std::make_tuple(rv, i); });
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
How can I reduce the build time?
|
|
82
|
+
================================
|
|
83
|
+
|
|
84
|
+
It's good practice to split binding code over multiple files, as in the
|
|
85
|
+
following example:
|
|
86
|
+
|
|
87
|
+
:file:`example.cpp`:
|
|
88
|
+
|
|
89
|
+
.. code-block:: cpp
|
|
90
|
+
|
|
91
|
+
void init_ex1(py::module_ &);
|
|
92
|
+
void init_ex2(py::module_ &);
|
|
93
|
+
/* ... */
|
|
94
|
+
|
|
95
|
+
PYBIND11_MODULE(example, m) {
|
|
96
|
+
init_ex1(m);
|
|
97
|
+
init_ex2(m);
|
|
98
|
+
/* ... */
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:file:`ex1.cpp`:
|
|
102
|
+
|
|
103
|
+
.. code-block:: cpp
|
|
104
|
+
|
|
105
|
+
void init_ex1(py::module_ &m) {
|
|
106
|
+
m.def("add", [](int a, int b) { return a + b; });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:file:`ex2.cpp`:
|
|
110
|
+
|
|
111
|
+
.. code-block:: cpp
|
|
112
|
+
|
|
113
|
+
void init_ex2(py::module_ &m) {
|
|
114
|
+
m.def("sub", [](int a, int b) { return a - b; });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:command:`python`:
|
|
118
|
+
|
|
119
|
+
.. code-block:: pycon
|
|
120
|
+
|
|
121
|
+
>>> import example
|
|
122
|
+
>>> example.add(1, 2)
|
|
123
|
+
3
|
|
124
|
+
>>> example.sub(1, 1)
|
|
125
|
+
0
|
|
126
|
+
|
|
127
|
+
As shown above, the various ``init_ex`` functions should be contained in
|
|
128
|
+
separate files that can be compiled independently from one another, and then
|
|
129
|
+
linked together into the same final shared object. Following this approach
|
|
130
|
+
will:
|
|
131
|
+
|
|
132
|
+
1. reduce memory requirements per compilation unit.
|
|
133
|
+
|
|
134
|
+
2. enable parallel builds (if desired).
|
|
135
|
+
|
|
136
|
+
3. allow for faster incremental builds. For instance, when a single class
|
|
137
|
+
definition is changed, only a subset of the binding code will generally need
|
|
138
|
+
to be recompiled.
|
|
139
|
+
|
|
140
|
+
"recursive template instantiation exceeded maximum depth of 256"
|
|
141
|
+
================================================================
|
|
142
|
+
|
|
143
|
+
If you receive an error about excessive recursive template evaluation, try
|
|
144
|
+
specifying a larger value, e.g. ``-ftemplate-depth=1024`` on GCC/Clang. The
|
|
145
|
+
culprit is generally the generation of function signatures at compile time
|
|
146
|
+
using C++14 template metaprogramming.
|
|
147
|
+
|
|
148
|
+
.. _`faq:hidden_visibility`:
|
|
149
|
+
|
|
150
|
+
"‘SomeClass’ declared with greater visibility than the type of its field ‘SomeClass::member’ [-Wattributes]"
|
|
151
|
+
============================================================================================================
|
|
152
|
+
|
|
153
|
+
This error typically indicates that you are compiling without the required
|
|
154
|
+
``-fvisibility`` flag. pybind11 code internally forces hidden visibility on
|
|
155
|
+
all internal code, but if non-hidden (and thus *exported*) code attempts to
|
|
156
|
+
include a pybind type (for example, ``py::object`` or ``py::list``) you can run
|
|
157
|
+
into this warning.
|
|
158
|
+
|
|
159
|
+
To avoid it, make sure you are specifying ``-fvisibility=hidden`` when
|
|
160
|
+
compiling pybind code.
|
|
161
|
+
|
|
162
|
+
As to why ``-fvisibility=hidden`` is necessary, because pybind modules could
|
|
163
|
+
have been compiled under different versions of pybind itself, it is also
|
|
164
|
+
important that the symbols defined in one module do not clash with the
|
|
165
|
+
potentially-incompatible symbols defined in another. While Python extension
|
|
166
|
+
modules are usually loaded with localized symbols (under POSIX systems
|
|
167
|
+
typically using ``dlopen`` with the ``RTLD_LOCAL`` flag), this Python default
|
|
168
|
+
can be changed, but even if it isn't it is not always enough to guarantee
|
|
169
|
+
complete independence of the symbols involved when not using
|
|
170
|
+
``-fvisibility=hidden``.
|
|
171
|
+
|
|
172
|
+
Additionally, ``-fvisibility=hidden`` can deliver considerably binary size
|
|
173
|
+
savings. (See the following section for more details.)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
.. _`faq:symhidden`:
|
|
177
|
+
|
|
178
|
+
How can I create smaller binaries?
|
|
179
|
+
==================================
|
|
180
|
+
|
|
181
|
+
To do its job, pybind11 extensively relies on a programming technique known as
|
|
182
|
+
*template metaprogramming*, which is a way of performing computation at compile
|
|
183
|
+
time using type information. Template metaprogramming usually instantiates code
|
|
184
|
+
involving significant numbers of deeply nested types that are either completely
|
|
185
|
+
removed or reduced to just a few instructions during the compiler's optimization
|
|
186
|
+
phase. However, due to the nested nature of these types, the resulting symbol
|
|
187
|
+
names in the compiled extension library can be extremely long. For instance,
|
|
188
|
+
the included test suite contains the following symbol:
|
|
189
|
+
|
|
190
|
+
.. only:: html
|
|
191
|
+
|
|
192
|
+
.. code-block:: none
|
|
193
|
+
|
|
194
|
+
__ZN8pybind1112cpp_functionC1Iv8Example2JRNSt3__16vectorINS3_12basic_stringIwNS3_11char_traitsIwEENS3_9allocatorIwEEEENS8_ISA_EEEEEJNS_4nameENS_7siblingENS_9is_methodEA28_cEEEMT0_FT_DpT1_EDpRKT2_
|
|
195
|
+
|
|
196
|
+
.. only:: not html
|
|
197
|
+
|
|
198
|
+
.. code-block:: cpp
|
|
199
|
+
|
|
200
|
+
__ZN8pybind1112cpp_functionC1Iv8Example2JRNSt3__16vectorINS3_12basic_stringIwNS3_11char_traitsIwEENS3_9allocatorIwEEEENS8_ISA_EEEEEJNS_4nameENS_7siblingENS_9is_methodEA28_cEEEMT0_FT_DpT1_EDpRKT2_
|
|
201
|
+
|
|
202
|
+
which is the mangled form of the following function type:
|
|
203
|
+
|
|
204
|
+
.. code-block:: cpp
|
|
205
|
+
|
|
206
|
+
pybind11::cpp_function::cpp_function<void, Example2, std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > >&, pybind11::name, pybind11::sibling, pybind11::is_method, char [28]>(void (Example2::*)(std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > >&), pybind11::name const&, pybind11::sibling const&, pybind11::is_method const&, char const (&) [28])
|
|
207
|
+
|
|
208
|
+
The memory needed to store just the mangled name of this function (196 bytes)
|
|
209
|
+
is larger than the actual piece of code (111 bytes) it represents! On the other
|
|
210
|
+
hand, it's silly to even give this function a name -- after all, it's just a
|
|
211
|
+
tiny cog in a bigger piece of machinery that is not exposed to the outside
|
|
212
|
+
world. So we'll generally only want to export symbols for those functions which
|
|
213
|
+
are actually called from the outside.
|
|
214
|
+
|
|
215
|
+
This can be achieved by specifying the parameter ``-fvisibility=hidden`` to GCC
|
|
216
|
+
and Clang, which sets the default symbol visibility to *hidden*, which has a
|
|
217
|
+
tremendous impact on the final binary size of the resulting extension library.
|
|
218
|
+
(On Visual Studio, symbols are already hidden by default, so nothing needs to
|
|
219
|
+
be done there.)
|
|
220
|
+
|
|
221
|
+
In addition to decreasing binary size, ``-fvisibility=hidden`` also avoids
|
|
222
|
+
potential serious issues when loading multiple modules and is required for
|
|
223
|
+
proper pybind operation. See the previous FAQ entry for more details.
|
|
224
|
+
|
|
225
|
+
Working with ancient Visual Studio 2008 builds on Windows
|
|
226
|
+
=========================================================
|
|
227
|
+
|
|
228
|
+
The official Windows distributions of Python are compiled using truly
|
|
229
|
+
ancient versions of Visual Studio that lack good C++11 support. Some users
|
|
230
|
+
implicitly assume that it would be impossible to load a plugin built with
|
|
231
|
+
Visual Studio 2015 into a Python distribution that was compiled using Visual
|
|
232
|
+
Studio 2008. However, no such issue exists: it's perfectly legitimate to
|
|
233
|
+
interface DLLs that are built with different compilers and/or C libraries.
|
|
234
|
+
Common gotchas to watch out for involve not ``free()``-ing memory region
|
|
235
|
+
that that were ``malloc()``-ed in another shared library, using data
|
|
236
|
+
structures with incompatible ABIs, and so on. pybind11 is very careful not
|
|
237
|
+
to make these types of mistakes.
|
|
238
|
+
|
|
239
|
+
How can I properly handle Ctrl-C in long-running functions?
|
|
240
|
+
===========================================================
|
|
241
|
+
|
|
242
|
+
Ctrl-C is received by the Python interpreter, and holds it until the GIL
|
|
243
|
+
is released, so a long-running function won't be interrupted.
|
|
244
|
+
|
|
245
|
+
To interrupt from inside your function, you can use the ``PyErr_CheckSignals()``
|
|
246
|
+
function, that will tell if a signal has been raised on the Python side. This
|
|
247
|
+
function merely checks a flag, so its impact is negligible. When a signal has
|
|
248
|
+
been received, you must either explicitly interrupt execution by throwing
|
|
249
|
+
``py::error_already_set`` (which will propagate the existing
|
|
250
|
+
``KeyboardInterrupt``), or clear the error (which you usually will not want):
|
|
251
|
+
|
|
252
|
+
.. code-block:: cpp
|
|
253
|
+
|
|
254
|
+
PYBIND11_MODULE(example, m)
|
|
255
|
+
{
|
|
256
|
+
m.def("long running_func", []()
|
|
257
|
+
{
|
|
258
|
+
for (;;) {
|
|
259
|
+
if (PyErr_CheckSignals() != 0)
|
|
260
|
+
throw py::error_already_set();
|
|
261
|
+
// Long running iteration
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
CMake doesn't detect the right Python version
|
|
267
|
+
=============================================
|
|
268
|
+
|
|
269
|
+
The CMake-based build system will try to automatically detect the installed
|
|
270
|
+
version of Python and link against that. When this fails, or when there are
|
|
271
|
+
multiple versions of Python and it finds the wrong one, delete
|
|
272
|
+
``CMakeCache.txt`` and then add ``-DPYTHON_EXECUTABLE=$(which python)`` to your
|
|
273
|
+
CMake configure line. (Replace ``$(which python)`` with a path to python if
|
|
274
|
+
your prefer.)
|
|
275
|
+
|
|
276
|
+
You can alternatively try ``-DPYBIND11_FINDPYTHON=ON``, which will activate the
|
|
277
|
+
new CMake FindPython support instead of pybind11's custom search. Requires
|
|
278
|
+
CMake 3.12+, and 3.15+ or 3.18.2+ are even better. You can set this in your
|
|
279
|
+
``CMakeLists.txt`` before adding or finding pybind11, as well.
|
|
280
|
+
|
|
281
|
+
Inconsistent detection of Python version in CMake and pybind11
|
|
282
|
+
==============================================================
|
|
283
|
+
|
|
284
|
+
The functions ``find_package(PythonInterp)`` and ``find_package(PythonLibs)``
|
|
285
|
+
provided by CMake for Python version detection are modified by pybind11 due to
|
|
286
|
+
unreliability and limitations that make them unsuitable for pybind11's needs.
|
|
287
|
+
Instead pybind11 provides its own, more reliable Python detection CMake code.
|
|
288
|
+
Conflicts can arise, however, when using pybind11 in a project that *also* uses
|
|
289
|
+
the CMake Python detection in a system with several Python versions installed.
|
|
290
|
+
|
|
291
|
+
This difference may cause inconsistencies and errors if *both* mechanisms are
|
|
292
|
+
used in the same project. Consider the following CMake code executed in a
|
|
293
|
+
system with Python 2.7 and 3.x installed:
|
|
294
|
+
|
|
295
|
+
.. code-block:: cmake
|
|
296
|
+
|
|
297
|
+
find_package(PythonInterp)
|
|
298
|
+
find_package(PythonLibs)
|
|
299
|
+
find_package(pybind11)
|
|
300
|
+
|
|
301
|
+
It will detect Python 2.7 and pybind11 will pick it as well.
|
|
302
|
+
|
|
303
|
+
In contrast this code:
|
|
304
|
+
|
|
305
|
+
.. code-block:: cmake
|
|
306
|
+
|
|
307
|
+
find_package(pybind11)
|
|
308
|
+
find_package(PythonInterp)
|
|
309
|
+
find_package(PythonLibs)
|
|
310
|
+
|
|
311
|
+
will detect Python 3.x for pybind11 and may crash on
|
|
312
|
+
``find_package(PythonLibs)`` afterwards.
|
|
313
|
+
|
|
314
|
+
There are three possible solutions:
|
|
315
|
+
|
|
316
|
+
1. Avoid using ``find_package(PythonInterp)`` and ``find_package(PythonLibs)``
|
|
317
|
+
from CMake and rely on pybind11 in detecting Python version. If this is not
|
|
318
|
+
possible, the CMake machinery should be called *before* including pybind11.
|
|
319
|
+
2. Set ``PYBIND11_FINDPYTHON`` to ``True`` or use ``find_package(Python
|
|
320
|
+
COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better,
|
|
321
|
+
3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead
|
|
322
|
+
of the old, deprecated search tools, and these modules are much better at
|
|
323
|
+
finding the correct Python.
|
|
324
|
+
3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python.
|
|
325
|
+
However, you will have to use the target-based system, and do more setup
|
|
326
|
+
yourself, because it does not know about or include things that depend on
|
|
327
|
+
Python, like ``pybind11_add_module``. This might be ideal for integrating
|
|
328
|
+
into an existing system, like scikit-build's Python helpers.
|
|
329
|
+
|
|
330
|
+
How to cite this project?
|
|
331
|
+
=========================
|
|
332
|
+
|
|
333
|
+
We suggest the following BibTeX template to cite pybind11 in scientific
|
|
334
|
+
discourse:
|
|
335
|
+
|
|
336
|
+
.. code-block:: bash
|
|
337
|
+
|
|
338
|
+
@misc{pybind11,
|
|
339
|
+
author = {Wenzel Jakob and Jason Rhinelander and Dean Moldovan},
|
|
340
|
+
year = {2017},
|
|
341
|
+
note = {https://github.com/pybind/pybind11},
|
|
342
|
+
title = {pybind11 -- Seamless operability between C++11 and Python}
|
|
343
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.. only:: latex
|
|
2
|
+
|
|
3
|
+
Intro
|
|
4
|
+
=====
|
|
5
|
+
|
|
6
|
+
.. include:: readme.rst
|
|
7
|
+
|
|
8
|
+
.. only:: not latex
|
|
9
|
+
|
|
10
|
+
Contents:
|
|
11
|
+
|
|
12
|
+
.. toctree::
|
|
13
|
+
:maxdepth: 1
|
|
14
|
+
|
|
15
|
+
changelog
|
|
16
|
+
upgrade
|
|
17
|
+
|
|
18
|
+
.. toctree::
|
|
19
|
+
:caption: The Basics
|
|
20
|
+
:maxdepth: 2
|
|
21
|
+
|
|
22
|
+
installing
|
|
23
|
+
basics
|
|
24
|
+
classes
|
|
25
|
+
compiling
|
|
26
|
+
|
|
27
|
+
.. toctree::
|
|
28
|
+
:caption: Advanced Topics
|
|
29
|
+
:maxdepth: 2
|
|
30
|
+
|
|
31
|
+
advanced/functions
|
|
32
|
+
advanced/classes
|
|
33
|
+
advanced/exceptions
|
|
34
|
+
advanced/smart_ptrs
|
|
35
|
+
advanced/cast/index
|
|
36
|
+
advanced/pycpp/index
|
|
37
|
+
advanced/embedding
|
|
38
|
+
advanced/misc
|
|
39
|
+
|
|
40
|
+
.. toctree::
|
|
41
|
+
:caption: Extra Information
|
|
42
|
+
:maxdepth: 1
|
|
43
|
+
|
|
44
|
+
faq
|
|
45
|
+
benchmark
|
|
46
|
+
limitations
|
|
47
|
+
reference
|
|
48
|
+
cmake/index
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
.. _installing:
|
|
2
|
+
|
|
3
|
+
Installing the library
|
|
4
|
+
######################
|
|
5
|
+
|
|
6
|
+
There are several ways to get the pybind11 source, which lives at
|
|
7
|
+
`pybind/pybind11 on GitHub <https://github.com/pybind/pybind11>`_. The pybind11
|
|
8
|
+
developers recommend one of the first three ways listed here, submodule, PyPI,
|
|
9
|
+
or conda-forge, for obtaining pybind11.
|
|
10
|
+
|
|
11
|
+
.. _include_as_a_submodule:
|
|
12
|
+
|
|
13
|
+
Include as a submodule
|
|
14
|
+
======================
|
|
15
|
+
|
|
16
|
+
When you are working on a project in Git, you can use the pybind11 repository
|
|
17
|
+
as a submodule. From your git repository, use:
|
|
18
|
+
|
|
19
|
+
.. code-block:: bash
|
|
20
|
+
|
|
21
|
+
git submodule add -b stable ../../pybind/pybind11 extern/pybind11
|
|
22
|
+
git submodule update --init
|
|
23
|
+
|
|
24
|
+
This assumes you are placing your dependencies in ``extern/``, and that you are
|
|
25
|
+
using GitHub; if you are not using GitHub, use the full https or ssh URL
|
|
26
|
+
instead of the relative URL ``../../pybind/pybind11`` above. Some other servers
|
|
27
|
+
also require the ``.git`` extension (GitHub does not).
|
|
28
|
+
|
|
29
|
+
From here, you can now include ``extern/pybind11/include``, or you can use
|
|
30
|
+
the various integration tools (see :ref:`compiling`) pybind11 provides directly
|
|
31
|
+
from the local folder.
|
|
32
|
+
|
|
33
|
+
Include with PyPI
|
|
34
|
+
=================
|
|
35
|
+
|
|
36
|
+
You can download the sources and CMake files as a Python package from PyPI
|
|
37
|
+
using Pip. Just use:
|
|
38
|
+
|
|
39
|
+
.. code-block:: bash
|
|
40
|
+
|
|
41
|
+
pip install pybind11
|
|
42
|
+
|
|
43
|
+
This will provide pybind11 in a standard Python package format. If you want
|
|
44
|
+
pybind11 available directly in your environment root, you can use:
|
|
45
|
+
|
|
46
|
+
.. code-block:: bash
|
|
47
|
+
|
|
48
|
+
pip install "pybind11[global]"
|
|
49
|
+
|
|
50
|
+
This is not recommended if you are installing with your system Python, as it
|
|
51
|
+
will add files to ``/usr/local/include/pybind11`` and
|
|
52
|
+
``/usr/local/share/cmake/pybind11``, so unless that is what you want, it is
|
|
53
|
+
recommended only for use in virtual environments or your ``pyproject.toml``
|
|
54
|
+
file (see :ref:`compiling`).
|
|
55
|
+
|
|
56
|
+
Include with conda-forge
|
|
57
|
+
========================
|
|
58
|
+
|
|
59
|
+
You can use pybind11 with conda packaging via `conda-forge
|
|
60
|
+
<https://github.com/conda-forge/pybind11-feedstock>`_:
|
|
61
|
+
|
|
62
|
+
.. code-block:: bash
|
|
63
|
+
|
|
64
|
+
conda install -c conda-forge pybind11
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
Include with vcpkg
|
|
68
|
+
==================
|
|
69
|
+
You can download and install pybind11 using the Microsoft `vcpkg
|
|
70
|
+
<https://github.com/Microsoft/vcpkg/>`_ dependency manager:
|
|
71
|
+
|
|
72
|
+
.. code-block:: bash
|
|
73
|
+
|
|
74
|
+
git clone https://github.com/Microsoft/vcpkg.git
|
|
75
|
+
cd vcpkg
|
|
76
|
+
./bootstrap-vcpkg.sh
|
|
77
|
+
./vcpkg integrate install
|
|
78
|
+
vcpkg install pybind11
|
|
79
|
+
|
|
80
|
+
The pybind11 port in vcpkg is kept up to date by Microsoft team members and
|
|
81
|
+
community contributors. If the version is out of date, please `create an issue
|
|
82
|
+
or pull request <https://github.com/Microsoft/vcpkg/>`_ on the vcpkg
|
|
83
|
+
repository.
|
|
84
|
+
|
|
85
|
+
Global install with brew
|
|
86
|
+
========================
|
|
87
|
+
|
|
88
|
+
The brew package manager (Homebrew on macOS, or Linuxbrew on Linux) has a
|
|
89
|
+
`pybind11 package
|
|
90
|
+
<https://github.com/Homebrew/homebrew-core/blob/master/Formula/pybind11.rb>`_.
|
|
91
|
+
To install:
|
|
92
|
+
|
|
93
|
+
.. code-block:: bash
|
|
94
|
+
|
|
95
|
+
brew install pybind11
|
|
96
|
+
|
|
97
|
+
.. We should list Conan, and possibly a few other C++ package managers (hunter,
|
|
98
|
+
.. perhaps). Conan has a very clean CMake integration that would be good to show.
|
|
99
|
+
|
|
100
|
+
Other options
|
|
101
|
+
=============
|
|
102
|
+
|
|
103
|
+
Other locations you can find pybind11 are `listed here
|
|
104
|
+
<https://repology.org/project/python:pybind11/versions>`_; these are maintained
|
|
105
|
+
by various packagers and the community.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Limitations
|
|
2
|
+
###########
|
|
3
|
+
|
|
4
|
+
Design choices
|
|
5
|
+
^^^^^^^^^^^^^^
|
|
6
|
+
|
|
7
|
+
pybind11 strives to be a general solution to binding generation, but it also has
|
|
8
|
+
certain limitations:
|
|
9
|
+
|
|
10
|
+
- pybind11 casts away ``const``-ness in function arguments and return values.
|
|
11
|
+
This is in line with the Python language, which has no concept of ``const``
|
|
12
|
+
values. This means that some additional care is needed to avoid bugs that
|
|
13
|
+
would be caught by the type checker in a traditional C++ program.
|
|
14
|
+
|
|
15
|
+
- The NumPy interface ``pybind11::array`` greatly simplifies accessing
|
|
16
|
+
numerical data from C++ (and vice versa), but it's not a full-blown array
|
|
17
|
+
class like ``Eigen::Array`` or ``boost.multi_array``. ``Eigen`` objects are
|
|
18
|
+
directly supported, however, with ``pybind11/eigen.h``.
|
|
19
|
+
|
|
20
|
+
Large but useful features could be implemented in pybind11 but would lead to a
|
|
21
|
+
significant increase in complexity. Pybind11 strives to be simple and compact.
|
|
22
|
+
Users who require large new features are encouraged to write an extension to
|
|
23
|
+
pybind11; see `pybind11_json <https://github.com/pybind/pybind11_json>`_ for an
|
|
24
|
+
example.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Known bugs
|
|
28
|
+
^^^^^^^^^^
|
|
29
|
+
|
|
30
|
+
These are issues that hopefully will one day be fixed, but currently are
|
|
31
|
+
unsolved. If you know how to help with one of these issues, contributions
|
|
32
|
+
are welcome!
|
|
33
|
+
|
|
34
|
+
- Intel 20.2 is currently having an issue with the test suite.
|
|
35
|
+
`#2573 <https://github.com/pybind/pybind11/pull/2573>`_
|
|
36
|
+
|
|
37
|
+
- Debug mode Python does not support 1-5 tests in the test suite currently.
|
|
38
|
+
`#2422 <https://github.com/pybind/pybind11/pull/2422>`_
|
|
39
|
+
|
|
40
|
+
- PyPy3 7.3.1 and 7.3.2 have issues with several tests on 32-bit Windows.
|
|
41
|
+
|
|
42
|
+
Known limitations
|
|
43
|
+
^^^^^^^^^^^^^^^^^
|
|
44
|
+
|
|
45
|
+
These are issues that are probably solvable, but have not been fixed yet. A
|
|
46
|
+
clean, well written patch would likely be accepted to solve them.
|
|
47
|
+
|
|
48
|
+
- Type casters are not kept alive recursively.
|
|
49
|
+
`#2527 <https://github.com/pybind/pybind11/issues/2527>`_
|
|
50
|
+
One consequence is that containers of ``char *`` are currently not supported.
|
|
51
|
+
`#2245 <https://github.com/pybind/pybind11/issues/2245>`_
|
|
52
|
+
|
|
53
|
+
- The ``cpptest`` does not run on Windows with Python 3.8 or newer, due to DLL
|
|
54
|
+
loader changes. User code that is correctly installed should not be affected.
|
|
55
|
+
`#2560 <https://github.com/pybind/pybind11/issue/2560>`_
|
|
56
|
+
|
|
57
|
+
Python 3.9.0 warning
|
|
58
|
+
^^^^^^^^^^^^^^^^^^^^
|
|
59
|
+
|
|
60
|
+
Combining older versions of pybind11 (< 2.6.0) with Python on exactly 3.9.0
|
|
61
|
+
will trigger undefined behavior that typically manifests as crashes during
|
|
62
|
+
interpreter shutdown (but could also destroy your data. **You have been
|
|
63
|
+
warned**).
|
|
64
|
+
|
|
65
|
+
This issue was `fixed in Python <https://github.com/python/cpython/pull/22670>`_.
|
|
66
|
+
As a mitigation for this bug, pybind11 2.6.0 or newer includes a workaround
|
|
67
|
+
specifically when Python 3.9.0 is detected at runtime, leaking about 50 bytes
|
|
68
|
+
of memory when a callback function is garbage collected. For reference, the
|
|
69
|
+
pybind11 test suite has about 2,000 such callbacks, but only 49 are garbage
|
|
70
|
+
collected before the end-of-process. Wheels (even if built with Python 3.9.0)
|
|
71
|
+
will correctly avoid the leak when run in Python 3.9.1, and this does not
|
|
72
|
+
affect other 3.X versions.
|