seeing a random test failure on mac os
# development
p
seeing a random test failure on mac os
Copy code
➜  pants git:(master) ./pants test src/python/pants/backend/awslambda/python/rules_test.py
17:28:46.83 [WARN] Completed: test - src/python/pants/backend/awslambda/python/rules_test.py:tests failed (exit code 2).
============================= test session starts ==============================
collected 0 items / 1 error

==================================== ERRORS ====================================
___ ERROR collecting src/python/pants/backend/awslambda/python/rules_test.py ___
ImportError while importing test module '/private/var/folders/hv/p6g7p3p95d19gtm5cfkrk5w00000gn/T/process-executionK3lTUS/src/python/pants/backend/awslambda/python/rules_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/python/pants/backend/awslambda/python/rules_test.py:11: in <module>
    from pants.backend.awslambda.python.rules import PythonAwsLambdaFieldSet
src/python/pants/backend/awslambda/python/rules.py:8: in <module>
    from pants.backend.awslambda.python.target_types import (
src/python/pants/backend/awslambda/python/target_types.py:10: in <module>
    from pants.backend.python.dependency_inference.rules import PythonInferSubsystem, import_rules
src/python/pants/backend/python/dependency_inference/rules.py:8: in <module>
    from pants.backend.python.dependency_inference import import_parser, module_mapper
src/python/pants/backend/python/dependency_inference/import_parser.py:6: in <module>
    from pants.backend.python.util_rules.pex import PexInterpreterConstraints
src/python/pants/backend/python/util_rules/pex.py:29: in <module>
    from pants.backend.python.util_rules import pex_cli
src/python/pants/backend/python/util_rules/pex_cli.py:11: in <module>
    from pants.backend.python.util_rules import pex_environment
src/python/pants/backend/python/util_rules/pex_environment.py:12: in <module>
    from pants.engine import process
src/python/pants/engine/process.py:14: in <module>
    from pants.base.exception_sink import ExceptionSink
src/python/pants/base/exception_sink.py:16: in <module>
    import setproctitle
E   ImportError: dlopen(/Users/asher/.cache/pants/named_caches/pex_root/venvs/74f365d60a447da8b8ba705c2b638745f9895556/499a9c6b888ba9d1ec95e7cf1be04097c8ac3633/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
E     Referenced from: /Users/asher/.cache/pants/named_caches/pex_root/venvs/74f365d60a447da8b8ba705c2b638745f9895556/499a9c6b888ba9d1ec95e7cf1be04097c8ac3633/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
E     Expected in: flat namespace
E    in /Users/asher/.cache/pants/named_caches/pex_root/venvs/74f365d60a447da8b8ba705c2b638745f9895556/499a9c6b888ba9d1ec95e7cf1be04097c8ac3633/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
=========================== short test summary info ============================
ERROR src/python/pants/backend/awslambda/python/rules_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.93s ===============================



𐄂 src/python/pants/backend/awslambda/python/rules_test.py:tests failed.
➜  pants git:(master)
this is on a clean main pants branch
Screen Shot 2021-04-28 at 5.30.50 PM.png
h
Hm, the native extension for setproctitle isn't working properly. You can try removing
~/.cache/pants/named_caches/pex/
(or better is to temporarily rename so we can debug)
p
same
h
Did you recently do an OS upgrade by chance?
p
yes. updated to bigsur over the weekend.
Screen Shot 2021-04-28 at 6.06.14 PM.png
h
Okay this is almost certainly why it broke. Could you please try now to rename
~/.cache/pants
to something like
pants2
? I realized named_caches prob isn't enough because of the LMDB store cache. Also temporarily turn off the remote cache
p
I'll just nuke lmdb store...
same error
h
to confirm, did it re-resolve your requirements? Make sure remote cache is not used
p
let me disable remote cache and try again.
Screen Shot 2021-04-28 at 6.49.57 PM.png
same error,
Copy code
➜  pants git:(master) rm -rf ~/.cache/pants/lmdb_store
➜  pants git:(master) rm -rf ~/.cache/pants/named_caches
➜  pants git:(master) ./pants --no-remote-cache-read test src/python/pants/backend/awslambda/python/rules_test.py
18:49:21.04 [INFO] initialization options changed: reinitializing scheduler...
18:49:24.05 [INFO] scheduler initialized.
18:50:17.07 [INFO] Completed: Building pytest.pex with 6 requirements: ipdb, pygments, pytest-cov>=2.10.1,<2.12, pytest-html, pytest-icdiff, pytest>=6.0.1,<6.3
18:50:44.16 [INFO] Completed: Resolving 3rdparty/python/constraints.txt
18:50:49.08 [INFO] Completed: Building requirements.pex with 11 requirements: PyYAML<5.5,>=5.4, ansicolors==1.1.8, humbug==0.1.9, packaging==20.9, pex==2.1.41, psutil==5.8.0, pytest<6.3,>=6.0.1, setproctitle==1.2.2, setuptools<54.... (52 characters truncated)
18:50:55.67 [INFO] Completed: Building pytest_runner.pex
18:50:58.64 [WARN] Completed: test - src/python/pants/backend/awslambda/python/rules_test.py:tests failed (exit code 2).
============================= test session starts ==============================
collected 0 items / 1 error

==================================== ERRORS ====================================
___ ERROR collecting src/python/pants/backend/awslambda/python/rules_test.py ___
ImportError while importing test module '/private/var/folders/hv/p6g7p3p95d19gtm5cfkrk5w00000gn/T/process-executionXhd03V/src/python/pants/backend/awslambda/python/rules_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/python/pants/backend/awslambda/python/rules_test.py:11: in <module>
    from pants.backend.awslambda.python.rules import PythonAwsLambdaFieldSet
src/python/pants/backend/awslambda/python/rules.py:8: in <module>
    from pants.backend.awslambda.python.target_types import (
src/python/pants/backend/awslambda/python/target_types.py:10: in <module>
    from pants.backend.python.dependency_inference.rules import PythonInferSubsystem, import_rules
src/python/pants/backend/python/dependency_inference/rules.py:8: in <module>
    from pants.backend.python.dependency_inference import import_parser, module_mapper
src/python/pants/backend/python/dependency_inference/import_parser.py:6: in <module>
    from pants.backend.python.util_rules.pex import PexInterpreterConstraints
src/python/pants/backend/python/util_rules/pex.py:29: in <module>
    from pants.backend.python.util_rules import pex_cli
src/python/pants/backend/python/util_rules/pex_cli.py:11: in <module>
    from pants.backend.python.util_rules import pex_environment
src/python/pants/backend/python/util_rules/pex_environment.py:12: in <module>
    from pants.engine import process
src/python/pants/engine/process.py:14: in <module>
    from pants.base.exception_sink import ExceptionSink
src/python/pants/base/exception_sink.py:16: in <module>
    import setproctitle
E   ImportError: dlopen(/Users/asher/.cache/pants/named_caches/pex_root/venvs/739a8cc0124c3cddb24a6f5ce816de42f81cca21/f3bf77d2aa2b64ffc6615072af3996709ad81904/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
E     Referenced from: /Users/asher/.cache/pants/named_caches/pex_root/venvs/739a8cc0124c3cddb24a6f5ce816de42f81cca21/f3bf77d2aa2b64ffc6615072af3996709ad81904/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
E     Expected in: flat namespace
E    in /Users/asher/.cache/pants/named_caches/pex_root/venvs/739a8cc0124c3cddb24a6f5ce816de42f81cca21/f3bf77d2aa2b64ffc6615072af3996709ad81904/lib/python3.8/site-packages/setproctitle.cpython-38-darwin.so
=========================== short test summary info ============================
ERROR src/python/pants/backend/awslambda/python/rules_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 1.41s ===============================



𐄂 src/python/pants/backend/awslambda/python/rules_test.py:tests failed.
➜  pants git:(master)
c
Triaging this as working on my machine, recently updated to 11.3 as well…
Copy code
✓ src/python/pants/backend/awslambda/python/rules_test.py:tests succeeded.
on clean main,
Copy code
commit fbed3e15e4ba4c5e5e83a37c1fd932e5bd9734d4 (HEAD -> refs/heads/main, refs/remotes/upstream/main)
Author: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Date:   Wed Apr 28 17:38:31 2021 -0700
(did not clean out any cache or other data from previous runs…)
h
Hm maybe I should update to 11.3 too to reproduce
@polite-garden-50641 could you try running this please?
Copy code
❯ pex setproctitle
Python 3.9.4 (default, Apr  4 2021, 17:42:23)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import setproctitle
It'd be great to isolate this to Pex if possible and remove the variable of Pants
p
afk rn, will try as soon as I’m back
Screen Shot 2021-04-29 at 1.33.02 PM.png
how do i get pex in my path ?
h
I personally like to use pipx to install Pex. https://pypi.org/project/pipx/ But you can also do `pip install pex`: https://github.com/pantsbuild/pex#installation
p
Screen Shot 2021-04-29 at 2.02.48 PM.png
h
Thank you. Now can you please try with
--interpreter-constraint='CPython==3.8.*'
included, given that you were using Py38 with Pants?
p
on which scope ?
Screen Shot 2021-04-29 at 2.10.28 PM.png
h
This is using Pex,
pex --interpreter-constraint='CPython==3.8.*' setproctitle
, then trying to import in the repl
p
Screen Shot 2021-04-29 at 2.12.50 PM.png
h
Great! That's what I was hoping would happen. It looks like setproctitle is broken on the new macOS and Python 3.8. This is not a Pants bug This is relevant: https://github.com/dvarrazzo/py-setproctitle/issues/82. The linked StackOverflow post suggets reinstalling your Python
👍 1