Was trying to get together the code for a potentia...
# general
w
Was trying to get together the code for a potential
WSDL -> Java
codegen backend and I’m getting an import error when doing
./pants test src/python/pants/backend/codegen/soap::
on a fresh pull of the
pants
repo (well, in fact it happens when I try running any Python test using the
./pants
script). The error looks like the following:
Copy code
_ ERROR collecting src/python/pants/backend/codegen/soap/target_types_test.py __
ImportError while importing test module '/private/var/folders/c9/5v4gbjh17w9_vy73fc90fnch0000gn/T/process-executionF88I01/src/python/pants/backend/codegen/soap/target_types_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/codegen/soap/target_types_test.py:9: in <module>
    from pants.backend.codegen.soap import target_types
src/python/pants/backend/codegen/soap/target_types.py:4: in <module>
    from pants.engine.rules import collect_rules, rule
src/python/pants/engine/rules.py:28: in <module>
    from pants.engine.engine_aware import SideEffecting
src/python/pants/engine/engine_aware.py:9: in <module>
    from pants.engine.internals import native_engine
E   ImportError: dlopen(/private/var/folders/c9/5v4gbjh17w9_vy73fc90fnch0000gn/T/process-executionF88I01/src/python/pants/engine/internals/native_engine.so, 0x0002): symbol not found in flat namespace '_PyObject_VectorcallMethod'
I did a
./cargo build
and
./cargo test
separately and those commands succeed … does any of know what I may be missing that causes that error?
c
Hi, No idea. A hunch I’m getting is if it could be related to
__init__.py
files missing, or some such, maybe.. do you see the same issue on a clean checkout from
main
as well?
w
yeah, that’s the odd thing, it happens in all packages…
c
I’d try a clean checkout, and wiping
~/.cache/pants
in case there’s some flunky data in there.. That will start you over from scratch. (N.b. that if you have any pantsd processes running, you need to kill them too..)
(in lack of better suggestions/troubleshooting tips)
w
unfortunately it still happens …
killed
pantsd
processes, removed
.pid
and
.pants.d
folders, wiped cache at
~/.cache/pants
and fresh cloned the repo again, then just run
./pants test src/python::
in the
main
branch and got the same errors
I believe that I had this working at some point and I’m looking at the GH workflow to see if I’m missing any setup step… but it doesn’t seem to be the case …
anyway, thanks for the help 😅
h
I think this may be because you're using the MacOS system python, which is known to have all sorts of quirks and flaws
I recommend installing an interpreter using
pyenv
And making sure that is on your PATH ahead of the system interpreter
Worth a try anyway
👍 1
w
pants seems to still prefer using my system-wide Python instead of the one installed by pyenv, even though the latter is before is in the
PATH
is there a way I can tell pants to prefer my pyenv setup? some sort of
.pantsrc
file or similar I could drop in my $HOME?
c
h
Or just to verify that this solves things, try
--python-bootstrap-search-path="['<PYENV>']"
That will tell Pants to not even try to use interpreters from PATH and instead only use pyenv interpreters
w
that works! I’ll drop that setting in a ~/.pants.rc file. Many thanks! 🙂
💯 1