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
Hooks for wx.lib.pubsub do not work with modulepgraph #1367
Comments
Well-fermented food for thought. I see two simple means of fixing this (in order of decreasing simplicity):
Untested, of course. But that should hypothetically theoretically work. Actually, that's pretty sweet, so no Solution B. Solution B was going to alternately suggest that |
@leycec The honor is your for this solution. Go a head ans issue a pull-reqest. I'd only write
instead of the one-liner as this is more readable. So, wait, stop this shows the problem: Which means, we need another solution. Maybe set some variable in |
Hmm. I see that the definition of Oh, wait. I sort-of-kind-of-maybe get what you're getting at: we need to explicitly detect whether If so... yeah. I don't believe that
The second approach requires two linear searches through a stupendously huge list for each such comparison. The efficiency obsessive-compulsive in me promotes the first approach, instead. Alternately, we could go with the graph hook approach. Unlike import hooks, graph hooks are guaranteed to be run immediately before
The existing It's also a little wonky. Sure, we could (ab|mis)use graph hooks in this way. And to get this working today, we probably should. In the long-term, however, we probably do want some means of determining import order. In that case, one of the prior two solutions may be a better fit. |
@leycec It was recently changed to be more robust. See this comment in build.py:
Basically, it now tries to apply all import hooks while dependency graph gets updated. So the order when a hook gets applied is unpredictable. So lets say that we have these files:
|
I'm tagging this as high, since this may show some deeper problem in the way, hooks are handle currently. |
@matysek Thanks for the erudite break-down. I'm properly educated now – and all without $100,000 in predatory student loan debt. ✏️ Your analysis confirms deep-set suspicions: while I can't see any critical issues in the new This could suggest, however, that fixing this issue requires new
That shouldn't be terribly arduous. (Lies. All lies!) Let me know if you'd like me to forge ahead with that. |
@leycec Regarding Regarding the erudite break-down expect my invoice the following days. |
back in ought-thirteen I asked M. Oussoren about adding extra info to graph It was inconclusive. I gave up, saying "Anyway I will store these outside On Sat, Aug 8, 2015 at 4:08 AM, Martin Zibricky notifications@github.com
|
Thanks for liaisoning with the respectable Brave Sir Ronald. Your efforts are not in vain.
Conceivably. But probably not. Although node identifiers are uniquely hashable (...they sort of have to be, don't they?), how exactly would you externally hook into As currently defined, graph hooks are module-specific and hence not generalizable to hooking every possible module. We can, however, extend the same idea by either:
In either case, there's little gain to externalizing this ordering into a PyInstaller-specific I know Done. Issue resolved. The glib credits roll, everyone goes to bed with a glazed lolipop and a loopy grin, and Santa returns to the North Pole. Honestly, why didn't Ronald just suggest that straightaway rather than obfuscating-ly hemming and hawing around? 😱 I'm getting a "too many chefs (and not enough actual cookin') in the kitchen" vibe. Since talk is discount cheap, I'm just going to go ahead and actually do this. Here's to you, fellow chefs! |
The order in which modules are imported by the user application is now inspectable via the new public `lib.modulegraph.modulegraph.Node.order` attribute. This is low-level machinery for fixing pyinstaller#1367 and similar issues.
Done. I now eat my zesty yellow pepper in the peace and comfort of a job well-done. (Well, done, anyway.) |
The order in which modules are imported by the user application is now inspectable via the new public `lib.modulegraph.modulegraph.Node.order` attribute. This is low-level machinery for fixing pyinstaller#1367 and similar issues.
Some summary of the insights found in #1393 (comment) and following:
Order of imports and hooks
conditional imports and imports in functions
ConclusionThe old imptracker's behaviour is plain wrong, module graph does a far better job. Idea for a solutionAs I need to go back to may paid occupation, I don't have time for testing this. So maybe I'm totally wrong again.This is based on wx 2.8.12, which I have installed.
|
The order in which modules are imported by the user application is now inspectable via the new public `lib.modulegraph.modulegraph.Node.order` attribute. This is low-level machinery for fixing pyinstaller#1367 and similar issues.
The order in which modules are imported by the user application is now inspectable via the new public `lib.modulegraph.modulegraph.Node.order` attribute. This is low-level machinery for fixing pyinstaller#1367 and similar issues.
The order in which modules are imported by the user application is now inspectable via the new public `lib.modulegraph.modulegraph.Node.order` attribute. This is low-level machinery for fixing pyinstaller#1367 and similar issues.
Here's one more detail to agonize over. wxPython 2.8 decides whether to use the legacy |
I'm thinking we'll need a runtime hook that imports In any case, with the path-aware FrozenImporter in place, the wx_lib_pubsub family of tests now passes on Python 2.7 with versions 2.9.5 and 3.0.2 of wxPython. |
I don't see any need for a runtime-hook. IMHO all the detection can be done at freeze-time and using the new redirect-hooks resp. |
Let me explain again. wxPython 2.8 contains this code:
The call to |
A few other solutions, off the top of my head:
|
Yes, but The only think we have to take care of is: |
Yes, it is just a marker, but that's not the issue here. The issue is that the marker is never detected whenever it is in a PYZ archive - and it is not detected because The problem is that |
But my point is, that there is no need to detect it at run-time. We can detect it at freeze-time already. And - to be frank - I'm strictly against implementing a complicated hack for |
All right, the third option sounds good, then. I'll update the wiki with a note about wxPython 2.8.x. The new hook works with 2.9.x and 3.0.x, according to the wx_lib_pubsub tests. It just brings in all of the submodules and relies on the The reason the new |
|
@codewarrior0 Please remove |
Sure. |
While removing the To resolve this, I included them as data files instead, and included the notorious Relevant commit: 5676716 |
The hook for
wx.lib.pubsub.setupargs1
does not work with modulegraph, because the order, hooks are executed has changed and may even be undetermined.The hook just sets a value in
hookutils.hook_variables
, which the hook forwx.lib.pubsub.core
uses for extending it's__path__
. But this requireshook-wx.lib.pubsub.core
to be executed afterhook-wx.lib.pubsub.setupargs1
, which is not the case when using modulegraph.wx.lib.pubsub.setuparg1
importswx.lib.pubsub.core
, so the cause may simply be that we are calling the hooks to early.The text was updated successfully, but these errors were encountered: