No requirements. Tested on Python 2.7 and 3.6 on Ubuntu 16.04 and macOS High Sierra.
Tested on Bazel 0.11.1. All recent versions are expected to work.
> git clone https://github.com/tuomasr/pazel.git
> cd pazel
> python setup.py install
NOTE: pazel
overwrites any existing BUILD files. Please use version control or have backups of
your current BUILD files before using pazel
.
The following example generates all BUILD files for the sample Python project in sample_app
.
Start from the pazel
root directory to which the repository was cloned.
> bazel run //pazel:app -- <pazel_root_dir>/sample_app -r <pazel_root_dir>/sample_app
-c <pazel_root_dir>/sample_app/.pazelrc
Generated BUILD files for <pazel_root_dir>/sample_app.
Start from the pazel
root directory.
> cd sample_app
> pazel
Generated BUILD files for <pazel_install_dir>/sample_app.
Now, we can build, test, and run the sample project by running the following invocations in the
sample_app
directory, respectively.
> bazel build
> bazel test ...
> bazel run foo:bar3
pazel -h
shows a summary of the command-line options. Each of them is explained below.
By default, BUILD files are generated recursively for the current working directory.
Use pazel <some_path>
to generate BUILD file(s) recursively for another directory
or for a single Python file.
All imports are assumed to be relative to the current working directory. For example,
sample_app/foo/bar2.py
imports from sample_app/foo/bar1.py
using from foo.bar1 import sample
.
Use pazel -r <some_path>
to override the path to which the imports are relative.
By default, pazel
adds rules to install all external Python packages. If your environment has
pre-installed packages for which these rules are not required, then use pazel -p
.
pazel
config file .pazelrc
is read from the current working directory. Use
pazel -c <pazelrc_path>
to specify an alternative path.
The tag # pazel-ignore
causes pazel
to ignore the rule that immediately follows the tag in an
existing BUILD file. In particular, the tag can be used to skip custom rules that pazel
does not
handle. pazel
places the ignored rules at the bottom of the BUILD file. See sample_app/foo/BUILD
for an example using the tag.