-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Frozen stdlib modules are discarded if custom frozen modules added. #89558
Comments
The mechanism to add custom frozen modules to the Python runtime is to set PyImport_FrozenModules (see Python/frozen.c) to some new array. This means that the default frozen modules (from _PyImport_FrozenModules) are no longer used unless explicitly added to the custom array. This is unlikely to be what the user wants. It's especially problematic since it's easy to not realize this (or forget) and forgetting essential modules (like _frozen_importlib) will cause crashes. It would probably make more sense to have PyImport_FrozenModules be an array of *additional* frozen modules, defaulting to an empty array. Before going down that route we need to be sure that isn't going to break folks that are accommodating the existing behavior. |
I've posted a PR that demonstrates a reasonable solution. |
I'm not sure I follow, but in any case, please make sure that The freeze tool would also need to know which modules are already |
On Thu, Oct 7, 2021 at 1:17 AM Marc-Andre Lemburg
Will do. |
On 07.10.2021 16:40, Eric Snow wrote:
Great, thanks, Eric.Marc-Andre Lemburg |
@mal, what's the best way to make sure Tools/freeze is still working? I don't see any tests for it in the test suite. I tried running the test in Tools/freeze/test, but I can't get that to work on main (or on the 3.10 branch). |
On 14.10.2021 22:56, Eric Snow wrote:
You'd have to create a frozen binary using the standard way freeze One of these days, I need to refactor PyRun into a standalone project https://www.egenix.com/products/python/PyRun/#Download I can send you an updated version for Python 3.8, if there's Essentially, you need to create a Python module which runs your |
@mal, who's maintaining Tools/freeze? I'm not aware of who's using it (other than you, of course). It looks like PyRun isn't compatible with anything newer than 3.5, so it seems like that isn't verifying that Tools/freeze still works. Neither does it have tests that run in the test suite (nor on buildbots). So could Tools/freeze have been broken for a while? I ask because I haven't been able to get it work work on the master branch (or on 3.10). |
On 16.10.2021 01:31, Eric Snow wrote:
I don't know who maintains it, but it's been working fine up until Python 3.8, There have also been a couple of patches going into the freeze tool, so this is I can try to port PyRun to 3.9 and 3.10 to see whether I run into any issues. |
On Sat, Oct 16, 2021 at 5:01 AM Marc-Andre Lemburg
Yeah, that would totally help. |
On 16.10.2021 21:20, Eric Snow wrote:
Ok, I'll start looking into this and post updates here. |
On Tue, Oct 19, 2021 at 10:47 AM Marc-Andre Lemburg
Thanks! |
On 19.10.2021 18:47, Marc-Andre Lemburg wrote:
>
>> On Sat, Oct 16, 2021 at 5:01 AM Marc-Andre Lemburg
>> <report@bugs.python.org> wrote:
>>> I can try to port PyRun to 3.9 and 3.10 to see whether I run into any issues.
>>> Would that help ?
>>
>> Yeah, that would totally help.
>
> Ok, I'll start looking into this and post updates here. I have PyRun mostly working with Python 3.9. Still need to add a few No changes were necessary to Tools/freeze/. The PGO build complains BTW: Why is test_embed even used for the PGO target ? |
On Wed, Oct 20, 2021 at 6:01 AM Marc-Andre Lemburg
Great! Thanks for getting to that so quickly. Are you going to take
Perhaps I've missed something, but I'm not clear on why PGO would be a |
On 20.10.2021 16:25, Eric Snow wrote:
Yes, 3.10 is next, once I have 3.9 ironed out. And then I'll give
Sorry, I wasn't clear. PGO is not a problem for test_embed. I just Well, I guess using the test suite for PGO is questionable anyway. |
On Wed, Oct 20, 2021 at 8:38 AM Marc-Andre Lemburg
Thanks!
Ah, that makes sense. I expect we don't do anything more complex than |
I have an initial version of PyRun for Python 3.10 running as well. I'll have to check my version of the freeze tool against the one BTW: (My) freeze.py uses this startup code as main(): int
main(int argc, char **argv)
{
extern int Py_FrozenMain(int, char **);
PyImport_FrozenModules = _PyImport_FrozenModules;
return Py_FrozenMain(argc, argv);
} I still have to dig through the changes you have made, but this |
FYI, I figured out the problem on my end. I wasn't using an installed python. Once I did it worked fine. |
On 26.10.2021 16:02, Eric Snow wrote:
Oh, you mean you tried using it directly from the source tree ? When building PyRun, I first install to a temporary directory and I've pretty much finished the port to 3.10. I'll try the main version in the next couple of days. There's currently |
This is done now. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: