You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.4 KiB

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