https://pantsbuild.org/ logo
#general
Title
# general
w

wide-midnight-78598

05/11/2022, 10:09 PM
Any thoughts on why I would be getting
symbol not found
error when using the
RuleRunner
? I ran into this in the past and just kinda assumed it wasn't a big deal, but on a different computer, same error. Even more specifically, why is my XCode Python3.8 library used in here, when I'm pointing my environment (and everything else) at homebrew's 3.9?
Copy code
pants % ./pants test src/python/pants/backend/python/lint/black/rules_integration_test.py
18:00:56.67 [ERROR] Completed: Run Pytest - src/python/pants/backend/python/lint/black/rules_integration_test.py:rules_integration_test failed (exit code 2).
============================= test session starts ==============================
collected 0 items / 1 error

==================================== ERRORS ====================================
_ ERROR collecting src/python/pants/backend/python/lint/black/rules_integration_test.py _
ImportError while importing test module '/private/var/folders/2y/y_j1jxgn3tj5rb67_gjb7v700000gn/T/process-executionpSyKcR/src/python/pants/backend/python/lint/black/rules_integration_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/python/lint/black/rules_integration_test.py:10: in <module>
    from pants.backend.python import target_types_rules
src/python/pants/backend/python/target_types_rules.py:18: in <module>
    from pants.backend.python.dependency_inference.module_mapper import (
src/python/pants/backend/python/dependency_inference/module_mapper.py:21: in <module>
    from pants.backend.python.subsystems.setup import PythonSetup
src/python/pants/backend/python/subsystems/setup.py:19: in <module>
    from pants.option.subsystem import Subsystem
src/python/pants/option/subsystem.py:12: in <module>
    from pants.engine.internals.selectors import AwaitableConstraints, Get
src/python/pants/engine/internals/selectors.py:14: in <module>
    from pants.engine.internals.native_engine import (
E   ImportError: dlopen(/private/var/folders/2y/y_j1jxgn3tj5rb67_gjb7v700000gn/T/process-executionpSyKcR/src/python/pants/engine/internals/native_engine.so, 0x0002): symbol not found in flat namespace '_PyCMethod_New'
- generated xml file: /private/var/folders/2y/y_j1jxgn3tj5rb67_gjb7v700000gn/T/process-executionpSyKcR/src.python.pants.backend.python.lint.black.rules_integration_test.py.rules_integration_test.xml -
=========================== short test summary info ============================
ERROR src/python/pants/backend/python/lint/black/rules_integration_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.46s ===============================



✕ src/python/pants/backend/python/lint/black/rules_integration_test.py:rules_integration_test failed in 1.50s.
1
w

witty-crayon-22786

05/11/2022, 10:23 PM
what are the interpreter_constraints for your repository? and do you set your search path to exclude interpreters which match the constraints but which you do not want? https://blog.pantsbuild.org/choosing-a-python-interpreter-for-a-pants-project/
w

wide-midnight-78598

05/11/2022, 11:54 PM
Thanks Stu, I don't explicitly exclude anything, but I've been setting my environment to target the correct one while building pants mainline. Seems to be working, but falls over specifically when running RuleRunner tests
I'm going to try excluding XCode, as I think the only other python on this computer is the correct one
w

witty-crayon-22786

05/11/2022, 11:55 PM
ah. yea, if you have a search path that you’d like to use for the
pantsbuild/pants
repo itself, you can put that in a
.pants.rc
file
👍 1
i use
Copy code
$ cat ~/.pants.rc
[python-bootstrap]
# Avoid system python.
search_path = ["<PYENV>"]
but you could also put it in the repo at
$WORKSPACE/.pants.rc
w

wide-midnight-78598

05/11/2022, 11:57 PM
Wow, okay, so, I didn't even know about the home-dir
pants.rc
. Does that also get picked up during something like VS Code's pre-commit phase?
w

witty-crayon-22786

05/11/2022, 11:57 PM
it will get picked up in any invoke of
pants
the challenge of a home directory RC file is just that it needs to be compatible with all repos it might be used with
w

wide-midnight-78598

05/11/2022, 11:59 PM
Wow, yeah, so that file clarifies so many questions I had about consistency across varying machines....... I'll test that out shortly and report back. If it works, then I'll be able to finally add those handy little unit tests to my PR
❤️ 1
Thanks @witty-crayon-22786 - that was it, setting a
.pants.rc
which kiboshed my system python worked perfectly
for the black unit test anyways, my clang one is getting some weird BinaryNotFound errors - but I think I'm missing some environment data
5 Views