Pants 2 is a fast, scalable, user-friendly build system for codebases of all sizes. It's currently focused on Python, Go, Java, Scala, Kotlin, Shell, and Docker, with support for other languages and frameworks coming soon.
Individuals and companies can now sponsor Pants financially.
Pants is an open-source project that is not owned or controlled by any one company or organization, and does incur some expenses. These expenses are managed by Pants Build, a non-profit that was established for this purpose. This non-profit's only source of revenue is sponsorship by individuals and companies that use Pants.
We offer formal sponsorship tiers for companies, as well as individual sponsorships via GitHub.
- All built-in backends now support the
[test].attempts_defaultoption to automatically retry tests. - Significant speed-ups when manipulating Python dependencies, especially huge ones like PyTorch.
- When a
pants test ...run in CI fails, the summary now includes suggested invocation to copy-paste and re-run locally. - The
__defaults__symbol now applies to targets generated by a target generator, in addition to targets written literally in BUILD files.
Keep reading to see the details and what's also included.
All built-in targets that support testing with the pants test goal now support automatic retries, using the [test].attempts_default option.
When running in CI, the printed summary at the end of a pants test ... run will now include single invocation to rerun all failing tests, if any. This can be controlled by the new [test].show_rerun_command option.
Option values can now be optionally read from files using @?.... For instance, opt = "@some_file.txt" will give an error if some_file.txt does not exist, but the new syntax opt = "@?some_file.txt" will just leave the option unset.
The stats subsystem can now output structured data, using the new [stats].format = "jsonlines" option. The structured output can make it easier to ingest and analyze Pants stats data, for example, tracking information about CI builds.
Introspection goals have had a few improvements:
-
pants peek ...now includes agoalsfield which will return a curated list of goals that can be run on the target -
Using the
jsonformat forpants dependencies ...orpants dependencies ...now correctly obeys theoutput_filesetting.
The __defaults__ symbol will now set default values for generated targets too. For instance, __defaults__({python_source: dict(skip_black=True)}) will now apply to the python_source targets generated by a python_sources target, without having to write __defaults__({(python_source, python_sources): ...}).
The visibility rules now supports using dicts for rules, in addition to strings, the same as a selectors. This means, for instance, {"path": "foo/bar.py", "action": "deny"} is equivalent to "!foo/bar.py".
Targets that use parametrize groups depending on other parametrized targets now match by the name passed as the positional argument to parametrize.
The cache_from field on docker_image now supports multiple values.
The new extra_run_args field on docker_image allows adding extra arguments that are passed into the docker run ... invocation when running the image with pants run.
Pants now correctly extracts the image ID when using docker buildx version 0.13.1 or greater.
Note: existing code that sets __defaults__(all=dict(extra_build_args=...)) to apply to docker_image targets will start applying to pex_binary targets too, since that target now has a field of the same name. Use __defaults__({docker_image: dict(extra_build_args=...)}) instead.
Failing go_package tests can now be automatically retried by setting the [test].attempts_default option.
Go mod files referring to Go versions with patch (like go 1.21.0) no longer cause Pants to crash.
Failing helm_unittest_test tests can now be automatically retried by setting the [test].attempts_default option.
The sources field of helm_chart targets now includes documentation files like README.md and values.schema.json so that they are available once published.
Versions 3.13.3 and 3.14.3 of the Helm tool are now known. Version 3.14.3 is now the default version.
The experimental-deploy goal now has built-in support for the --dry-run option, which passes that to the underlying Helm invocation.
The helm-k8s-parser subsystem now uses hikaru version 0.16.0b0 by default. The helm-post-renderer subsystem now uses yamlpath version 3.8.1 by default.
Failing javascript_test tests can now be automatically retried by setting the [test].attempts_default option.
package_json targets using yarn v2 or greater as the package manager are now supported.
Failing kotlin_junit_test, junit_test, and scala_junit_test tests can now be automatically retried by setting the [test].attempts_default option.
Scalafix can now be run by Pants using the new pants.backend.experimental.scala.lint.scalafix backend.
All built-in tool lockfiles are now configured to support Python 3.12, if the underlying tool version does.
Any PEX files Pants builds internally now take less work to build, meaning running tools and tests can be faster. These PEX files are now built with the --no-pre-install-wheels flag and thus directly use the wheels for third-party dependencies, without repackaging them. This is particularly valuable for requirements with huge wheels like PyTorch. One benchmark indicates key parts of build a pex file containing PyTorch are several minutes faster. This speed up applies for all tools and is visible even with smaller wheels. The author of these release notes observed the time to run mypy from scratch dropped from 150s to 100s in a production codebase.
The new extra_build_args field on pex_binary allows passing arbitrary additional arguments to the underlying pex invocation when packaging those targets. (Note: existing code that sets __defaults__(all=dict(extra_build_args=...)) to apply to docker_image targets will thus start applying this to pex_binary targets too. Use __defaults__({docker_image: dict(extra_build_args=...)}) instead.)
Pants now uses pex version 2.3.1 by default, and requires version 2.3.0 or greater.
The Ruff backend now uses version 0.3.0 by default.
The new skip_ruff_check and skip_ruff_format fields on targets like python_source and python_test allow stopping either the linter or formatter specifically from running on that target. The existing skip_ruff field continues to stop both the linter and formatter from running.
The runtime field of the python_google_cloud_function target now supports python312.
Virtualenvs exported with pants export ... have improved in two ways (Note: these apply only when using py_resolve_format = "mutable_virtualenv", which is the default):
-
They include Pants' resolve name in the shell prompt, when activated.
-
The new
py_hermetic_scriptsoption allows disabling the default behaviour of rewriting scripts to be hermetic (ignore system libraries and configuration), to, for example, allow IDEs like PyCharm to inject its debugger, coverage, or other IDE-specific libs when running a script.
Default module mappings were added for more modules: antlr4-python3-runtime, auth0-python, biopython, cloud-sql-python-connector, coolprop, databricks-sdk, databricks-sql-connetor, delta-spark, django-activity-stream, django-notifications-hq, django-oauth-toolkit, django-two-factor-auth, djangorestframework-jwt, dnspython, drf-api-tracking, faiss-cpu, faiss-gpu, fonttools, grpcio-status, grpcio-testing, matplotlib, matrix-nio, netcdf4, o365, py-healthcheck, pycryptodome, perfa, pynacl, pyshp, python-sat, pywavelets, robotraconteur, sisl. The mappings for opentelemetry have been restored after a regression in 2.20.0 (NB. this fix was released in 2.20.1 too).
The default version for many subsystems/backends has been updated:
coverage-py: 7.2.7debugpy: 1.6.7.post1pants.backend.python.lint.autoflake: 2.1.1pants.backend.python.lint.bandit: 1.7.5pants.backend.python.lint.black: 23.3.0pants.backend.python.typecheck.mypy: 1.4.1pants.backend.python.lint.pyupgrade: 3.3.2pants.backend.python.lint.yapf: 0.40.2
The deprecation has expired for the python_awslambda target alias: use the new python_aws_lambda_function target instead.
The pants.backend.shell.lint.shellcheck backend now uses version 0.10.0 by default.
Failing shunit2_test and experimental_test_shell_command tests can now be automatically retried by setting the [test].attempts_default option.
The experimental-deploy goal now has built-in support for the --dry-run option, which runs terraform plan instead of terraform apply.
The terraform-hcl2-parser subsystem now uses python-hcl2 version 4.3.2 by default.
The pants.backend.experimental.tools.yamllint backend now uses version 1.32.0 by default.
Plugins that define target generators should set the generated_target_cls class var to the targets that they generate. This ensures that __defaults__ set for that generated_target_cls class are applied to the targets generated by the plugin. (#20649)
The new pants.backend.project_info.peek.HasAdditionalTargetDataFieldSet union allows attaching arbitrary information to targets. This is shown in the peek output for these targets by using pants peek --include-additional-info ....
The new pants.core.goals.resolves.ExportableTool union allows subsystems and tools to be exported with pants export ..., similar to a user resolve. (#20730)
The implicit_value keyword argument for option registration is no longer supported. (#20762)
For the full changelog, see the individual GitHub Releases for this series: https://github.com/pantsbuild/pants/releases