acceptable-balloon-2043
03/10/2025, 11:48 AMpants lint :: while I'm inside an activated conda environment calculates for a bit, and then running it again returns the result instantly from cache as expected. If I deactivate the conda environment, the same call starts calculating everything from the beginning. What changed for pants between these two runs to invalidate the cache between them if the python itself is hermetic and nothing else changed in the shell (PATH changed, but does that matter?) ?broad-processor-92400
03/19/2025, 10:50 PMpants.toml? For this sort of question, I'd be particularly looking for any environment variables that are intentionally propagated into sandboxes.
Alternatively/additionally, run with pants --keep-sandboxes=always lint :: and then look at the __run.sh files in the sandbox. They should have a env -i SOME_ENV=... ... command within them that indicates explicitly what the env vars used are, and thus they can be compared.acceptable-balloon-2043
03/20/2025, 8:06 AMpants.toml that looks like something affecting environment variables.
Looking at the sandboxes, the lint execution itself doesn't have any env variables that could cause it but... sandbox for Find interpreter for constraints: CPython==3.12.* and sandbox for building the pylint_runner itself have env -i CPPFLAGS='' LANG=en_US.UTF-8 LDFLAGS='' PATH=$ with my whole PATH variable after it (which changes when you go in and out of virtualenvs of course).
Is this expected or some configuration I have is causing the PATH to be included there?broad-processor-92400
03/20/2025, 10:03 PMif python_providers: ... branch that avoids the Get(..., PexCliProcess(...)) search below.
Can you share your pants.toml?acceptable-balloon-2043
03/21/2025, 10:31 AMFind interpreter for constraints: CPython==3.12.* disappears when using python build standalone, but both Building 6 requirements for pylint.pex and Determine distributions found in pylint.pex still use PATH in it's run.sh
Our pants.toml is pretty big so I can try to give you relevant sections, but if i'm missing something tell me:
[GLOBAL]
pants_version = "2.25.0"
# <https://www.pantsbuild.org/stable/docs/getting-started/initial-configuration#enable-backends>
backend_packages = [
"pants.backend.python",
"pants.backend.python.providers.experimental.python_build_standalone",
"pants.backend.plugin_development",
"pants.backend.python.lint.isort",
"pants.backend.python.lint.black",
"pants.backend.python.lint.pylint",
"pants.backend.python.lint.pyupgrade",
"pants.backend.python.lint.flake8",
"pants.backend.awslambda.python",
"pants.backend.build_files.fmt.black",
"pants.backend.shell",
"pants.backend.experimental.python",
"pants.backend.experimental.tools.yamllint",
"pants.backend.experimental.adhoc",
"progressive_mypy",
]
pythonpath = ["%(buildroot)s/pants_plugins"]
[DEFAULT]
CONST_PYTHON_VERSION = "3.12.*" # Should be aligned with the version in `.python-version`
CONST_PANTS_PYTHON_VERSION = "3.11.*" # Should be aligned with the version in macros PANTS_PLUGIN_INTERPRETER_CONSTRAINTS
[python]
interpreter_constraints = ["==%(CONST_PYTHON_VERSION)s"]
enable_resolves = true
default_resolve = "python-default"
[python.resolves]
pants-plugins = "toolchain/lockfiles/pants-plugins.lockfile"
python-default = "toolchain/lockfiles/python-default.lockfile"
[python.resolves_to_interpreter_constraints]
python-default = ["==%(CONST_PYTHON_VERSION)s"]
pants-plugins = ["==%(CONST_PANTS_PYTHON_VERSION)s"]
[pylint]
config = "toolchain/config/.pylintrc"
install_from_resolve = "python-default"
requirements = [
"//ml_framework/ml_framework/core/requirements:reqs-ml#pylint",
]
source_plugins = [
"pylint_plugins:pylint_plugins",
]
progressive_mypy is a custom mypy plugin that is unrelated to lint goalacceptable-balloon-2043
03/21/2025, 10:37 AMexample-python repo with the only change of adding :
diff --git a/pants.toml b/pants.toml
index 937067c..8a778af 100644
--- a/pants.toml
+++ b/pants.toml
@@ -6,6 +6,7 @@ pants_version = "2.25.0rc0"
backend_packages.add = [
"pants.backend.build_files.fmt.black",
"pants.backend.python",
+ "pants.backend.python.providers.experimental.python_build_standalone",
"pants.backend.python.lint.docformatter",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
and running pants --keep-sandboxes=always lint --only=flake8 helloworld/greet/greeting.py; The run.sh in sandbox for for Building flake8.pex from <resource://pants.backend.python.lint.flake8/flake8.lock> also has my entire PATHbroad-processor-92400
03/24/2025, 2:14 AM<PATH> . If I clear it explicitly, the repo seems to be behave better:
[pex]
executable_search_paths = []acceptable-balloon-2043
03/24/2025, 10:02 AMexample-python now yields for me:
env -i CPPFLAGS='' LANG=en_US.UTF-8 LDFLAGS='' PATH='' PEX_IGNORE_RCFILES=true PEX_PYTHON=/Users/kris.tashkov/Library/Caches/nce/8fb836cadd1e1f50180fea66b6acab1f23108e9a74f158744e706c6da41a534b/bindings/venvs/2.25.0rc0/bin/python3.11 PEX_ROOT=.cache/pex_root /Users/kris.tashkov/Library/Caches/nce/8fb836cadd1e1f50180fea66b6acab1f23108e9a74f158744e706c6da41a534b/bindings/venvs/2.25.0rc0/bin/python3.11 ./pex --tmpdir .tmp --jobs 12 --no-emit-warnings --pip-version 24.2 --python-path 'path is here again' --output-file flake8.pex --venv prepend --seed verbose --venv-site-packages-copies --python /Users/kris.tashkov/.cache/pants/named_caches/python_build_standalone/3.9.21/bin/python3 --console-script flake8 --no-pre-install-wheels $'--sources-directory=source_files' --lock flake8.lock --no-pypi $'--index=<https://pypi.org/simple/>' --manylinux manylinux2014 --layout packed
with --python-path also containing entries from my current path including the current conda env 😭broad-processor-92400
03/24/2025, 6:13 PMacceptable-balloon-2043
03/24/2025, 7:40 PMmypy 's result is never cached and it's always ran from scratch. Is this normal or something else I have misconfigured?broad-processor-92400
03/24/2025, 8:33 PMpants check :: && pants check ::acceptable-balloon-2043
03/24/2025, 8:40 PMYeah, it does seem like an easy-to-miss sharp edge. Could you file a ticket? At the very least, we can improve documentation (but preferably behaviour, of course).will do
Re mypy: does it run from scratch even if you make no code changes, egyep, always reruns. Since it's one big batch of 3000+ files I always thought it's something related to size, but now I'm starting to question it.pants check :: && pants check ::
acceptable-balloon-2043
03/24/2025, 9:15 PMLC_CTYPE=UTF-8 to the requirements building run.sh while running it through iterm2 adds LANG=en_US.UTF-8 . This leaks from the terminal I call it from (iterm2 sets one, while the terminal of pycharm seems to set another) but it's interesting that this is enough for the cache not to match 😄
Beside unifying it on my local machine (and adding it to a README for others) e.g setting iterm2 to use posix format for locale, , is there anything I can do on the pants.toml side to unify this?broad-processor-92400
03/24/2025, 10:12 PMyep, always reruns. Since it's one big batch of 3000+ files I always thought it's something related to size, but now I'm starting to question it.Hm, strange. Mypy is a bit special in that it needs to see the whole "world", and thus changing any file in a given resolve will have pants re-run the process (theoretically with mypy using its own internal cache)... but changing no files at all should still be cached. Are you observing this re-run with your custom
progressive_mypy backend? If so, there might be some inconsistencies in that backend (e.g. randomly ordered CLI args, including a timestamp, ...)?acceptable-balloon-2043
03/24/2025, 10:13 PMbroad-processor-92400
03/24/2025, 10:13 PMLC_CTYPE and `LANG`: https://www.pantsbuild.org/stable/reference/subsystems/subprocess-environment#env_vars ... so many random env var-controlling options!acceptable-balloon-2043
03/24/2025, 10:49 PMpants lint :: works, pants package now can't find a python since I guess it doesn't use the python provider backend (and I've removed all the PATH variables so it can't find the system one)broad-processor-92400
03/25/2025, 4:29 AMacceptable-balloon-2043
03/25/2025, 7:03 AMacceptable-balloon-2043
03/25/2025, 7:36 AM