mirror of
https://github.com/google/brotli.git
synced 2024-11-21 19:20:09 +00:00
Python: Create Makefile for development shortcuts (#488)
This commit is contained in:
parent
fd96151b2a
commit
6ab0a5cee7
@ -51,12 +51,12 @@ See [Premake5](https://premake.github.io/)
|
||||
|
||||
#### Python
|
||||
|
||||
The basic commands to build, test, and install the Python module are:
|
||||
To install the Python module from source, run the following:
|
||||
|
||||
$ python setup.py build test
|
||||
$ python setup.py install
|
||||
|
||||
See the [Python readme](python/README.md) for more details.
|
||||
See the [Python readme](python/README.md) for more details on testing
|
||||
and development.
|
||||
|
||||
### Benchmarks
|
||||
* [Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/) / [Unstable Squash Compression Benchmark](https://quixdb.github.io/squash-benchmark/unstable/)
|
||||
|
49
python/Makefile
Normal file
49
python/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
# Copyright 2016 The Brotli Authors. All rights reserved.
|
||||
#
|
||||
# Distributed under MIT license.
|
||||
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
# Default
|
||||
.PHONY: all
|
||||
# Build
|
||||
.PHONY: build
|
||||
# Test
|
||||
.PHONY: test tests
|
||||
# Clean
|
||||
.PHONY: clean
|
||||
# Format
|
||||
.PHONY: fix
|
||||
|
||||
|
||||
PYTHON ?= python
|
||||
YAPF ?= yapf
|
||||
|
||||
EXT_SUFFIX=$(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
|
||||
EXT_SOURCES=$(shell find . -name '*.cc')
|
||||
EXTENSIONS=$(EXT_SOURCES:%.cc=%$(EXT_SUFFIX))
|
||||
|
||||
|
||||
all: build
|
||||
|
||||
build: $(EXTENSIONS)
|
||||
|
||||
$(EXTENSIONS): $(EXT_SOURCES)
|
||||
@cd .. && $(PYTHON) setup.py develop
|
||||
|
||||
test: tests
|
||||
|
||||
tests: build
|
||||
@echo 'running tests'
|
||||
@$(PYTHON) -m unittest discover -p '*_test.py'
|
||||
|
||||
clean:
|
||||
@cd .. && $(PYTHON) setup.py clean
|
||||
@find .. -name '*.pyc' | xargs rm -v
|
||||
@find .. -name '*.so' | xargs rm -v
|
||||
@find .. -type d -name '__pycache__' | xargs rm -v -r
|
||||
@find .. -type d -name '*.egg-info' | xargs rm -v -r
|
||||
|
||||
fix:
|
||||
@echo 'formatting code'
|
||||
-@$(YAPF) --in-place --recursive --verify .
|
@ -1,38 +1,43 @@
|
||||
This directory contains the code for the Python `brotli` module,
|
||||
`bro.py` tool, and roundtrip tests.
|
||||
|
||||
### Installation
|
||||
|
||||
If you just want to install the module from source, execute the
|
||||
following from the root project directory:
|
||||
|
||||
$ python setup.py install
|
||||
|
||||
### Development
|
||||
|
||||
To build the module, execute the following from the root project
|
||||
directory:
|
||||
For development, reinstalling the module with every change is time
|
||||
consuming. Instead, we recommend using the `setuptools`
|
||||
"[development mode][]" to make the module available while still being
|
||||
able to edit the source files.
|
||||
|
||||
$ python setup.py build
|
||||
We provide a `Makefile` to simplify common commands:
|
||||
|
||||
To test the module, execute the following from the root project
|
||||
directory:
|
||||
|
||||
$ python setup.py test
|
||||
$ make # Deploy the module in "development mode"
|
||||
|
||||
$ make tests # Test the module
|
||||
|
||||
$ make clean # Remove all temporary files and build output
|
||||
|
||||
### Code Style
|
||||
|
||||
Brotli's code follows the [Google Python Style Guide][]. To
|
||||
automatically format your code, install [YAPF][]:
|
||||
automatically format your code, first install [YAPF][]:
|
||||
|
||||
$ pip install yapf
|
||||
|
||||
Then, either format a single file:
|
||||
Then, to format all files in the project, you can run:
|
||||
|
||||
$ yapf --in-place FILE
|
||||
|
||||
Or, format all files in a directory:
|
||||
|
||||
$ yapf --in-place --recursive DIR
|
||||
$ make fix # Automatically format code
|
||||
|
||||
See the [YAPF usage][] documentation for more information.
|
||||
|
||||
|
||||
[development mode]: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
|
||||
[Google Python Style Guide]: https://google.github.io/styleguide/pyguide.html
|
||||
[YAPF]: https://github.com/google/yapf
|
||||
[YAPF usage]: https://github.com/google/yapf#usage
|
||||
|
Loading…
Reference in New Issue
Block a user