xcoll 0.4.0__py3-none-any.whl → 0.5.1__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 +2 -1
- xcoll/beam_elements/__init__.py +9 -2
- xcoll/beam_elements/absorber.py +2 -2
- xcoll/beam_elements/base.py +105 -67
- xcoll/beam_elements/blowup.py +198 -0
- xcoll/beam_elements/{collimators_src → elements_src}/black_absorber.h +21 -3
- xcoll/beam_elements/{collimators_src → elements_src}/black_crystal.h +20 -2
- 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 +19 -2
- xcoll/beam_elements/{collimators_src → elements_src}/everest_collimator.h +19 -3
- xcoll/beam_elements/{collimators_src → elements_src}/everest_crystal.h +30 -9
- xcoll/beam_elements/everest.py +5 -6
- xcoll/beam_elements/monitor.py +428 -0
- xcoll/colldb.py +103 -74
- xcoll/general.py +4 -4
- xcoll/initial_distribution.py +18 -6
- xcoll/install.py +3 -1
- xcoll/interaction_record/interaction_record.py +127 -81
- xcoll/interaction_record/interaction_record_src/interaction_record.h +43 -43
- xcoll/line_tools.py +8 -9
- xcoll/lossmap.py +48 -38
- xcoll/scattering_routines/everest/amorphous.h +4 -11
- xcoll/scattering_routines/everest/channeling.h +3 -8
- xcoll/scattering_routines/everest/everest.h +4 -1
- xcoll/scattering_routines/everest/jaw.h +4 -3
- xcoll/scattering_routines/everest/materials.py +35 -15
- xcoll/scattering_routines/everest/multiple_coulomb_scattering.h +2 -2
- xcoll/scattering_routines/everest/nuclear_interaction.h +1 -1
- 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/collimator_geometry.h +9 -10
- xcoll/scattering_routines/geometry/crystal_geometry.h +9 -6
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/METADATA +1 -1
- xcoll-0.5.1.dist-info/RECORD +413 -0
- xcoll/scattering_routines/fluka/build_fluka_input.py +0 -58
- xcoll-0.4.0.dist-info/RECORD +0 -126
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/LICENSE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/NOTICE +0 -0
- {xcoll-0.4.0.dist-info → xcoll-0.5.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
Upgrade guide
|
|
2
|
+
#############
|
|
3
|
+
|
|
4
|
+
This is a companion guide to the :doc:`changelog`. While the changelog briefly
|
|
5
|
+
lists all of the new features, improvements and bug fixes, this upgrade guide
|
|
6
|
+
focuses only the subset which directly impacts your experience when upgrading
|
|
7
|
+
to a new version. But it goes into more detail. This includes things like
|
|
8
|
+
deprecated APIs and their replacements, build system changes, general code
|
|
9
|
+
modernization and other useful information.
|
|
10
|
+
|
|
11
|
+
.. _upgrade-guide-2.9:
|
|
12
|
+
|
|
13
|
+
v2.9
|
|
14
|
+
====
|
|
15
|
+
|
|
16
|
+
* Any usage of the recently added ``py::make_simple_namespace`` should be
|
|
17
|
+
converted to using ``py::module_::import("types").attr("SimpleNamespace")``
|
|
18
|
+
instead.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
.. _upgrade-guide-2.7:
|
|
22
|
+
|
|
23
|
+
v2.7
|
|
24
|
+
====
|
|
25
|
+
|
|
26
|
+
*Before* v2.7, ``py::str`` can hold ``PyUnicodeObject`` or ``PyBytesObject``,
|
|
27
|
+
and ``py::isinstance<str>()`` is ``true`` for both ``py::str`` and
|
|
28
|
+
``py::bytes``. Starting with v2.7, ``py::str`` exclusively holds
|
|
29
|
+
``PyUnicodeObject`` (`#2409 <https://github.com/pybind/pybind11/pull/2409>`_),
|
|
30
|
+
and ``py::isinstance<str>()`` is ``true`` only for ``py::str``. To help in
|
|
31
|
+
the transition of user code, the ``PYBIND11_STR_LEGACY_PERMISSIVE`` macro
|
|
32
|
+
is provided as an escape hatch to go back to the legacy behavior. This macro
|
|
33
|
+
will be removed in future releases. Two types of required fixes are expected
|
|
34
|
+
to be common:
|
|
35
|
+
|
|
36
|
+
* Accidental use of ``py::str`` instead of ``py::bytes``, masked by the legacy
|
|
37
|
+
behavior. These are probably very easy to fix, by changing from
|
|
38
|
+
``py::str`` to ``py::bytes``.
|
|
39
|
+
|
|
40
|
+
* Reliance on py::isinstance<str>(obj) being ``true`` for
|
|
41
|
+
``py::bytes``. This is likely to be easy to fix in most cases by adding
|
|
42
|
+
``|| py::isinstance<bytes>(obj)``, but a fix may be more involved, e.g. if
|
|
43
|
+
``py::isinstance<T>`` appears in a template. Such situations will require
|
|
44
|
+
careful review and custom fixes.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
.. _upgrade-guide-2.6:
|
|
48
|
+
|
|
49
|
+
v2.6
|
|
50
|
+
====
|
|
51
|
+
|
|
52
|
+
Usage of the ``PYBIND11_OVERLOAD*`` macros and ``get_overload`` function should
|
|
53
|
+
be replaced by ``PYBIND11_OVERRIDE*`` and ``get_override``. In the future, the
|
|
54
|
+
old macros may be deprecated and removed.
|
|
55
|
+
|
|
56
|
+
``py::module`` has been renamed ``py::module_``, but a backward compatible
|
|
57
|
+
typedef has been included. This change was to avoid a language change in C++20
|
|
58
|
+
that requires unqualified ``module`` not be placed at the start of a logical
|
|
59
|
+
line. Qualified usage is unaffected and the typedef will remain unless the
|
|
60
|
+
C++ language rules change again.
|
|
61
|
+
|
|
62
|
+
The public constructors of ``py::module_`` have been deprecated. Use
|
|
63
|
+
``PYBIND11_MODULE`` or ``module_::create_extension_module`` instead.
|
|
64
|
+
|
|
65
|
+
An error is now thrown when ``__init__`` is forgotten on subclasses. This was
|
|
66
|
+
incorrect before, but was not checked. Add a call to ``__init__`` if it is
|
|
67
|
+
missing.
|
|
68
|
+
|
|
69
|
+
A ``py::type_error`` is now thrown when casting to a subclass (like
|
|
70
|
+
``py::bytes`` from ``py::object``) if the conversion is not valid. Make a valid
|
|
71
|
+
conversion instead.
|
|
72
|
+
|
|
73
|
+
The undocumented ``h.get_type()`` method has been deprecated and replaced by
|
|
74
|
+
``py::type::of(h)``.
|
|
75
|
+
|
|
76
|
+
Enums now have a ``__str__`` method pre-defined; if you want to override it,
|
|
77
|
+
the simplest fix is to add the new ``py::prepend()`` tag when defining
|
|
78
|
+
``"__str__"``.
|
|
79
|
+
|
|
80
|
+
If ``__eq__`` defined but not ``__hash__``, ``__hash__`` is now set to
|
|
81
|
+
``None``, as in normal CPython. You should add ``__hash__`` if you intended the
|
|
82
|
+
class to be hashable, possibly using the new ``py::hash`` shortcut.
|
|
83
|
+
|
|
84
|
+
The constructors for ``py::array`` now always take signed integers for size,
|
|
85
|
+
for consistency. This may lead to compiler warnings on some systems. Cast to
|
|
86
|
+
``py::ssize_t`` instead of ``std::size_t``.
|
|
87
|
+
|
|
88
|
+
The ``tools/clang`` submodule and ``tools/mkdoc.py`` have been moved to a
|
|
89
|
+
standalone package, `pybind11-mkdoc`_. If you were using those tools, please
|
|
90
|
+
use them via a pip install from the new location.
|
|
91
|
+
|
|
92
|
+
The ``pybind11`` package on PyPI no longer fills the wheel "headers" slot - if
|
|
93
|
+
you were using the headers from this slot, they are available by requesting the
|
|
94
|
+
``global`` extra, that is, ``pip install "pybind11[global]"``. (Most users will
|
|
95
|
+
be unaffected, as the ``pybind11/include`` location is reported by ``python -m
|
|
96
|
+
pybind11 --includes`` and ``pybind11.get_include()`` is still correct and has
|
|
97
|
+
not changed since 2.5).
|
|
98
|
+
|
|
99
|
+
.. _pybind11-mkdoc: https://github.com/pybind/pybind11-mkdoc
|
|
100
|
+
|
|
101
|
+
CMake support:
|
|
102
|
+
--------------
|
|
103
|
+
|
|
104
|
+
The minimum required version of CMake is now 3.4. Several details of the CMake
|
|
105
|
+
support have been deprecated; warnings will be shown if you need to change
|
|
106
|
+
something. The changes are:
|
|
107
|
+
|
|
108
|
+
* ``PYBIND11_CPP_STANDARD=<platform-flag>`` is deprecated, please use
|
|
109
|
+
``CMAKE_CXX_STANDARD=<number>`` instead, or any other valid CMake CXX or CUDA
|
|
110
|
+
standard selection method, like ``target_compile_features``.
|
|
111
|
+
|
|
112
|
+
* If you do not request a standard, pybind11 targets will compile with the
|
|
113
|
+
compiler default, but not less than C++11, instead of forcing C++14 always.
|
|
114
|
+
If you depend on the old behavior, please use ``set(CMAKE_CXX_STANDARD 14 CACHE STRING "")``
|
|
115
|
+
instead.
|
|
116
|
+
|
|
117
|
+
* Direct ``pybind11::module`` usage should always be accompanied by at least
|
|
118
|
+
``set(CMAKE_CXX_VISIBILITY_PRESET hidden)`` or similar - it used to try to
|
|
119
|
+
manually force this compiler flag (but not correctly on all compilers or with
|
|
120
|
+
CUDA).
|
|
121
|
+
|
|
122
|
+
* ``pybind11_add_module``'s ``SYSTEM`` argument is deprecated and does nothing;
|
|
123
|
+
linking now behaves like other imported libraries consistently in both
|
|
124
|
+
config and submodule mode, and behaves like a ``SYSTEM`` library by
|
|
125
|
+
default.
|
|
126
|
+
|
|
127
|
+
* If ``PYTHON_EXECUTABLE`` is not set, virtual environments (``venv``,
|
|
128
|
+
``virtualenv``, and ``conda``) are prioritized over the standard search
|
|
129
|
+
(similar to the new FindPython mode).
|
|
130
|
+
|
|
131
|
+
In addition, the following changes may be of interest:
|
|
132
|
+
|
|
133
|
+
* ``CMAKE_INTERPROCEDURAL_OPTIMIZATION`` will be respected by
|
|
134
|
+
``pybind11_add_module`` if set instead of linking to ``pybind11::lto`` or
|
|
135
|
+
``pybind11::thin_lto``.
|
|
136
|
+
|
|
137
|
+
* Using ``find_package(Python COMPONENTS Interpreter Development)`` before
|
|
138
|
+
pybind11 will cause pybind11 to use the new Python mechanisms instead of its
|
|
139
|
+
own custom search, based on a patched version of classic ``FindPythonInterp``
|
|
140
|
+
/ ``FindPythonLibs``. In the future, this may become the default. A recent
|
|
141
|
+
(3.15+ or 3.18.2+) version of CMake is recommended.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
v2.5
|
|
146
|
+
====
|
|
147
|
+
|
|
148
|
+
The Python package now includes the headers as data in the package itself, as
|
|
149
|
+
well as in the "headers" wheel slot. ``pybind11 --includes`` and
|
|
150
|
+
``pybind11.get_include()`` report the new location, which is always correct
|
|
151
|
+
regardless of how pybind11 was installed, making the old ``user=`` argument
|
|
152
|
+
meaningless. If you are not using the function to get the location already, you
|
|
153
|
+
are encouraged to switch to the package location.
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
v2.2
|
|
157
|
+
====
|
|
158
|
+
|
|
159
|
+
Deprecation of the ``PYBIND11_PLUGIN`` macro
|
|
160
|
+
--------------------------------------------
|
|
161
|
+
|
|
162
|
+
``PYBIND11_MODULE`` is now the preferred way to create module entry points.
|
|
163
|
+
The old macro emits a compile-time deprecation warning.
|
|
164
|
+
|
|
165
|
+
.. code-block:: cpp
|
|
166
|
+
|
|
167
|
+
// old
|
|
168
|
+
PYBIND11_PLUGIN(example) {
|
|
169
|
+
py::module m("example", "documentation string");
|
|
170
|
+
|
|
171
|
+
m.def("add", [](int a, int b) { return a + b; });
|
|
172
|
+
|
|
173
|
+
return m.ptr();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// new
|
|
177
|
+
PYBIND11_MODULE(example, m) {
|
|
178
|
+
m.doc() = "documentation string"; // optional
|
|
179
|
+
|
|
180
|
+
m.def("add", [](int a, int b) { return a + b; });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
New API for defining custom constructors and pickling functions
|
|
185
|
+
---------------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
The old placement-new custom constructors have been deprecated. The new approach
|
|
188
|
+
uses ``py::init()`` and factory functions to greatly improve type safety.
|
|
189
|
+
|
|
190
|
+
Placement-new can be called accidentally with an incompatible type (without any
|
|
191
|
+
compiler errors or warnings), or it can initialize the same object multiple times
|
|
192
|
+
if not careful with the Python-side ``__init__`` calls. The new-style custom
|
|
193
|
+
constructors prevent such mistakes. See :ref:`custom_constructors` for details.
|
|
194
|
+
|
|
195
|
+
.. code-block:: cpp
|
|
196
|
+
|
|
197
|
+
// old -- deprecated (runtime warning shown only in debug mode)
|
|
198
|
+
py::class<Foo>(m, "Foo")
|
|
199
|
+
.def("__init__", [](Foo &self, ...) {
|
|
200
|
+
new (&self) Foo(...); // uses placement-new
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// new
|
|
204
|
+
py::class<Foo>(m, "Foo")
|
|
205
|
+
.def(py::init([](...) { // Note: no `self` argument
|
|
206
|
+
return new Foo(...); // return by raw pointer
|
|
207
|
+
// or: return std::make_unique<Foo>(...); // return by holder
|
|
208
|
+
// or: return Foo(...); // return by value (move constructor)
|
|
209
|
+
}));
|
|
210
|
+
|
|
211
|
+
Mirroring the custom constructor changes, ``py::pickle()`` is now the preferred
|
|
212
|
+
way to get and set object state. See :ref:`pickling` for details.
|
|
213
|
+
|
|
214
|
+
.. code-block:: cpp
|
|
215
|
+
|
|
216
|
+
// old -- deprecated (runtime warning shown only in debug mode)
|
|
217
|
+
py::class<Foo>(m, "Foo")
|
|
218
|
+
...
|
|
219
|
+
.def("__getstate__", [](const Foo &self) {
|
|
220
|
+
return py::make_tuple(self.value1(), self.value2(), ...);
|
|
221
|
+
})
|
|
222
|
+
.def("__setstate__", [](Foo &self, py::tuple t) {
|
|
223
|
+
new (&self) Foo(t[0].cast<std::string>(), ...);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// new
|
|
227
|
+
py::class<Foo>(m, "Foo")
|
|
228
|
+
...
|
|
229
|
+
.def(py::pickle(
|
|
230
|
+
[](const Foo &self) { // __getstate__
|
|
231
|
+
return py::make_tuple(self.value1(), self.value2(), ...); // unchanged
|
|
232
|
+
},
|
|
233
|
+
[](py::tuple t) { // __setstate__, note: no `self` argument
|
|
234
|
+
return new Foo(t[0].cast<std::string>(), ...);
|
|
235
|
+
// or: return std::make_unique<Foo>(...); // return by holder
|
|
236
|
+
// or: return Foo(...); // return by value (move constructor)
|
|
237
|
+
}
|
|
238
|
+
));
|
|
239
|
+
|
|
240
|
+
For both the constructors and pickling, warnings are shown at module
|
|
241
|
+
initialization time (on import, not when the functions are called).
|
|
242
|
+
They're only visible when compiled in debug mode. Sample warning:
|
|
243
|
+
|
|
244
|
+
.. code-block:: none
|
|
245
|
+
|
|
246
|
+
pybind11-bound class 'mymodule.Foo' is using an old-style placement-new '__init__'
|
|
247
|
+
which has been deprecated. See the upgrade guide in pybind11's docs.
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
Stricter enforcement of hidden symbol visibility for pybind11 modules
|
|
251
|
+
---------------------------------------------------------------------
|
|
252
|
+
|
|
253
|
+
pybind11 now tries to actively enforce hidden symbol visibility for modules.
|
|
254
|
+
If you're using either one of pybind11's :doc:`CMake or Python build systems
|
|
255
|
+
<compiling>` (the two example repositories) and you haven't been exporting any
|
|
256
|
+
symbols, there's nothing to be concerned about. All the changes have been done
|
|
257
|
+
transparently in the background. If you were building manually or relied on
|
|
258
|
+
specific default visibility, read on.
|
|
259
|
+
|
|
260
|
+
Setting default symbol visibility to *hidden* has always been recommended for
|
|
261
|
+
pybind11 (see :ref:`faq:symhidden`). On Linux and macOS, hidden symbol
|
|
262
|
+
visibility (in conjunction with the ``strip`` utility) yields much smaller
|
|
263
|
+
module binaries. `CPython's extension docs`_ also recommend hiding symbols
|
|
264
|
+
by default, with the goal of avoiding symbol name clashes between modules.
|
|
265
|
+
Starting with v2.2, pybind11 enforces this more strictly: (1) by declaring
|
|
266
|
+
all symbols inside the ``pybind11`` namespace as hidden and (2) by including
|
|
267
|
+
the ``-fvisibility=hidden`` flag on Linux and macOS (only for extension
|
|
268
|
+
modules, not for embedding the interpreter).
|
|
269
|
+
|
|
270
|
+
.. _CPython's extension docs: https://docs.python.org/3/extending/extending.html#providing-a-c-api-for-an-extension-module
|
|
271
|
+
|
|
272
|
+
The namespace-scope hidden visibility is done automatically in pybind11's
|
|
273
|
+
headers and it's generally transparent to users. It ensures that:
|
|
274
|
+
|
|
275
|
+
* Modules compiled with different pybind11 versions don't clash with each other.
|
|
276
|
+
|
|
277
|
+
* Some new features, like ``py::module_local`` bindings, can work as intended.
|
|
278
|
+
|
|
279
|
+
The ``-fvisibility=hidden`` flag applies the same visibility to user bindings
|
|
280
|
+
outside of the ``pybind11`` namespace. It's now set automatic by pybind11's
|
|
281
|
+
CMake and Python build systems, but this needs to be done manually by users
|
|
282
|
+
of other build systems. Adding this flag:
|
|
283
|
+
|
|
284
|
+
* Minimizes the chances of symbol conflicts between modules. E.g. if two
|
|
285
|
+
unrelated modules were statically linked to different (ABI-incompatible)
|
|
286
|
+
versions of the same third-party library, a symbol clash would be likely
|
|
287
|
+
(and would end with unpredictable results).
|
|
288
|
+
|
|
289
|
+
* Produces smaller binaries on Linux and macOS, as pointed out previously.
|
|
290
|
+
|
|
291
|
+
Within pybind11's CMake build system, ``pybind11_add_module`` has always been
|
|
292
|
+
setting the ``-fvisibility=hidden`` flag in release mode. From now on, it's
|
|
293
|
+
being applied unconditionally, even in debug mode and it can no longer be opted
|
|
294
|
+
out of with the ``NO_EXTRAS`` option. The ``pybind11::module`` target now also
|
|
295
|
+
adds this flag to its interface. The ``pybind11::embed`` target is unchanged.
|
|
296
|
+
|
|
297
|
+
The most significant change here is for the ``pybind11::module`` target. If you
|
|
298
|
+
were previously relying on default visibility, i.e. if your Python module was
|
|
299
|
+
doubling as a shared library with dependents, you'll need to either export
|
|
300
|
+
symbols manually (recommended for cross-platform libraries) or factor out the
|
|
301
|
+
shared library (and have the Python module link to it like the other
|
|
302
|
+
dependents). As a temporary workaround, you can also restore default visibility
|
|
303
|
+
using the CMake code below, but this is not recommended in the long run:
|
|
304
|
+
|
|
305
|
+
.. code-block:: cmake
|
|
306
|
+
|
|
307
|
+
target_link_libraries(mymodule PRIVATE pybind11::module)
|
|
308
|
+
|
|
309
|
+
add_library(restore_default_visibility INTERFACE)
|
|
310
|
+
target_compile_options(restore_default_visibility INTERFACE -fvisibility=default)
|
|
311
|
+
target_link_libraries(mymodule PRIVATE restore_default_visibility)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
Local STL container bindings
|
|
315
|
+
----------------------------
|
|
316
|
+
|
|
317
|
+
Previous pybind11 versions could only bind types globally -- all pybind11
|
|
318
|
+
modules, even unrelated ones, would have access to the same exported types.
|
|
319
|
+
However, this would also result in a conflict if two modules exported the
|
|
320
|
+
same C++ type, which is especially problematic for very common types, e.g.
|
|
321
|
+
``std::vector<int>``. :ref:`module_local` were added to resolve this (see
|
|
322
|
+
that section for a complete usage guide).
|
|
323
|
+
|
|
324
|
+
``py::class_`` still defaults to global bindings (because these types are
|
|
325
|
+
usually unique across modules), however in order to avoid clashes of opaque
|
|
326
|
+
types, ``py::bind_vector`` and ``py::bind_map`` will now bind STL containers
|
|
327
|
+
as ``py::module_local`` if their elements are: builtins (``int``, ``float``,
|
|
328
|
+
etc.), not bound using ``py::class_``, or bound as ``py::module_local``. For
|
|
329
|
+
example, this change allows multiple modules to bind ``std::vector<int>``
|
|
330
|
+
without causing conflicts. See :ref:`stl_bind` for more details.
|
|
331
|
+
|
|
332
|
+
When upgrading to this version, if you have multiple modules which depend on
|
|
333
|
+
a single global binding of an STL container, note that all modules can still
|
|
334
|
+
accept foreign ``py::module_local`` types in the direction of Python-to-C++.
|
|
335
|
+
The locality only affects the C++-to-Python direction. If this is needed in
|
|
336
|
+
multiple modules, you'll need to either:
|
|
337
|
+
|
|
338
|
+
* Add a copy of the same STL binding to all of the modules which need it.
|
|
339
|
+
|
|
340
|
+
* Restore the global status of that single binding by marking it
|
|
341
|
+
``py::module_local(false)``.
|
|
342
|
+
|
|
343
|
+
The latter is an easy workaround, but in the long run it would be best to
|
|
344
|
+
localize all common type bindings in order to avoid conflicts with
|
|
345
|
+
third-party modules.
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
Negative strides for Python buffer objects and numpy arrays
|
|
349
|
+
-----------------------------------------------------------
|
|
350
|
+
|
|
351
|
+
Support for negative strides required changing the integer type from unsigned
|
|
352
|
+
to signed in the interfaces of ``py::buffer_info`` and ``py::array``. If you
|
|
353
|
+
have compiler warnings enabled, you may notice some new conversion warnings
|
|
354
|
+
after upgrading. These can be resolved using ``static_cast``.
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
Deprecation of some ``py::object`` APIs
|
|
358
|
+
---------------------------------------
|
|
359
|
+
|
|
360
|
+
To compare ``py::object`` instances by pointer, you should now use
|
|
361
|
+
``obj1.is(obj2)`` which is equivalent to ``obj1 is obj2`` in Python.
|
|
362
|
+
Previously, pybind11 used ``operator==`` for this (``obj1 == obj2``), but
|
|
363
|
+
that could be confusing and is now deprecated (so that it can eventually
|
|
364
|
+
be replaced with proper rich object comparison in a future release).
|
|
365
|
+
|
|
366
|
+
For classes which inherit from ``py::object``, ``borrowed`` and ``stolen``
|
|
367
|
+
were previously available as protected constructor tags. Now the types
|
|
368
|
+
should be used directly instead: ``borrowed_t{}`` and ``stolen_t{}``
|
|
369
|
+
(`#771 <https://github.com/pybind/pybind11/pull/771>`_).
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
Stricter compile-time error checking
|
|
373
|
+
------------------------------------
|
|
374
|
+
|
|
375
|
+
Some error checks have been moved from run time to compile time. Notably,
|
|
376
|
+
automatic conversion of ``std::shared_ptr<T>`` is not possible when ``T`` is
|
|
377
|
+
not directly registered with ``py::class_<T>`` (e.g. ``std::shared_ptr<int>``
|
|
378
|
+
or ``std::shared_ptr<std::vector<T>>`` are not automatically convertible).
|
|
379
|
+
Attempting to bind a function with such arguments now results in a compile-time
|
|
380
|
+
error instead of waiting to fail at run time.
|
|
381
|
+
|
|
382
|
+
``py::init<...>()`` constructor definitions are also stricter and now prevent
|
|
383
|
+
bindings which could cause unexpected behavior:
|
|
384
|
+
|
|
385
|
+
.. code-block:: cpp
|
|
386
|
+
|
|
387
|
+
struct Example {
|
|
388
|
+
Example(int &);
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
py::class_<Example>(m, "Example")
|
|
392
|
+
.def(py::init<int &>()); // OK, exact match
|
|
393
|
+
// .def(py::init<int>()); // compile-time error, mismatch
|
|
394
|
+
|
|
395
|
+
A non-``const`` lvalue reference is not allowed to bind to an rvalue. However,
|
|
396
|
+
note that a constructor taking ``const T &`` can still be registered using
|
|
397
|
+
``py::init<T>()`` because a ``const`` lvalue reference can bind to an rvalue.
|
|
398
|
+
|
|
399
|
+
v2.1
|
|
400
|
+
====
|
|
401
|
+
|
|
402
|
+
Minimum compiler versions are enforced at compile time
|
|
403
|
+
------------------------------------------------------
|
|
404
|
+
|
|
405
|
+
The minimums also apply to v2.0 but the check is now explicit and a compile-time
|
|
406
|
+
error is raised if the compiler does not meet the requirements:
|
|
407
|
+
|
|
408
|
+
* GCC >= 4.8
|
|
409
|
+
* clang >= 3.3 (appleclang >= 5.0)
|
|
410
|
+
* MSVC >= 2015u3
|
|
411
|
+
* Intel C++ >= 15.0
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
The ``py::metaclass`` attribute is not required for static properties
|
|
415
|
+
---------------------------------------------------------------------
|
|
416
|
+
|
|
417
|
+
Binding classes with static properties is now possible by default. The
|
|
418
|
+
zero-parameter version of ``py::metaclass()`` is deprecated. However, a new
|
|
419
|
+
one-parameter ``py::metaclass(python_type)`` version was added for rare
|
|
420
|
+
cases when a custom metaclass is needed to override pybind11's default.
|
|
421
|
+
|
|
422
|
+
.. code-block:: cpp
|
|
423
|
+
|
|
424
|
+
// old -- emits a deprecation warning
|
|
425
|
+
py::class_<Foo>(m, "Foo", py::metaclass())
|
|
426
|
+
.def_property_readonly_static("foo", ...);
|
|
427
|
+
|
|
428
|
+
// new -- static properties work without the attribute
|
|
429
|
+
py::class_<Foo>(m, "Foo")
|
|
430
|
+
.def_property_readonly_static("foo", ...);
|
|
431
|
+
|
|
432
|
+
// new -- advanced feature, override pybind11's default metaclass
|
|
433
|
+
py::class_<Bar>(m, "Bar", py::metaclass(custom_python_type))
|
|
434
|
+
...
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
v2.0
|
|
438
|
+
====
|
|
439
|
+
|
|
440
|
+
Breaking changes in ``py::class_``
|
|
441
|
+
----------------------------------
|
|
442
|
+
|
|
443
|
+
These changes were necessary to make type definitions in pybind11
|
|
444
|
+
future-proof, to support PyPy via its ``cpyext`` mechanism (`#527
|
|
445
|
+
<https://github.com/pybind/pybind11/pull/527>`_), and to improve efficiency
|
|
446
|
+
(`rev. 86d825 <https://github.com/pybind/pybind11/commit/86d825>`_).
|
|
447
|
+
|
|
448
|
+
1. Declarations of types that provide access via the buffer protocol must
|
|
449
|
+
now include the ``py::buffer_protocol()`` annotation as an argument to
|
|
450
|
+
the ``py::class_`` constructor.
|
|
451
|
+
|
|
452
|
+
.. code-block:: cpp
|
|
453
|
+
|
|
454
|
+
py::class_<Matrix>("Matrix", py::buffer_protocol())
|
|
455
|
+
.def(py::init<...>())
|
|
456
|
+
.def_buffer(...);
|
|
457
|
+
|
|
458
|
+
2. Classes which include static properties (e.g. ``def_readwrite_static()``)
|
|
459
|
+
must now include the ``py::metaclass()`` attribute. Note: this requirement
|
|
460
|
+
has since been removed in v2.1. If you're upgrading from 1.x, it's
|
|
461
|
+
recommended to skip directly to v2.1 or newer.
|
|
462
|
+
|
|
463
|
+
3. This version of pybind11 uses a redesigned mechanism for instantiating
|
|
464
|
+
trampoline classes that are used to override virtual methods from within
|
|
465
|
+
Python. This led to the following user-visible syntax change:
|
|
466
|
+
|
|
467
|
+
.. code-block:: cpp
|
|
468
|
+
|
|
469
|
+
// old v1.x syntax
|
|
470
|
+
py::class_<TrampolineClass>("MyClass")
|
|
471
|
+
.alias<MyClass>()
|
|
472
|
+
...
|
|
473
|
+
|
|
474
|
+
// new v2.x syntax
|
|
475
|
+
py::class_<MyClass, TrampolineClass>("MyClass")
|
|
476
|
+
...
|
|
477
|
+
|
|
478
|
+
Importantly, both the original and the trampoline class are now specified
|
|
479
|
+
as arguments to the ``py::class_`` template, and the ``alias<..>()`` call
|
|
480
|
+
is gone. The new scheme has zero overhead in cases when Python doesn't
|
|
481
|
+
override any functions of the underlying C++ class.
|
|
482
|
+
`rev. 86d825 <https://github.com/pybind/pybind11/commit/86d825>`_.
|
|
483
|
+
|
|
484
|
+
The class type must be the first template argument given to ``py::class_``
|
|
485
|
+
while the trampoline can be mixed in arbitrary order with other arguments
|
|
486
|
+
(see the following section).
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
Deprecation of the ``py::base<T>()`` attribute
|
|
490
|
+
----------------------------------------------
|
|
491
|
+
|
|
492
|
+
``py::base<T>()`` was deprecated in favor of specifying ``T`` as a template
|
|
493
|
+
argument to ``py::class_``. This new syntax also supports multiple inheritance.
|
|
494
|
+
Note that, while the type being exported must be the first argument in the
|
|
495
|
+
``py::class_<Class, ...>`` template, the order of the following types (bases,
|
|
496
|
+
holder and/or trampoline) is not important.
|
|
497
|
+
|
|
498
|
+
.. code-block:: cpp
|
|
499
|
+
|
|
500
|
+
// old v1.x
|
|
501
|
+
py::class_<Derived>("Derived", py::base<Base>());
|
|
502
|
+
|
|
503
|
+
// new v2.x
|
|
504
|
+
py::class_<Derived, Base>("Derived");
|
|
505
|
+
|
|
506
|
+
// new -- multiple inheritance
|
|
507
|
+
py::class_<Derived, Base1, Base2>("Derived");
|
|
508
|
+
|
|
509
|
+
// new -- apart from `Derived` the argument order can be arbitrary
|
|
510
|
+
py::class_<Derived, Base1, Holder, Base2, Trampoline>("Derived");
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
Out-of-the-box support for ``std::shared_ptr``
|
|
514
|
+
----------------------------------------------
|
|
515
|
+
|
|
516
|
+
The relevant type caster is now built in, so it's no longer necessary to
|
|
517
|
+
include a declaration of the form:
|
|
518
|
+
|
|
519
|
+
.. code-block:: cpp
|
|
520
|
+
|
|
521
|
+
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
|
|
522
|
+
|
|
523
|
+
Continuing to do so won’t cause an error or even a deprecation warning,
|
|
524
|
+
but it's completely redundant.
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
Deprecation of a few ``py::object`` APIs
|
|
528
|
+
----------------------------------------
|
|
529
|
+
|
|
530
|
+
All of the old-style calls emit deprecation warnings.
|
|
531
|
+
|
|
532
|
+
+---------------------------------------+---------------------------------------------+
|
|
533
|
+
| Old syntax | New syntax |
|
|
534
|
+
+=======================================+=============================================+
|
|
535
|
+
| ``obj.call(args...)`` | ``obj(args...)`` |
|
|
536
|
+
+---------------------------------------+---------------------------------------------+
|
|
537
|
+
| ``obj.str()`` | ``py::str(obj)`` |
|
|
538
|
+
+---------------------------------------+---------------------------------------------+
|
|
539
|
+
| ``auto l = py::list(obj); l.check()`` | ``py::isinstance<py::list>(obj)`` |
|
|
540
|
+
+---------------------------------------+---------------------------------------------+
|
|
541
|
+
| ``py::object(ptr, true)`` | ``py::reinterpret_borrow<py::object>(ptr)`` |
|
|
542
|
+
+---------------------------------------+---------------------------------------------+
|
|
543
|
+
| ``py::object(ptr, false)`` | ``py::reinterpret_steal<py::object>(ptr)`` |
|
|
544
|
+
+---------------------------------------+---------------------------------------------+
|
|
545
|
+
| ``if (obj.attr("foo"))`` | ``if (py::hasattr(obj, "foo"))`` |
|
|
546
|
+
+---------------------------------------+---------------------------------------------+
|
|
547
|
+
| ``if (obj["bar"])`` | ``if (obj.contains("bar"))`` |
|
|
548
|
+
+---------------------------------------+---------------------------------------------+
|