| 1 | This directory contains the code for the Python `brotli` module, |
| 2 | `bro.py` tool, and roundtrip tests. |
| 3 | |
| 4 | Only Python 2.7+ is supported. |
| 5 | |
| 6 | We provide a `Makefile` to simplify common development commands. |
| 7 | |
| 8 | ### Installation |
| 9 | |
| 10 | If you just want to install the latest release of the Python `brotli` |
| 11 | module, we recommend installing from [PyPI][]: |
| 12 | |
| 13 | $ pip install brotli |
| 14 | |
| 15 | Alternatively, you may install directly from source by running the |
| 16 | following command from this directory: |
| 17 | |
| 18 | $ make install |
| 19 | |
| 20 | If you already have native Brotli installed on your system and want to use this one instead of the vendored sources, you |
| 21 | should set the `USE_SYSTEM_BROTLI=1` environment variable when building the wheel, like this: |
| 22 | |
| 23 | $ USE_SYSTEM_BROTLI=1 pip install brotli --no-binary brotli |
| 24 | |
| 25 | Brotli is found via the `pkg-config` utility. Moreover, you must build all 3 `brotlicommon`, `brotlienc`, and `brotlidec` |
| 26 | components. If you're installing brotli from the package manager, you need the development package, like this on Fedora: |
| 27 | |
| 28 | $ dnf install brotli brotli-devel |
| 29 | |
| 30 | ### Development |
| 31 | |
| 32 | You may run the following commands from this directory: |
| 33 | |
| 34 | $ make # Build the module in-place |
| 35 | |
| 36 | $ make test # Test the module |
| 37 | |
| 38 | $ make clean # Remove all temporary files and build output |
| 39 | |
| 40 | If you wish to make the module available while still being |
| 41 | able to edit the source files, you can use the `setuptools` |
| 42 | "[development mode][]": |
| 43 | |
| 44 | $ make develop # Install the module in "development mode" |
| 45 | |
| 46 | ### Code Style |
| 47 | |
| 48 | Brotli's code follows the [Google Python Style Guide][]. To |
| 49 | automatically format your code, first install [YAPF][]: |
| 50 | |
| 51 | $ pip install yapf |
| 52 | |
| 53 | Then, to format all files in the project, you can run: |
| 54 | |
| 55 | $ make fix # Automatically format code |
| 56 | |
| 57 | See the [YAPF usage][] documentation for more information. |
| 58 | |
| 59 | |
| 60 | [PyPI]: https://pypi.org/project/Brotli/ |
| 61 | [development mode]: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode |
| 62 | [Google Python Style Guide]: https://google.github.io/styleguide/pyguide.html |
| 63 | [YAPF]: https://github.com/google/yapf |
| 64 | [YAPF usage]: https://github.com/google/yapf#usage |