-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
(dev): 3.11 testing #3923
(dev): 3.11 testing #3923
Conversation
@rwgk Any ideas how to address this failure? I would like to get PyBind11 fully supported before 3.11 leaves alpha. |
No, unfortunately not. First thought: this could be really tricky to debug and fix. MRO is complex, especially between native Python & pybind11: https://pybind11.readthedocs.io/en/stable/advanced/classes.html
That's all I know though, I don't have first-hand experience working on the MI code. What I'd try first: comment out tests until everything that's left passes. Then look at the overall picture to decide what to do next. |
@rwgk I know what causes the issue. It's a corner case caused when a PyBind11 Class has multiple inheritance and the first base does not have dynamic-attrs, but another base class does not. |
I only remembered that very vaguely. Variation of my "comment out" strategy: manually add |
@rwgk Adding it to the children classes did not help. Adding it to the base classes does work, but then that makes this unit test stops doing anything meaningful and the base class and any of its parents inherit the performance penalty of the dynamic-attrs. |
Sound fine to me:
My net conclusion: Add |
FYI, beta1 is out, no more non-bug fix changes. |
c4d14bc
to
99bafd0
Compare
99bafd0
to
a5a0e5d
Compare
Signed-off-by: Henry Schreiner <[email protected]>
a5a0e5d
to
9887cdc
Compare
In the Python 3.10 code path, PySys_SetArgvEx() is called after Python initialization, when sys.path was already computed. In this case, the function inserts a new path at
If you don't call PySys_SetArgvEx(), Py_RunMain() inserts a new path at I tried to document everything about the Python Path Configuration at: https://docs.python.org/dev/c-api/init_config.html#python-path-configuration See the "Py_RunMain() and Py_Main() modify sys.path: (...)" section. If you control argv and you know what should be in
Note: the code to compute sys.path has been rewritten in pure Python in Python 3.11: https://github.com/python/cpython/blob/main/Modules/getpath.py But this code doesn't include changes done afterwards by Py_RunMain(), as I wrote. |
Signed-off-by: Henry Schreiner <[email protected]>
…7/pybind11 into skylion007/311-testing
Signed-off-by: Henry Schreiner <[email protected]>
380c3d1
to
e0e5673
Compare
Signed-off-by: Henry Schreiner <[email protected]>
git clean -xdf tar zcvf ../python-pybind11_2.9.2.orig.tar.gz --exclude=.git . debuild -uc -us cp python-pybind11.spec ../python-pybind11_2.9.2-2.spec mv ../python*-pybind11*2.9.2*.{gz,xz,spec,dsc} /osc/home\:alvistack/pybind-pybind11-2.9.2/ rm -rf ../*pybind11*2.9.2*.* See pybind#3923 Signed-off-by: Wong Hoi Sing Edison <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Henry was faster by a few minutes.
Py_InitializeEx(init_signal_handlers ? 1 : 0); | ||
|
||
detail::set_interpreter_argv(argc, argv, add_program_dir_to_path); | ||
// Before it was special-cased in python 3.8, passing an empty or null argv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really concerned about inlining the two complex functions here, especially because each version introduces multiple variables which could clash in non-obvious way for one Python version or another. We don't know how this code will need to be evolved in the future, accidents seem likely. I think it would be much better to keep the functions separate, even if we need #ifdef
in both places, above for the function definitions, and here (I didn't look enough to know).
@@ -14,7 +14,7 @@ env: | |||
|
|||
jobs: | |||
standard: | |||
name: "🐍 3.11 dev • ubuntu-latest • x64" | |||
name: "🐍 3.11 latest internals • ubuntu-latest • x64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency would be nice, e.g.
3.11-latest above (line 33) and here.
I often look at CI logs in bulk, having to manually map latest internals
here to -dev
elsewhere is confusing/distracting.
|
||
PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path)); | ||
#else | ||
PyConfig config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here would be useful (similar to Henry's comment from a few days ago):
- Link to the corresponding Python sources.
- Something like "unfortunately the Python code is private, therefore we are forced to duplicate here".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has to be duplicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this comment in mind:
@henryiii wrote 14 days ago:
_PyPathConfig_ComputeSysPath0 is private. :( It seems looking at PEP 587 that all the sys.path handling is now tied to the high level API (Py_Main, Py_BytesMain, and Py_RunMain), and line-by-line runners like us are stuck reimplementing the logic ourselves now.
When I saw the email that Henry had already merged this PR I stopped looking further. Doing that now:
This seems to be what @henryiii was referring to (and the "Link" I had in mind):
Comparing that with the new #else
(Python 3.11) block here in embed.h, it looks like something completely different. Apparently I misinterpreted Henry's comment. Sorry.
Looking more, it seems this is @vstinner's response to the @henryiii's comment above:
Which makes me think adding this link would be useful:
if (add_program_dir_to_path) {
// https://docs.python.org/dev/c-api/init_config.html#python-path-configuration
PyRun_SimpleString("import sys, os.path; "
"sys.path.insert(0, "
"os.path.abspath(os.path.dirname(sys.argv[0])) "
"if sys.argv and os.path.exists(sys.argv[0]) else '')");
}
Or maybe alternatively the link to Victor's comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PyConfig API initializes the default value of sys.path. But Py_RunMain() then inserts a path to sys.path. Python 3.11 safe_path=1 disables this behavior:
- https://docs.python.org/dev/c-api/init_config.html#c.PyConfig.safe_path
- https://docs.python.org/dev/c-api/init_config.html#python-path-configuration
It might be interesting to move more code changing sys.path into the Python initialization (PyConfig), but it's complicated.
git clean -xdf tar zcvf ../python-pybind11_2.9.2.orig.tar.gz --exclude=.git . debuild -uc -us cp python-pybind11.spec ../python-pybind11_2.9.2-2.spec mv ../python*-pybind11*2.9.2*.{gz,xz,spec,dsc} /osc/home\:alvistack/pybind-pybind11-2.9.2/ rm -rf ../*pybind11*2.9.2*.* See pybind#3923 Signed-off-by: Wong Hoi Sing Edison <[email protected]>
git clean -xdf tar zcvf ../python-pybind11_2.9.2.orig.tar.gz --exclude=.git . debuild -uc -us cp python-pybind11.spec ../python-pybind11_2.9.2-2.spec mv ../python*-pybind11*2.9.2*.{gz,xz,spec,dsc} /osc/home\:alvistack/pybind-pybind11-2.9.2/ rm -rf ../*pybind11*2.9.2*.* See pybind#3923 Signed-off-by: Wong Hoi Sing Edison <[email protected]>
Description
Suggested changelog entry: