Learn Python with Talk Python's 270 hours of courses

Build All the Things with Pants Build System

Episode #387, published Thu, Oct 27, 2022, recorded Thu, Oct 6, 2022

Do you have a large or growing Python code base? If you struggle to run builds, tests, linting, and other quality checks regularly or quickly, you'll want to hear what Benjy Weinberger has to say. He's here to introduce Pants Build to us. Pants 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.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Introduction and Background

Benjy Weinberger is a seasoned software developer with over two decades of experience. He’s been at companies such as Twitter, where he helped develop large-scale engineering solutions and cultivated deep expertise in developer tooling. Benjy is a co-founder at Toolchain, where he leads the creation and support of Pants Build—a fast, scalable, user-friendly build system for Python and other languages. His passion for making developers’ lives easier and for empowering teams of all sizes to have enterprise-grade build tooling is a driving force behind Pants Build’s continuous evolution.

What to Know If You're New to Python

If you’re new to Python and want to get the most out of this episode, it helps to understand basic package management, testing, and version control with Git. Knowing how to install and run third-party libraries (e.g., using pip or virtual environments) will also help you follow references to Python tooling.

Key Points and Takeaways

  1. Pants Build System for Large or Growing Codebases Pants is a build system that automates testing, packaging, and code quality checks, especially valuable for teams with substantial Python code. It focuses on dependency inference, caching, concurrency, and minimal setup overhead so you can quickly scale workflows without manual complexity.
  2. Seamless Integration with Python Tooling Pants automatically orchestrates popular Python tools such as pytest, mypy, Black, Bandit, and more. Instead of manually installing and remembering to run each tool in the correct order, Pants can unify these steps, speeding up routine tasks and ensuring consistent standards.
  3. Caching and Parallelism for Speed The Pants engine creates a dependency graph for each action—like testing or linting—and runs them with maximum concurrency while caching all intermediate steps. If part of your codebase is unchanged since the last run, Pants reuses prior results to cut down build and test times. This design greatly accelerates repetitive tasks in both local development and CI.
  4. Monorepo Support and Cross-Team Collaboration Pants excels in larger codebases or monorepos where multiple services or apps live side by side. By analyzing imports and dependencies, Pants lets developers only run checks or tests relevant to changed files. This ensures teams don’t break each other’s code and can scale safely without excessive overhead or complicated publishing workflows.
  5. Multi-Language and Heterogeneous Environments While Python is a major focus, Pants also supports languages like Go, Java, Scala, Kotlin, Shell, and Docker. This is beneficial when you have microservices or components in multiple languages but want a single, coherent build tool.
  6. Supporting Packaging and Deployments (AWS Lambda, GCP, Docker) Pants can package code for AWS Lambda, Google Cloud Functions, or Docker images, helping you maintain many deployable artifacts from one codebase. You specify how to build each target once, and Pants takes care of packaging only what’s needed to produce minimal, consistent deploys.
  7. Adoption Without Overhauling Your Workflow Benjy emphasized that Pants is easy to adopt incrementally. You can begin with a small part of your project or basic tasks (e.g., test running, linting) and expand as you see the benefits. Teams often discover that adding more tools (like new linters or type-checkers) becomes trivial once Pants is in place.
  8. Dependency Inference and Lock Files Pants infers dependencies by examining your import statements, reducing the need for explicit “build metadata.” It also supports universal lock files, giving you stable, reproducible environments across teams. This approach safeguards against supply-chain issues and lowers friction for new developers on your team.
  9. Evolution from Pants v1 to Pants v2 Pants v2 is a full re-implementation focusing on Python first (with strong cross-language support). The engine is written in Rust, with a Python 3 async interface for extensibility. It’s also designed for broad community use instead of being specialized for a single large company’s monolithic codebase.
  10. Benefits for Both Large Enterprises and Small Teams One of the core themes Benjy highlighted is that a tool like Pants shouldn’t just be for tech giants. Whether you’re a 10-person startup or a 10,000-person organization, having a robust build system means saving time, preventing mistakes, and improving code quality.

Interesting Quotes and Stories

  • Benjy on childhood and coding: “It's absolutely unbelievable that your childhood hobby can become your grown-up profession. We get to do it all the time, for fun and for our jobs.”
  • On concurrency and caching: “The system can look at your code, look at the dependencies, perform all this analysis, and say, well, that means I actually need to invoke pytest on these tests. And if that means I need to first install pytest in a hermetic environment, I'll do that. Then everything is cached.”

Key Definitions and Terms

  • Monorepo: A single repository that holds the code and assets for multiple projects or services.
  • Hermetic Environment: A build or run environment sealed off from the rest of your system, ensuring consistent, reproducible results with no hidden dependencies.
  • Caching: Storing computed results so they can be reused rather than recalculated, thus speeding up subsequent runs.
  • Concurrency: Executing multiple tasks or checks in parallel, typically leveraging all CPU cores or even distributed systems.

Learning Resources

Overall Takeaway

Pants Build aims to bring top-tier build automation to every Python team—no matter its size. By harmonizing code checks, testing, packaging, and deployment under a single smart system, Pants reduces tedious work, speeds up feedback loops, and lets developers focus on delivering features confidently. It is an inclusive solution that handles single-language or multilingual projects, supports modern workflows like microservices and serverless, and can be adopted incrementally to fit any organization's culture.

Links from the show

Benjy on Twitter: @benjy
Pants Build: pantsbuild.org
Pants Source: github.com
Getting help in the Pants community: pantsbuild.org/docs/getting-help
An example repo to demonstrate Python support in Pants: github.com
Toolchain: toolchain.com
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon