cool-easter-32542
05/15/2023, 8:21 PMnamed_caches_dir to a directory that is .gitignored results in python import errors and general whacky behavior. Using named_caches_dir within the git repo is sometimes used in CI, where GitLab for example is cranky about caching files outside of what the call the "build root".
I've extracted a smallish if not minimal case at: https://github.com/cburroughs/example-python/tree/crazy-cache
$ pants --no-pantsd --no-local-cache test ::
<snip>
✓ helloworld/greet/greeting_test.py:tests succeeded in 12.88s.
✓ helloworld/translator/bar_test.py:tests_py310 succeeded in 8.67s.
✓ helloworld/translator/bar_test.py:tests_py37 succeeded in 1.07s.
✓ helloworld/translator/foo_test.py:tests_py310 succeeded in 5.39s.
✓ helloworld/translator/foo_test.py:tests_py37 succeeded in 6.11s.
✓ helloworld/translator/translator_test.py:tests_py310 succeeded in 1.46s.
✓ helloworld/translator/translator_test.py:tests_py37 succeeded in 1.02s.
```
$ PANTS_CONFIG_FILES=pants.ci.toml pants --no-pantsd --no-local-cache test ::
155421.95 [INFO] Starting: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155422.16 [INFO] Starting: Installing python-3.7.lock for the resolve def37
155422.19 [INFO] Canceled: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155422.19 [INFO] Starting: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155422.60 [INFO] Starting: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155422.84 [INFO] Starting: Installing python-default.lock for the resolve default
155505.50 [INFO] Completed: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155506.51 [INFO] Completed: Building pytest.pex from resource://pants.backend.python.subsystems/pytest.lock
155545.28 [INFO] Long running tasks:
82.43s Installing python-default.lock for the resolve default
83.12s Installing python-3.7.lock for the resolve def37
155615.34 [INFO] Long running tasks:
112.50s Installing python-default.lock for the resolve default
113.19s Installing python-3.7.lock for the resolve def37
155645.39 [INFO] Long running tasks:
142.55s Installing python-default.lock for the resolve default
143.23s Installing python-3.7.lock for the resolve def37
155715.45 [INFO] Long running tasks:
172.61s Installing python-default.lock for the resolve default
173.30s Installing python-3.7.lock for the resolve def37
155745.50 [INFO] Long running tasks:
202.65s Installing python-default.lock for the resolve default
203.34s Installing python-3.7.lock for the resolve def37
155815.53 [INFO] Long running tasks:
232.69s Installing python-default.lock for the resolve default
233.38s Installing python-3.7.lock for the resolve def37
155845.59 [INFO] Long running tasks:
262.74s Installing python-default.lock for the resolve default
263.43s Installing python-3.7.lock for the resolve def37
155915.66 [INFO] Long running tasks:
292.82s Installing python-default.lock for the resolve default
293.50s Installing python-3.7.lock for the resolve def37
155945.69 [INFO] Long running tasks:
322.85s Installing python-default.lock for the resolve default
323.54s Installing python-3.7.lock for the resolve def37
160015.73 [INFO] Long running tasks:
352.89s Installing python-default.lock for the resolve default
353.58s Installing python-3.7.lock for the resolve def37
160045.78 [INFO] Long running tasks:
382.93s Installing python-default.lock for the resolve default
383.62s Installing python-3.7.lock for the resolve def37
160103.04 [INFO] Completed: Installing python-default.lock for the resolve default
160103.05 [INFO] Starting: Building requirements.pex from python-default.lock
160103.08 [INFO] Canceled: Building requirements.pex from python-default.lock
160103.08 [INFO] Starting: Building requirements.pex from python-default.lock
160115.19 [INFO] Completed: Installing python-3.7.lock for the resolve def37
160115.20 [INFO] Starting: Building requirements.pex from python-3.7.lock
160115.24 [INFO] Canceled: Building requirements.pex from python-3.7.lock
160116.17 [INFO] Starting: Building requirements.pex from python-3.7.lock
160209.09 [INFO] Completed: Building requirements.pex from python-default.lock
160209.09 [INFO] Starting: Building local_dists.pex
160210.26 [INFO] Completed: Building requirements.pex from python-3.7.lock
160210.27 [INFO] Starting: Building local_dists.pex
160211.12 [INFO] Completed: Building local_dists.pex
160211.17 [INFO] Starting: Building pytest_runner.pex
160224.47 [INFO] Completed: Building local_dists.pex
160224.47 [INFO] Starting: Building pytest_runner.pex
160307.49 [INFO] Completed: Building pytest_runner.pex
160346.39 [INFO] Long running tasks:
81.91s Building pytest_runner.pex
160355.03 [INFO] Completed: Run Pytest - helloworld/translator/bar_test.py:tests_py310 - succeeded.
160355.03 [INFO] Completed: Run Pytest - helloworld/translator/translator_test.py:tests_py310 - succeeded.
160414.52 [INFO] Completed: Run Pytest - helloworld/greet/greeting_test.py:tests - succeeded.
160414.53 [INFO] Completed: Building pytest_runner.pex
160510.93 [ERROR] Completed: Run Pytest - helloworld/translator/foo_test.py:tests_py310 - failed (exit code 2).
============================= test session starts ==============================
collecting ... collected 0 items / 1 error
==================================== ERRORS ====================================
______________ ERROR collecting helloworld/translator/foo_test.py ______________
helloworld/translator/foo_test.py1 in <module>
from airflow.models import Variable
/home/ecsb/src/o/example-python/.cache/pants/named_caches/pex_root/venvs/s/fd2f0f00/venv/lib/python3.10/site-packages/airflow/__init__.py34 in <module>
from airflow import settings
/home/ecsb/src/o/example-python/.cache/pants/named_caches/pex_root/venvs/s/fd2f0f00/venv/lib/python3.10/site-packages/airflow/settings.py43 in <module>
TIMEZONE = pendulum.tz.timezone('UTC')
E AttributeError: module 'pendulum' has no attribute 'tz'
=============================== warnings summary ===============================
../../home/ecsb/src/o/example-python/.cache/pants/named_caches/pex_root/venvs/s/fd2f0f00/venv/lib/python3.10/site-packages/airflow/configuration.py:270
/home/ecsb/src/o/example-python/.cache/pants/named_caches/pex_root/venvs/s/fd2f0f00/venv/lib/python3.10/site-packages/airflow/configuration.py270 DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.version import StrictVersion
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: /tmp/pants-sandbox-om6ajE/helloworld.translator.foo_test.py.tests_py310.xml -
=========================== short test summary info ============================
ERROR helloworld/translator/foo_test.py - AttributeError: module 'pendulum' h...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
========================= 1 warning, 1 error in 5.42s ==========================
160513.54 [INFO] Completed: Run Pytest - helloworld/translator/translator_test.py:tests_py37 - succeeded.
160513.68 [INFO] Completed: Run Pytest - helloworld/translator/bar_test.py:tests_py37 - succeeded.
160516.53 [INFO] Long running tasks:
61.98s Run Pytest for helloworld/translator/foo_test.py:tests_py37
160516.92 [INFO] Completed: Run Pytest - helloworld/translator/foo_test.py:tests_py37 - succeeded.
✓ helloworld/greet/greeting_test.py:tests succeeded in 19.68s.
✓ helloworld/translator/bar_test.py:tests_py…
pantsbuild/pants