1a8c51b3fSopenharmony_ci# Building and installing Python bindings
2a8c51b3fSopenharmony_ci
3a8c51b3fSopenharmony_ciPython bindings are available as wheels on [PyPI](https://pypi.org/project/google-benchmark/) for importing and 
4a8c51b3fSopenharmony_ciusing Google Benchmark directly in Python. 
5a8c51b3fSopenharmony_ciCurrently, pre-built wheels exist for macOS (both ARM64 and Intel x86), Linux x86-64 and 64-bit Windows.
6a8c51b3fSopenharmony_ciSupported Python versions are Python 3.7 - 3.10.
7a8c51b3fSopenharmony_ci
8a8c51b3fSopenharmony_ciTo install Google Benchmark's Python bindings, run:
9a8c51b3fSopenharmony_ci
10a8c51b3fSopenharmony_ci```bash
11a8c51b3fSopenharmony_cipython -m pip install --upgrade pip  # for manylinux2014 support
12a8c51b3fSopenharmony_cipython -m pip install google-benchmark
13a8c51b3fSopenharmony_ci```
14a8c51b3fSopenharmony_ci
15a8c51b3fSopenharmony_ciIn order to keep your system Python interpreter clean, it is advisable to run these commands in a virtual
16a8c51b3fSopenharmony_cienvironment. See the [official Python documentation](https://docs.python.org/3/library/venv.html) 
17a8c51b3fSopenharmony_cion how to create virtual environments.
18a8c51b3fSopenharmony_ci
19a8c51b3fSopenharmony_ciTo build a wheel directly from source, you can follow these steps:
20a8c51b3fSopenharmony_ci```bash
21a8c51b3fSopenharmony_cigit clone https://github.com/google/benchmark.git
22a8c51b3fSopenharmony_cicd benchmark
23a8c51b3fSopenharmony_ci# create a virtual environment and activate it
24a8c51b3fSopenharmony_cipython3 -m venv venv --system-site-packages
25a8c51b3fSopenharmony_cisource venv/bin/activate  # .\venv\Scripts\Activate.ps1 on Windows
26a8c51b3fSopenharmony_ci
27a8c51b3fSopenharmony_ci# upgrade Python's system-wide packages
28a8c51b3fSopenharmony_cipython -m pip install --upgrade pip setuptools wheel
29a8c51b3fSopenharmony_ci# builds the wheel and stores it in the directory "wheelhouse".
30a8c51b3fSopenharmony_cipython -m pip wheel . -w wheelhouse
31a8c51b3fSopenharmony_ci```
32a8c51b3fSopenharmony_ci
33a8c51b3fSopenharmony_ciNB: Building wheels from source requires Bazel. For platform-specific instructions on how to install Bazel,
34a8c51b3fSopenharmony_cirefer to the [Bazel installation docs](https://bazel.build/install).
35