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

tests/test_threadpoolctl.py::test_command_line_empty regression with Python 3.12 #146

Closed
mgorny opened this issue Jul 14, 2023 · 11 comments · Fixed by #155
Closed

tests/test_threadpoolctl.py::test_command_line_empty regression with Python 3.12 #146

mgorny opened this issue Jul 14, 2023 · 11 comments · Fixed by #155

Comments

@mgorny
Copy link
Contributor

mgorny commented Jul 14, 2023

When running the test suite against Python 3.12.0b4, I'm getting the following test failure:

_______________________________________________________ test_command_line_empty _______________________________________________________

    def test_command_line_empty():
        output = subprocess.check_output((sys.executable + " -m threadpoolctl").split())
>       assert json.loads(output.decode("utf-8")) == []
E       AssertionError: assert [{'user_api': 'openmp', 'internal_api': 'openmp', 'prefix': 'libgomp', 'filepath': '/usr/lib/gcc/x86_64-pc-linux-gnu/13/libgomp.so.1.0.0', 'version': None, 'num_threads': 12}] == []
E         Left contains one more item: {'filepath': '/usr/lib/gcc/x86_64-pc-linux-gnu/13/libgomp.so.1.0.0', 'internal_api': 'openmp', 'num_threads': 12, 'prefix': 'libgomp', ...}
E         Full diff:
E           [
E         -  ,
E         +  {'filepath': '/usr/lib/gcc/x86_64-pc-linux-gnu/13/libgomp.so.1.0.0',
E         +   'internal_api': 'openmp',
E         +   'num_threads': 12,
E         +   'prefix': 'libgomp',
E         +   'user_api': 'openmp',
E         +   'version': None},
E           ]

tests/test_threadpoolctl.py:535: AssertionError

The test passes with Python 3.11.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 13, 2023

Thanks @mgorny for the report but I cannot reproduce with Python 3.12.0 (final):

py312 ❯ pytest -v -k test_command_line_empty
===================================================================== test session starts =====================================================================
platform darwin -- Python 3.12.0, pytest-7.4.2, pluggy-1.3.0 -- /Users/ogrisel/mambaforge/envs/py312/bin/python3.12
cachedir: .pytest_cache
rootdir: /Users/ogrisel/code/threadpoolctl
plugins: cov-4.1.0
collected 63 items / 62 deselected / 1 selected                                                                                                               

tests/test_threadpoolctl.py::test_command_line_empty PASSED                                                                                             [100%]

============================================================== 1 passed, 62 deselected in 0.09s ===============================================================

Do you confirm we can close this issue?

@mgorny
Copy link
Contributor Author

mgorny commented Oct 13, 2023

I'm afraid I can still reproduce it with Python 3.12.0 final. Perhaps it is Linux-specific?

I've also tried 85d329a and it happens there still. Clearly Python version is relevant:

$ python3.11 -m threadpoolctl 
[]
$ python3.12 -m threadpoolctl 
[
  {
    "user_api": "openmp",
    "internal_api": "openmp",
    "num_threads": 12,
    "prefix": "libgomp",
    "filepath": "/usr/lib/gcc/x86_64-pc-linux-gnu/13/libgomp.so.1.0.0",
    "version": null
  }
]

@ogrisel
Copy link
Contributor

ogrisel commented Oct 16, 2023

Ok so it looks like python itself is linked against libgomp by default on Python 3.12? That's unexpected. Let me update our CI in a PR to check.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 16, 2023

Ok so it looks like python itself is linked against libgomp by default on Python 3.12?

I don't think that's the case, I'm afraid. Or at least trivial grep -R libgomp reveals nothing.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 16, 2023

Oh, I see what's going on. Python 3.12 links to libb2.so (BLAKE2 provider), and libb2.so links to libgomp.so.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 16, 2023

That's very interesting.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 16, 2023

Oh, I see what's going on. Python 3.12 links to libb2.so (BLAKE2 provider), and libb2.so links to libgomp.so.

Although I cannot reproduce on a conda-forge installation, even on Linux.

How did you install python3.12 on your host?

EDIT: from your github bio, I guess it's the Python package from gentoo. I can try to replicate with podman or docker.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 16, 2023

I guess we will have to make our tests robust to Python installs that come with libgomp linked in by default.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 16, 2023

Yeah, it's system Python package. FWICS CPython just picks libb2 up if it's installed at build time (with pkg-config module). To reproduce the specific problem, you have to also build libb2 with --enable-openmp, I think.

I guess we will have to make our tests robust to Python installs that come with libgomp linked in by default.

Yeah, I suppose any library in the stack could incidentally bring OpenMP in.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 17, 2023

@mgorny please let me know if #155 works for you.

@mgorny
Copy link
Contributor Author

mgorny commented Oct 17, 2023

Thanks. I can confirm that it fixes the issue for us on Gentoo — however, as I've noted on the PR, other Linux systems are bound to use different paths than /usr/lib/, so they'll probably eventually be affected as well.

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