elegant-park-52418
06/25/2025, 6:19 PMshell_command
have the extra_env_vars
field, but run_shell_command
does not?hundreds-carpet-28072
06/26/2025, 1:44 PMgcloud 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.square-psychiatrist-19087
06/26/2025, 1:53 PMuv run
inside shell_command
, but it's failing trying to install kerberos with
cc: fatal error: cannot execute 'as': execvp: No such file or directory
any idea how to fix it?high-psychiatrist-4761
06/26/2025, 5:18 PMhigh-psychiatrist-4761
06/26/2025, 5:32 PM% 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:
% 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?high-yak-85899
06/26/2025, 6:28 PM[python-repos].indexes
, will that get used for pants internals as well as the requirements we have in our repository?victorious-wire-62055
06/26/2025, 6:33 PM__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.high-psychiatrist-4761
06/26/2025, 7:02 PMnamespace 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?
.
├── 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
square-psychiatrist-19087
06/26/2025, 9:55 PMhappy-kitchen-89482
06/26/2025, 10:24 PMbrainy-parrot-55558
06/26/2025, 10:28 PMvictorious-dress-47449
06/26/2025, 11:23 PMdirenv
: 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.high-yak-85899
06/27/2025, 1:08 AMruff
? It's been like this for a while, but if I click the link it downloads immediately.modern-smartphone-82928
06/27/2025, 4:15 AMDocker 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
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
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?high-yak-85899
06/27/2025, 3:08 PM%(<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.victorious-wire-62055
06/27/2025, 7:08 PMpython_sources
targets but no target named for the folder itself
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:
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?gray-apple-79637
06/27/2025, 8:29 PMpants 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'
stale-waitress-56895
06/28/2025, 12:47 PMbillions-sundown-65740
06/30/2025, 6:29 AMmicroscopic-knife-5995
06/30/2025, 4:37 PMmodule_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?brash-honey-7160
06/30/2025, 8:38 PMtailor
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!broad-processor-92400
07/01/2025, 1:51 AMhigh-magician-46188
07/01/2025, 7:47 AMdocker 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)broad-ability-40758
07/01/2025, 12:46 PMpython_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 thatbrainy-parrot-55558
07/01/2025, 3:32 PMhttp2: 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"
adorable-psychiatrist-59834
07/01/2025, 7:31 PMmicroscopic-knife-5995
07/01/2025, 8:58 PMpants 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?steep-eve-20716
07/01/2025, 9:56 PMpowerful-scooter-95162
07/02/2025, 7:02 PMwide-midnight-78598
07/03/2025, 5:42 PM