HomeDocs
DocsCommunityTestimonialsUsersGitHubTwitterBlogJobsTermsPrivacyCookies
TermsPrivacyCookies

Pants v1 vs. v2 engine

How the redesign of Pants impacts your project.

👍

New user? You may skip this page

This page is intended for current Pants users still using the v1 implementation of Pants. If you are trying Pants for a new project, you will already be using the v2 version of Pants, so you can ignore this page.

What is Pants v1?

Pants v1 refers to the original execution engine, and the build logic that it runs. Pants v1 includes support for Python, Java, Scala, Node and Go. The v1 engine has been around since the early 2010s, and is on a path to deprecation and removal.

What is Pants v2?

Pants v2 refers to the new execution engine, and the build logic that uses it. Pants v2 is a complete, ground-up redesign, based on lessons learned from v1.

The v2 engine is written in Rust, for performance. The build rules that it uses are written in typed Python 3, for familiarity and simplicity. The v2 engine is designed so that fine-grained invalidation, concurrency, hermeticity, caching and remote execution happen naturally, without rule authors needing to think about it.

Pants v2 currently includes supports Python, with support for Java, Scala and other languages still to come.

Why should I care about v2?

Pants v2 has many advantages over v1 (and over many other systems). These include:

Concurrency

The v2 engine can take full advantage of all the cores on your machine because relevant portions are implemented in Rust atop the Tokio framework.

This means, for example, that you can run all of your linters at the same time, and fully utilize your cores to run tests in parallel.

Caching

The v2 engine caches processes precisely based on their inputs, and sandboxes execution to minimize side-effects and to make builds consistent and repeatable.

Remote Execution

The v2 engine can delegate work to a remote build cluster so that you are no longer limited by the number of cores on your machine. If you have enough remote workers, you can run your entire test suite in total parallelism.

Remote caching means that your coworkers can reuse the results of commands you already ran.

Fine-grained invalidation

Work is broken down into many small units and kept warm in a daemon so that as little work as possible needs to be re-done when files change.

User Interface

The old "tree-based" output has been replaced by a low-latency dynamic UI.

796

This means that Pants's output is less verbose, and you can see what Pants is doing "under-the-hood" at any given moment.

Python Features

Pants v2 supports all the Python features that v1 supported, such as running tests and building binaries. It also provides many new or improved features:

Precise file arguments

When you run ./pants test project/app_test.py, for example, Pants v2 will only run the tests in that specific file.

(Pants v1 would run over the owning target, which might contain many additional files.)

A powerful plugin system

The old v1 plugin API required you to explicitly think about caching, and also made it hard to express dependencies between build steps.

With the v2 plugin API, your rules will run with the same concurrency, caching, and remoting semantics as the core rules!

👍

Upcoming feature: dependency inference

Soon, Pants will be able to analyze your Python import statements to determine which targets your code depends on. This means that you will be able to leave off the dependencies field in BUILD files most of the time.