Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test suite failures and missing symbols on macOS #742

Closed
damaxwell opened this issue Jan 22, 2020 · 2 comments · Fixed by #1347
Closed

test suite failures and missing symbols on macOS #742

damaxwell opened this issue Jan 22, 2020 · 2 comments · Fixed by #1347
Labels

Comments

@damaxwell
Copy link

🐛 Bug Reports

There are failures in the test suite on macOS with pyenv installed Python 3.7.6.

failures:

---- buffer::test::test_array_buffer stdout ----
thread 'buffer::test::test_array_buffer' panicked at 'called `Result::unwrap()` on an `Err` value: PyErr { type: Py(0x10b9fa4f0, PhantomData) }', src/libcore/result.rs:1189:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- exceptions::test::test_check_exception stdout ----
thread 'exceptions::test::test_check_exception' panicked at 'Can not import module: socket: PyErr { type: Py(0x10b9fa4f0, PhantomData) }', src/libcore/result.rs:1189:5


failures:
    buffer::test::test_array_buffer
    exceptions::test::test_check_exception

The issue is caused by missing Python library symbols in the final linked rust executable. For example, the failure in test_check_exception happens on an import socket. The Python socket module imports a C extension module _socket that references _PyTime_AsMilliseconds, which is missing:

Traceback (most recent call last):
  File "/Users/david/.pyenv/versions/3.7.6/lib/python3.7/socket.py", line 49, in <module>
    import _socket
ImportError: dlopen(/Users/david/.pyenv/versions/3.7.6/lib/python3.7/lib-dynload/_socket.cpython-37m-darwin.so, 2): Symbol not found: __PyTime_AsMilliseconds
  Referenced from: /Users/david/.pyenv/versions/3.7.6/lib/python3.7/lib-dynload/_socket.cpython-37m-darwin.so
  Expected in: flat namespace
 in /Users/david/.pyenv/versions/3.7.6/lib/python3.7/lib-dynload/_socket.cpython-37m-darwin.so

The issue may be related to the fact that the pyenv installation only provides a static Python library.

The issue may be known; it was obliquely mentioned in #704 before being deleted from the original issue report.

🌍 Environment

  • Your operating system and version:
    macOS 10.15.2

  • Your python version:
    3.7.6

  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?:
    pyenv

  • Your rust version (rustc --version):
    1.41.0-nightly

  • Are you using the latest pyo3 version? Have you tried using latest master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?
    Yes.

💥 Reproducing

cargo test

@damaxwell
Copy link
Author

Oh, hey, look at that. If you install Python with a shared library:

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.6

then all your problems go away. So this is my mistake. But others seem to have hit it. Maybe just note this somewhere in the docs?

@kngwyu
Copy link
Member

kngwyu commented Feb 11, 2020

Thank you for sharing the workaround!
I added a note on README based on your snippet :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants