In its upcoming release, now available to early adopters, build system Pants adds Java, Scala, and Go to previously supported Python.
Pants aims to be a fast, scalable, and user-friendly build system. Pants breaks a build into many smaller tasks to be able to run them concurrently and cache their results to avoid having to run them again unless strictly required. Pants is compatible with servers complying with the caching and remote execution API, also used by Bazel and others. This also makes it suitable for splitting work across multiple identically-configured hosts.
One of Pants' goal is making build files less cluttered and light on the developer by avoiding unnecessary configuration. Indeed, thanks to a number of default choices, many projects will be ready to go by simply defining a pants.toml
configuration file that includes the Pants version you want to pin your project to and required backends. This will tell Pants which source files to look for and create a suitable BUILD
file for you. For example, this is how you can specify a list of backends for a Python project, including linting and mypy support:
[GLOBAL]
pants_version = "2.8.0"
backend_packages.add = [
"pants.backend.python",
"pants.backend.python.lint.docformatter",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
"pants.backend.python.lint.isort",
"pants.backend.python.typecheck.mypy",
]
Each backend can be configured by providing specific options in its own .toml
section. In addition to creating libraries and executables, Pants is also able to deploy to Docker and AWS Lambda using their corresponding backends.
Pants is mostly written in Python, with an ongoing Rust migration aimed to reduce client latency, and provides an API to enable the creation of plugins to add custom build steps, in case required.
InfoQ has spoken with Benjy Weinberger, one of the creators of Pants alongside John Sirois, and currently CEO of Toolchain, Pants' main sponsor.
InfoQ: The build system arena is quite crowded. Why do you think there is a need for another build system? What makes Pants unique in comparison to other solutions?
Benjy Weinberger: In the last 5-10 years, a few convergent trends have made codebases and their build workflows increasingly complex. These include: a growing reliance on large tangles of third-party dependencies, more application frameworks and layers of abstraction, novel deployment paradigms (containers, cloud functions, microservices), and the emergence of data science as an engineering discipline in its own right.
Existing tools were not designed with these trends in mind, and they are often limited in capability and scalability in the face of these and other innovations. The designs of existing tools were typically driven by one of two concerns: A) Support for small to medium codebases using a single language/framework, or B) Support for the internal needs of a single company. In neither case will such a tool be able to address the needs of most real-world engineering teams today.
Pants v2 was designed with these use-cases in mind, and in particular with how they are utilized by engineering teams of various sizes, across different industries. Pants is a significant leap forward in usability, stability and performance for a wide variety of users whose needs are not being met by previous-generation build systems.
Another important innovation in Pants is in ergonomics: previous-generation build systems, particularly the multi-language ones, tend to have a steep learning curve, requiring every user to ingest a new domain of terms and concepts just to get anything done. Pants, whenever possible, works with the natural idioms of the languages and frameworks the user is already familiar with, and tries to "get out of the way" as much as possible.
Beyond its technical capabilities, what also sets Pants apart is its very strong open-source community ethos: any individual or organization can be an equal participant in the design and implementation, which helps ensure that the project responds to the needs of a diverse set of users. Community feedback on design and prioritization is actively solicited, and the community is also a friendly resource for getting help with adopting and using Pants.
InfoQ: What are Pants' natural competitors in your view?
Weinberger: The biggest "competitor" we see in the marketplace is not a specific system, but rather motley collections of cobbled together, ad-hoc, DIY scripts. Dissatisfaction with these runs high, but few teams have the expertise or experience to improve on them on their own. Pants systematizes all this build work, providing a uniform, ergonomic user experience that is a great fit for your use-cases, and doesn't distract you from the task at hand, while also providing better performance, thanks to caching and concurrency. Since the homebrewed solutions don't scale well, teams often find themselves splitting their codebase up artificially. This slows collaborative development down, as users have to take extra steps to publish code so it can be consumed across repo boundaries. Pants allows you to keep your codebase unified, supporting rapid iteration and nimble development.
Beyond that, of course we see Bazel as a natural competitor. It's important to note that Bazel was designed for Google's internal use. Their informal slogan is "Build like Google". But if you're not Google, you almost certainly don't want to build like Google! Your use-cases are probably very different, and Bazel was not designed for them. For example, Google doesn't use third-party dependencies, so Bazel's support for them is haphazard, whereas Pants' is robust. Pants is also considerably easier to adopt, use and customize. There are several reasons why an engineering team should consider choosing Pants over Bazel, summarized in this article.
InfoQ: Pants 2.8 significantly extends the set of languages it supports. What's on Pants roadmap for next year?
Weinberger: Because our roadmap is so community-driven, we're still figuring our 2022 plans out! We thrive on user input, and now is a great time to provide it, as we look to plan for the months ahead. That said, a few likely themes are:
Security: Further improving Pants's ability to lock down your builds against supply chain and other attacks. We already have good support in this area, but security is an evolving landscape requiring constant vigilance.
More work on scalability and performance, to ensure that all enterprise users have a great build experience.
New language support: Which languages will depend on community feedback, but we'll be considering JavaScript/TypeScript and Rust, for example.
IDE integrations, specifically IntelliJ/PyCharm, and VS Code.
Pants is open source and its community is active on Slack. As mentioned, Pants' latest version is available as a preview to interested developers.