https://pantsbuild.org/ logo
Join Slack
Powered by
# general
  • e

    elegant-park-52418

    06/25/2025, 6:19 PM
    qq, why does
    shell_command
    have the
    extra_env_vars
    field, but
    run_shell_command
    does not?
    h
    • 2
    • 4
  • h

    hundreds-carpet-28072

    06/26/2025, 1:44 PM
    Is it possible to have conditional pypi indexes? An example case for this is say a subset of our projects use private packages and hence need to pull from a private pypi repo. Ideally, the setup/auth required for doing so could be skipped if not needed i.e. if only touching parts of the dependency graph that use public packages. This would be especially useful for things like
    gcloud auth
    that I’m currently solving with a
    .pants.bootstrap
    step but this depends on the
    gcloud
    cli being available as well as the correct user auth. Skipping this where possible would improve builds times and reduce confusing errors when they’re not available.
  • s

    square-psychiatrist-19087

    06/26/2025, 1:53 PM
    I'm trying to run
    uv run
    inside
    shell_command
    , but it's failing trying to install kerberos with
    Copy code
    cc: fatal error: cannot execute 'as': execvp: No such file or directory
    any idea how to fix it?
    d
    • 2
    • 4
  • h

    high-psychiatrist-4761

    06/26/2025, 5:18 PM
    Do we have any real life python monorepo that uses pants in github? The example repo provided by pants official doc is too simple. I want to reference some real stuff. Does anyone know some? Thanks!
    h
    • 2
    • 1
  • h

    high-psychiatrist-4761

    06/26/2025, 5:32 PM
    Hi, I have some lint questions. I got the black failed report as follows.
    Copy code
    % pants lint ::
    10:28:33.91 [INFO] Completed: Format with Black - black made no changes.
    10:28:33.91 [INFO] Completed: Lint with Flake8 - flake8 succeeded.
    Partition: ['CPython<4.0,>=3.8']
    
    
    10:28:33.91 [INFO] Completed: Format with docformatter - docformatter made no changes.
    10:28:33.91 [WARN] Completed: Format with Black - black made changes.
      src/python/text_streaming_service/text_streaming_service.py
      test/python/tests/text_streaming_service/test_text_streaming_service.py
    10:28:33.92 [INFO] Completed: Format with isort - isort made no changes.
    
    ✕ black failed.
    ✓ docformatter succeeded.
    ✓ flake8 succeeded.
    ✓ isort succeeded.
    
    (One or more formatters failed. Run `pants fmt` to fix.)
    Then I run fmt:
    Copy code
    % pants fmt ::
    10:30:29.58 [WARN] Completed: Format with isort - isort made changes.
      src/python/text_streaming_service/text_streaming_service.py
      test/python/tests/text_streaming_service/test_text_streaming_service.py
    10:30:29.58 [INFO] Completed: Format with docformatter - docformatter made no changes.
    10:30:29.58 [WARN] Completed: Format with Black - black made changes.
      src/python/text_streaming_service/text_streaming_service.py
      test/python/tests/text_streaming_service/test_text_streaming_service.py
    10:30:29.58 [INFO] Completed: Format with Black - black made no changes.
    
    + black made changes.
    ✓ docformatter made no changes.
    + isort made changes.
    Then I ran
    pants lint ::
    again, but it still shows
    black failed
    . do you know why? And what the exact error black report?
    b
    c
    e
    • 4
    • 7
  • h

    high-yak-85899

    06/26/2025, 6:28 PM
    For pantsbuild internals, how does that fetch its third party dependencies? If I set
    [python-repos].indexes
    , will that get used for pants internals as well as the requirements we have in our repository?
    f
    • 2
    • 7
  • v

    victorious-wire-62055

    06/26/2025, 6:33 PM
    I'm looking for advice if folks have had to handle a python module + a script in the same folder. In my case this is for a build script / CI tool, so it doesn't share dependencies with the module in the same folder. What makes this trouble: pants assumes the
    __init__
    file in the same folder is a dependency of the script (as well as
    __init__
    files in parent folders, and I haven't found an invocation of
    !__init__.py
    in the BUILD file that changes this behavior.
    e
    • 2
    • 4
  • h

    high-psychiatrist-4761

    06/26/2025, 7:02 PM
    some question about
    namespace package
    . I have following project structure. I make
    src/python/some_package
    as namespace package. Then I do
    pants package src/python/some_package/package1:dist
    , it generate the whl and tar files. When I check the
    package1-0.1.0.dist-info/namespace_packages.txt
    inside the
    dist/package1-0.1.0-py3-none-any.whl
    , it is empty. I am wondering if pants support namespace package correctly?
    Copy code
    .
    ├── 3rdparty
    │   └── python
    │       └── python-default.lock
    ├── dist
    │   ├── package1-0.1.0-py3-none-any.whl
    │   └── package1-0.1.0.tar.gz
    ├── pants.toml
    ├── src
    │   └── python
    │       └── some_package
    │           ├── lib1
    │           │   ├── __init__.py
    │           │   ├── BUILD
    │           │   ├── lib1.py
    │           │   └── pyproject.toml
    │           ├── package1
    │           │   ├── __init__.py
    │           │   ├── BUILD
    │           │   ├── package1.py
    │           │   └── pyproject.toml
    │           └── package2
    │               ├── __init__.py
    │               ├── BUILD
    │               ├── package2.py
    │               └── pyproject.toml
    └── test
        └── python
            └── tests
                └── some_package
                    └── package1
                        ├── __init__.py
                        ├── BUILD
                        ├── pyproject.toml
                        └── test_package1.py
    h
    • 2
    • 23
  • s

    square-psychiatrist-19087

    06/26/2025, 9:55 PM
    Is it possible to avoid building pex every time I want to run a tool?
    h
    • 2
    • 12
  • h

    happy-kitchen-89482

    06/26/2025, 10:24 PM
    Hi folks, we’d like to release 2.27.0 soon, unless anyone has any bugs to report. So please try 2.27.0rc1 if you’re in a position to, and report issues. Thanks!
  • b

    brainy-parrot-55558

    06/26/2025, 10:28 PM
    is the https://www.pantsbuild.org/ website down?
    h
    w
    • 3
    • 15
  • v

    victorious-dress-47449

    06/26/2025, 11:23 PM
    Neat trick for those using
    direnv
    : you can write a script to export your virtualenvs for your IDE, have direnv run it and then get direnv to watch your lock files for any changes and re-run the export automatically. That way your IDE always has the latest dependencies and tools.
  • h

    high-yak-85899

    06/27/2025, 1:08 AM
    Why might pants be stuck downloading a new version of
    ruff
    ? It's been like this for a while, but if I click the link it downloads immediately.
  • m

    modern-smartphone-82928

    06/27/2025, 4:15 AM
    This configuration used to work, now we're suddenly receiving an error when trying to COPY pex to docker image, after fresh set of generate-lockfiles. Error
    Copy code
    Docker build failed for `docker_image` apps/program:program_docker_image. The apps/program/Dockerfile has `COPY` instructions for source files that may not have been found in the Docker build context.
    Dockerfile
    Copy code
    FROM python:3.10-slim as deps
    COPY apps.program/program_pex.pex /program_pex.pex
    RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /program_pex.pex venv --scope=deps --compile /program
    
    FROM python:3.10-slim as srcs
    COPY apps.program/program_pex.pex /program_pex.pex
    RUN PEX_TOOLS=1 /usr/local/bin/python3.10 /program_pex.pex venv --scope=srcs --compile /program
    BUILD
    Copy code
    docker_image(
      name="program_docker_image",
      repository="apps/program",
      image_tags=[],
      source="Dockerfile",
      dependencies=[],
      secrets = {
          "mynetrc": "~/.netrc",
      }
    )
    
    pex_binary(
        name="program_pex",
        entry_point="program.handler:main",
        resolve="python-program",
        layout="zipapp",
        include_tools=True,
        execution_mode="venv",
        dependencies=[],
        venv_site_packages_copies=True,
    )
    sandbox, shows that
    apps.program/program_pex.pex
    exists. Something changed around Docker build context?
    • 1
    • 1
  • h

    high-yak-85899

    06/27/2025, 3:08 PM
    Just curious if this is bug ticket worthy. In config files, I can use the interpolation like
    %(<http://env.MY|env.MY>_ENV_VAR)s
    successfully. I wanted to provide a default if it wasn't set and do something like
    %(<http://env.MY|env.MY>_ENV_VAR=none)s
    . This is valid syntax and it seems to parse and work fine, but it doesn't respect the environment variables set when this happens. I've only tested this on 2.24.0.
  • v

    victorious-wire-62055

    06/27/2025, 7:08 PM
    I'm getting an error when I have two parallel
    python_sources
    targets but no target named for the folder itself
    Copy code
    ResolveError: The address projects/hello_world:hello_world from the `dependencies` field of the target projects/hello_world/build.py:build does not exist.
    The
    BUILD
    file looks like this:
    Copy code
    python_sources(
        name="src-python"
        sources=[*python_sources.sources.default, "!build.py"],
    )
    
    python_sources(
        name="build",
        sources=["build.py"],
        overrides={
            "build.py": {"dependencies": ["!./__init__.py"]},
        },
    )
    If I remove the
    name
    from the first python_sources, that resolves the error, but
    pants peek
    on both the :build target and build.py do not show any dependency on the folder itself. What am I missing here?
    g
    • 2
    • 3
  • g

    gray-apple-79637

    06/27/2025, 8:29 PM
    i'm using the go package and getting this error. i'm on osx, pants version 2.19.0. how can i fix it?
    Copy code
    pants list services/gorilla --print-stacktrace -ldebug
    16:20:13.30 [INFO] Initialization options changed: reinitializing scheduler...
    16:20:13.54 [INFO] Scheduler initialized.
    16:20:14.09 [ERROR] 1 Exception encountered:
    
    Engine traceback:
      in select
        ..
      in pants.backend.project_info.list_targets.list_targets
        `list` goal
      in pants.engine.internals.specs_rules.resolve_addresses_from_specs
        Find targets from input specs
    
    Traceback (most recent call last):
      File "/Users/jacob.pusateri/Library/Caches/nce/8fb836cadd1e1f50180fea66b6acab1f23108e9a74f158744e706c6da41a534b/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/specs_rules.py", line 270, in resolve_addresses_from_specs
        includes, ignores = await MultiGet(
      File "/Users/jacob.pusateri/Library/Caches/nce/8fb836cadd1e1f50180fea66b6acab1f23108e9a74f158744e706c6da41a534b/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 404, in MultiGet
        return await _MultiGet((__arg0, __arg1))
      File "/Users/jacob.pusateri/Library/Caches/nce/8fb836cadd1e1f50180fea66b6acab1f23108e9a74f158744e706c6da41a534b/bindings/venvs/2.19.0/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 172, in __await__
        result = yield self.gets
    KeyError: 'Version'
    • 1
    • 3
  • s

    stale-waitress-56895

    06/28/2025, 12:47 PM
    Can I produce a pex with the whole content of a resolve? To use as a base image?
    e
    • 2
    • 1
  • b

    billions-sundown-65740

    06/30/2025, 6:29 AM
    Is it possible to select repositories/create tags based on the enviroment or env variable? I would like to tag/push docker images different based on the environment e.g. on the local machine images should have a dev tag and/or be pushed to a certain repo and in the CI/CD pipeline the same images should be tagged/pushed differently.
    e
    • 2
    • 1
  • m

    microscopic-knife-5995

    06/30/2025, 4:37 PM
    Module mapping from pattern? Hello team, I am looking through the Pants code base to see if I can register a
    module_pattern_mapping
    . Specifically I want to map
    prefix-some-library
    to
    some_library
    . It seems there are default module pattern mapping defined in the Python backend and
    python_requirements
    support custom module mapping. But am I right in that users cannot register custom module pattern mapping?
    h
    • 2
    • 11
  • b

    brash-honey-7160

    06/30/2025, 8:38 PM
    Hey y'all! Currently exploring Pants as a solution to help implement a Python monorepo... but am definitely hitting a few roadblocks, most notably with DevEx. My immediate use-cases are numerous: 1. Extracting copy-pasted library code across multiple repos into a library. 2. Pulling all those repos (each with 1 or more AWS Lambdas) into the monorepo. 3. Creating better E2E test suites integrating workflows across microservices locally with mocked external dependencies, to circumvent lengthy E2E test cycles running AWS with stateful external dependencies. 4. Consolidating AWS CDK codebases to be able to dynamically import relevant CDK dependencies from one stack, into another stack. 5. Being able to run AWS CDK applications to synth and deploy AWS resources including Lambdas (which have a particularly strange requirement in terms of building source to a local directory before upload). • I'm curious if there's some CLI features that allows
    tailor
    to be run such that it actually writes the dependencies (for things like python libraries of a python source) to the BUILD file...? I'm struggling to see why it's a good pattern to have everything inferred in the CLI without any static output that can be searched, verified, etc. without having to run
    peek
    . • I'm confused how Pants works with Venvs or lockfiles... how does Pants know what versions of python or packages to use? How does it know which python executable to use? Does it make a Venv under the hood? I'm not familar with Pex, so maybe I'm missing something here... but I'm having a bit of trouble understanding how to transition from a Venv+Poetry+Make approach, to Pants. • What sort of development workflow would Pants ultimately allow me to have? For example, if I update a library version, would it have a command to say "run all the tests that transitively depend on [updated package]"? If I update a library used by multiple microservices, I can use the change detection to deploy those services? Please forgive my utter dismay and confusion, as I'm still just scratching the surface of this tool and have little to no support from my team so I'm shooting in the dark on this. I've never used a monorepo tool in JS/TS or any other language/framework, so I'm still trying to wrap my head around this approach (versus libraries). Thanks in advance for any and all information anyone can provide here!
    👀 1
    m
    h
    h
    • 4
    • 13
  • b

    broad-processor-92400

    07/01/2025, 1:51 AM
    👖 Pants 2.27 is released! 👖 If you missed the announcement in #C18RRR4JK, the latest stable release is now available. See https://www.pantsbuild.org/blog/2025/06/30/pants-2-27 for what's in it
    🚀 1
    👖 2
    v
    • 2
    • 1
  • h

    high-magician-46188

    07/01/2025, 7:47 AM
    Hi, (context:) I'm working on optimizing the CI speed and my current bottleneck seems to be building the Python Wheels. In my current setup, I use Pants to build the Wheels and then directly (w/o Pants) run a
    docker build
    command that copies the wheels and installs them. My question is: can I build Docker images for Python projects with Pants in a way that will skip building the Wheels? (building the Wheels takes around 2.5 minutes)
    d
    • 2
    • 3
  • b

    broad-ability-40758

    07/01/2025, 12:46 PM
    What's the easiest way to add a custom argument that alters the build? I want to be able to include/exclude
    python_requirements
    based on whether GPUs are available (via a cli argument/env var/similar) but it's not immediately obvious to me how to accomplish that
    d
    • 2
    • 5
  • b

    brainy-parrot-55558

    07/01/2025, 3:32 PM
    We bumped the pants version to 2.27 just now, and started getting
    http2: response body closed
    during the CI. We are using Bazel remote cache in Namespace.so (and running in their GH Action Runners)
    15:30:10.83 [WARN] Failed to read from remote cache (64 occurrences so far): Unknown: "http2: response body closed"
    h
    • 2
    • 2
  • a

    adorable-psychiatrist-59834

    07/01/2025, 7:31 PM
    Just noticed 2.25 is marked deprecated. Is there a pants command or script i can use to check this within my repo? I'm on 2.25.1 I'd love to be able to have it become noisy on deprecation/unsupported.
  • m

    microscopic-knife-5995

    07/01/2025, 8:58 PM
    🧵 generate-lockfile and uv pip compile hello folks, I just thought I would share a little hack I use for people facing long delays when generating lockfiles or people who run into runtime exceptions even after generating one. The Problem I have a mid-size monorepo with dependencies such as PyTorch, vLLM, TensorFlow etc. I value reproducibility and use
    pants generate-lockfiles
    but as the repo grows it is taking longer and longer for the command to finish. On top of that even when the resolve finishes, I get PyTorch errors at run time (see thread). Pragmatic solution The pragmatic solution that I came up with is disable
    enable_resolves = true
    in
    pants.toml
    and use
    uv pip compile --universal
    to generate a lock file. Then I use this generated lock file in
    python_requirements
    . This approach isn't as strict as directly using
    pants generate-lockfiles
    .
    uv pip compile
    functionality is a subset of
    pants generate-lockfiles
    but I made this pragmatic trade off because the reality I face living in Python AI/ML ecosystem. I hope this helps other folks who are prisoners of PyTorch. Questions and feedback I have been doing this for a while and haven't encountered any issues. Maybe a Pants dev will shake their head and say "no no"? What could be a potential drawback of this approach?
    h
    b
    • 3
    • 16
  • s

    steep-eve-20716

    07/01/2025, 9:56 PM
    Fun fact: If you google "Pants advanced filtering", you get results for fart-filtering underwear 😂 💀
    w
    • 2
    • 1
  • p

    powerful-scooter-95162

    07/02/2025, 7:02 PM
    How do people manage dependencies not ballooning out of control and making all binaries huge?
    c
    w
    +2
    • 5
    • 4
  • w

    wide-midnight-78598

    07/03/2025, 5:42 PM
    👖 The docs just got a bug fix on https://www.pantsbuild.org/spotlight/users which fixes a broken link to https://github.com/pantsbuild/pants/issues/new?template=user_registration.yml in order to have your company featured on a public list of Pants Users. In case that was holding you back, now's a great time to add your company to our list of users! 👖