Add support for Python 3.12#7670
Conversation
|
I've got a half baked branch for the imp->importlib transition. |
|
@bwoodsend Oh nice! Could we get those changes merged in first, or could I cherry-pick them in to this PR? |
|
Working on it... There's also this lovely surprise from the changelog:
although it looks like we're safe for another year. |
That doesn't look too bad. Last time I looked at the interpreter initialization/configuration, I was (mistakenly?) under impression we would have to deal with config struct directly, which would be a pain to do in version agnostic way. But this looks like an opaque structure with an API that abstracts the actual struct layout away, so it's quite nice for our use case. It's available from python 3.8 on, so we can start making the switch once we drop support for 3.7. |
|
#7676 is merged, let's see where a rebase takes us... |
|
... but not using a merge commit!!! |
3bcd71c to
58f9dbb
Compare
|
It will eventually take us here: https://github.com/rokm/pyinstaller/actions/runs/5166038863 Overall, it's not that terrible... I'm not sure what this one is about yet... These tests using My current hypothesis is that the current modulegraph's approach of looping over search locations, taking importer for it, and trying to look up the module for it was working for <= 3.11, because stdlib With 3.12, we don't have stdlib I'll see if we can completely replace this block: pyinstaller/PyInstaller/lib/modulegraph/modulegraph.py Lines 2952 to 3026 in fd0a25a with I think these are caused by lack of |
|
I'll deal with the extraneous fizz. |
|
Looks like it's also time to implement proper dependency scanning for Tcl/Tk libraries in splash, because the |
|
This fizz thing looks harmless. The code it's scanning for calls to functions is: def foo():
bar()
return [fizz(3) for i in range(10)]Until now, the body of a comprehension loop (i.e. the Before: (Pdb++) foo_code.co_names
('bar', 'range') # <-- no fizz()
(Pdb++) foo_code.co_consts[1]
<code object <listcomp> at 0x7fd4487b1630, file "<no file>", line 4> # <-- nested code object
(Pdb++) foo_code.co_consts[1].co_names
('fizz',) # <-- there's fizz!Verses after: (Pdb) foo_code.co_names
('bar', 'range', 'fizz')
(Pdb) foo_code.co_consts
(None, 10, 3) |
|
Does it still make sense to be dragging distutils support to 3.12 given that the package only sort of exists now? |
I think it does - a simple But we have whole summer to figure out the best way to handle this (i.e., the one with minimal changes compared to how things work right now and what our current hooks are made to handle)... despite that "high-priority" label |
|
Let's merge this now rather than wait for the official 3.12 release? There should be very little difference between Python's beta releases and the real ones. |
|
I suppose we could, if we're fine with depending on development version of Whatever issues may come up between now and October, we would have to deal with either way, and earlier exposure means faster feedback. |
Python 3.12 removed LOAD_METHOD opcode; LOAD_ATTR now behaves like LOAD_METHOD if the low bit of its oparg is set. This means that LOAD_ATTR pushes namei>>1 on stack. (This change is similar to what python 3.11 did with LOAD_GLOBAL).
The latest release of pywin32-ctypes (0.2.0) is incompatible with python 3.12, so we need to install the version from git main branch. This version updated the custom module path finder to be compliant with PEP 451.
Update the `VendorImporter` used by `test_import_metapath1` to the version available in the latest release of `setuptools` (67.8.0). This version is compatible with PEP 451, and hence python 3.12.
In Python <= 3.11, the compiled bytecode for [foo() for i in range(10)] is two code objects - the code object for the `foo()` bit being embedded in the code object for everything else. In Python >= 3.12, it's one flat code object. This makes it unsuitable as a test for scanning nested code objects since it's only the correct situation on older Pythons. Swap out the function call in the body of a comprehension loop with calling a function in a lambda which still does the right thing with any Python version.
Starting with python 3.12, `distutils` is not part of stdlib anymore, and it is provided solely by `setuptools`. Due to limitations of the modulegraph, the latter cannot find and properly analyze the `setuptools`-provided `distutils` (and its submodules) under mapped names, so we need the pre-safe-import-module hook to mark the `distutils` as a run-time package. Marking the package as a run-time one means that we also need to mark its submodules and subpackages as run-time ones.
bwoodsend
left a comment
There was a problem hiding this comment.
Well I approve of the bits you two wrote.
|
We still need to update the README and add a news fragment, then it should be ready for merge. |
|
Thanks @bwoodsend and @rokm for the teamwork on this one! |
Python 3.12 is now in beta and this PR adds support.