installing.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. _installing:
  2. Installing the library
  3. ######################
  4. There are several ways to get the pybind11 source, which lives at
  5. `pybind/pybind11 on GitHub <https://github.com/pybind/pybind11>`_. The pybind11
  6. developers recommend one of the first three ways listed here, submodule, PyPI,
  7. or conda-forge, for obtaining pybind11.
  8. .. _include_as_a_submodule:
  9. Include as a submodule
  10. ======================
  11. When you are working on a project in Git, you can use the pybind11 repository
  12. as a submodule. From your git repository, use:
  13. .. code-block:: bash
  14. git submodule add -b stable ../../pybind/pybind11 extern/pybind11
  15. git submodule update --init
  16. This assumes you are placing your dependencies in ``extern/``, and that you are
  17. using GitHub; if you are not using GitHub, use the full https or ssh URL
  18. instead of the relative URL ``../../pybind/pybind11`` above. Some other servers
  19. also require the ``.git`` extension (GitHub does not).
  20. From here, you can now include ``extern/pybind11/include``, or you can use
  21. the various integration tools (see :ref:`compiling`) pybind11 provides directly
  22. from the local folder.
  23. Include with PyPI
  24. =================
  25. You can download the sources and CMake files as a Python package from PyPI
  26. using Pip. Just use:
  27. .. code-block:: bash
  28. pip install pybind11
  29. This will provide pybind11 in a standard Python package format. If you want
  30. pybind11 available directly in your environment root, you can use:
  31. .. code-block:: bash
  32. pip install "pybind11[global]"
  33. This is not recommended if you are installing with your system Python, as it
  34. will add files to ``/usr/local/include/pybind11`` and
  35. ``/usr/local/share/cmake/pybind11``, so unless that is what you want, it is
  36. recommended only for use in virtual environments or your ``pyproject.toml``
  37. file (see :ref:`compiling`).
  38. Include with conda-forge
  39. ========================
  40. You can use pybind11 with conda packaging via `conda-forge
  41. <https://github.com/conda-forge/pybind11-feedstock>`_:
  42. .. code-block:: bash
  43. conda install -c conda-forge pybind11
  44. Include with vcpkg
  45. ==================
  46. You can download and install pybind11 using the Microsoft `vcpkg
  47. <https://github.com/Microsoft/vcpkg/>`_ dependency manager:
  48. .. code-block:: bash
  49. git clone https://github.com/Microsoft/vcpkg.git
  50. cd vcpkg
  51. ./bootstrap-vcpkg.sh
  52. ./vcpkg integrate install
  53. vcpkg install pybind11
  54. The pybind11 port in vcpkg is kept up to date by Microsoft team members and
  55. community contributors. If the version is out of date, please `create an issue
  56. or pull request <https://github.com/Microsoft/vcpkg/>`_ on the vcpkg
  57. repository.
  58. Global install with brew
  59. ========================
  60. The brew package manager (Homebrew on macOS, or Linuxbrew on Linux) has a
  61. `pybind11 package
  62. <https://github.com/Homebrew/homebrew-core/blob/master/Formula/pybind11.rb>`_.
  63. To install:
  64. .. code-block:: bash
  65. brew install pybind11
  66. .. We should list Conan, and possibly a few other C++ package managers (hunter,
  67. .. perhaps). Conan has a very clean CMake integration that would be good to show.
  68. Other options
  69. =============
  70. Other locations you can find pybind11 are `listed here
  71. <https://repology.org/project/python:pybind11/versions>`_; these are maintained
  72. by various packagers and the community.