Pants 2.x is built around the "v2" engine, which is a complete, ground-up redesign of the entire system, based on lessons learned from 10 years of development on the previous, "v1", technology.
The Pants engine is written in Rust, for performance. The build rules that it uses are written in typed Python 3, for familiarity and simplicity.
The engine is designed so that fine-grained invalidation, concurrency, hermeticity, caching, and remote execution happen naturally, without rule authors needing to think about it.
The 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.
The engine caches processes precisely based on their inputs, and sandboxes execution to minimize side-effects and to make builds consistent and repeatable.
The 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 and your CI can reuse the results of commands you already ran.
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.
Pants sandboxes all processes that it executes, ensuring that cache keys are always accurate, and builds are always correct.
Pants analyzes your code's import statements to determine files' dependencies automatically. Dependency information is required for precise change detection and cache invalidation, but inference means that you don't need to declare dependencies manually (and hermetic execution guarantees that they are always accurate)!
Older build tools like Bazel:
python_library( name="lib" deps=[ "//src/python/project/core", "//src/python/project/models:customer", "//src/python/project/models:organization", "//src/python/project/models:policy", "//src/python/project/models:user", "//src/python/project/views:dashboard", "//src/python/project/util:csrf_util", "//src/python/project/util:strutil", ], ) python_tests( name="tests", deps=[ ... ], )
With the Pants plugin API, your custom rules will run with the same concurrency, caching, and remoting semantics as the core rules.
Some example plugins that users have written:
- Cython support
- Building a Docker image, including packages built via
setup.pylogic to compute the
- Jupyter support
Updated about 1 year ago