Supercharge your mach commands with external Python packages

Gregory Szorc gps at mozilla.com
Sat Sep 21 00:17:50 UTC 2013


The "mach" script in the root directory of mozilla-central is a generic
command dispatching tool. Have a piece of commonly used functionality
useful to many people? Create a mach command so others can use it easily!

While mach started with commands dealing with build system interaction
and running tests, it has since evolved to provide additional
functionality. For example, run |mach mercurial-setup| to help you
ensure an optimal Mercurial experience. Run |mach uuid| to generate a
new UUID. Run |mach update-uuids| to automatically change the UUID of an
IDL.

Until recently, mach commands were mostly limited to using functionality
exposed in the tree. Wanted to use an external Python package to get
work done? It wasn't exactly easy. Now, with the work in bug 794506,
it's trivial for mach commands to install external Python packages at
run-time. See the implementation of |mach build-docs| [1] for an example.

The possibilities here are really endless since there are so many
packages in PyPI - the Python Package Index [2]. Some crazy ideas:

* Install Mercurial and have access to the Mercurial API (but watch out
for MPL-GPL license mismatch)
* Install hg-git and add commands for converting between Mercurial and Git
* Install dulwich (Git implemented in Python) for interacting with Git
repositories.
* Install Node.js through https://pypi.python.org/pypi/gp.recipe.node
and leverage Node for voodoo
* Install mozdownload (https://pypi.python.org/pypi/mozdownload/) to
download pre-built builds (I have some nefarious ideas for this
involving bootstrapping the build system)
* Install MozillaPulse (https://pypi.python.org/pypi/MozillaPulse/) to
subscribe to automation events in near real time.

There's, uh, a lot of cool stuff you can do with this. I encourage you
to explore and contribute your awesomeness back to the tree so others
can more easily leverage your work. Scratch your own itches then package
them as mach commands so others can do the same.

As a disclaimer, if you install something using mach, it *may* interfere
with the build system. This shouldn't happen. But if it does, you've
been forewarned.

Enjoy.

[1]
https://hg.mozilla.org/integration/mozilla-inbound/diff/85811665eed7/python/mozbuild/mozbuild/mach_commands.py
[2] https://pypi.python.org/pypi





More information about the firefox-dev mailing list