It never ends... Now I'm getting `ImportError: /tm...
# development
h
It never ends... Now I'm getting
ImportError: /tmp/pants-sandbox-577g1M/src/python/pants/engine/internals/native_engine.so: undefined symbol: PyObject_VectorcallMethod
in a test, on linux.
Full stack trace:
Copy code
____________________________________________________________________________ ERROR collecting src/python/pants/option/options_bootstrapper_test.py ____________________________________________________________________________
ImportError while importing test module '/tmp/pants-sandbox-577g1M/src/python/pants/option/options_bootstrapper_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/data/home/benjy/.pyenv/versions/3.7.13/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/python/pants/option/options_bootstrapper_test.py:11: in <module>
    from pants.base.build_environment import get_buildroot
src/python/pants/base/build_environment.py:11: in <module>
    from pants.engine.internals import native_engine
E   ImportError: /tmp/pants-sandbox-577g1M/src/python/pants/engine/internals/native_engine.so: undefined symbol: PyObject_VectorcallMethod
So this is happening at test collection time, due to some file importing the native_engine
This works on other machines, including both macos and another linux machine
python3-dev
is installed and up to date on this machine
Ironically the test doesn't actually care about that native_engine import, it just happens to be imported by build_environment.py for use by some other function
But nonetheless this is weird
I can reproduce outside of the test, in a repl:
Copy code
$ ./pants repl src/python/pants/base/build_environment.py
>>> from pants.base.build_environment import get_buildroot
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/tmp/pants-sandbox-VjVHcE/src/python/pants/base/build_environment.py", line 11, in <module>
    from pants.engine.internals import native_engine
ImportError: /tmp/pants-sandbox-VjVHcE/src/python/pants/engine/internals/native_engine.so: undefined symbol: PyObject_VectorcallMethod
Or even
./pants run src/python/pants/base/build_environment.py
e
So the 1st backtrace is running under 3.7.13 - expected?
IE is the engine.so for 3.7?
So the engine.so is definitely 3.9
So, that's the proximal issue.
h
uuurgh
Fortunately this doesn't hit users, this is a pants-running-pants thing
I assume anyway
will dig for the root cause
objdump is helpful
e
Yeah, should be a pants-running-pants thing.
h
Yep, Pants runs on 3.9 with a 3.9 engine, selects 3.7 at runtime, that code copies the outer pants' engine into the sandbox and boom
🤷‍♂️