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