As codebases grow, they become increasingly difficult to work with. Builds get ever slower and existing tooling doesn’t scale. One solution is to keep splitting the code into more and more independent repositories — but you end up with hundreds of free-floating codebases with hard-to-manage dependencies. This makes it hard to discover, navigate and share code, which can affect developer productivity.
Another solution is to have a single large, unified codebase. We’ve found that this promotes better engineering team cohesion and collaboration, which results in greater productivity and happiness. But tooling for such structured codebases has been lacking. That’s why we developed Pants, an open source build system written in Python.
Pants models code modules (known as “targets”) and their dependencies in BUILD files — in a manner similar to Google’s internal build system. This allows it to only build the parts of the codebase you actually need, ignoring the rest of the code. That’s a key requirement for scaling large, unified codebases.
Pants started out in 2010 as an internal tool here, and was originally just a frontend to generate build.xml files for the Ant build tool, hence the name (a contraction of “Python Ant”). Pants grew in capability and complexity, and became the build tool for the twitter/commons open source libraries, and hence became open source itself.
In 2012, Foursquare began using Pants internally, and Foursquare engineers picked up the Pants development mantle, adding Scala support, build artifact caching and many other features. Since then, several more engineering teams, including those at Urban Compass and Oscar, have integrated Pants into their codebases. Most recently, Square began to use Pants, and has contributed significantly to its development.
As a result, Pants is a true independent open source project with collaborators across companies and a growing development community. It now lives in a standalone GitHub repo at github.com/pantsbuild/pants and we’ve welcomed more committers to the project.
Among Pants’ current strengths:
If your codebase is growing beyond your toolchain’s ability to scale, but you’re reluctant to split it up, you might want to give Pants a try. It may be of particular interest if you have complex dependencies, generated code and custom build steps. Pants is still a young and evolving open source project. We constantly strive to make it easier to use. If you’re interested in using or learning from Pants, reach out to the community on the developer mailing list and follow @pantsbuild for updates.