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

witty-family-13337

02/21/2022, 9:17 AM
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

curved-television-6568

02/21/2022, 9:31 AM
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

witty-family-13337

02/21/2022, 10:33 AM
yeah, that’s the odd thing, it happens in all packages…
c

curved-television-6568

02/21/2022, 10:49 AM
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

witty-family-13337

02/21/2022, 11:44 AM
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

happy-kitchen-89482

02/21/2022, 3:38 PM
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

witty-family-13337

02/21/2022, 5:29 PM
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

curved-television-6568

02/21/2022, 5:35 PM
h

happy-kitchen-89482

02/21/2022, 5:56 PM
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

witty-family-13337

02/21/2022, 7:07 PM
that works! I’ll drop that setting in a ~/.pants.rc file. Many thanks! 🙂
💯 1
6 Views