Google Groups Home
Help | Sign in
Hidden imports from a top-level module
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
akineko  
View profile
 More options Jun 19, 1:01 pm
From: akineko <akin...@gmail.com>
Date: Thu, 19 Jun 2008 10:01:21 -0700 (PDT)
Local: Thurs, Jun 19 2008 1:01 pm
Subject: Hidden imports from a top-level module
Hello everyone,

I'm having a hidden import problem, which is not uncommon.

I have a fairly small GUI Python program.
What the program does is loading another Python script (which may be
much larger than the top-level) and creates a separate window using
the environment derived from the top-level.
Any python code can be imported as far as it meets some basic
requirements.

Now, I want use Pyinstaller with this program.
When I executed the "pyinstalled" program, I got hidden import problem
as pyinstaller cannot see the imports used in the loaded external
Python script.

I thought I could fix this problem by creating a hook-<module>.py
file. But it didn't work.
By reading a part of pyinstaller codes, I found that hook-<module>.py
scheme was only applied when a module is being imported. As my top-
level module is a small single file Python code and it doesn't import
any module except fairy common Python libraries, I don't have any
import that is appropriate for me to use.

As I know which modules are hidden imports, it is much easier if I can
explicitly specify which ones to be included (much like exclude). Is
there any way using the Pyinstaller 1.3 to do such explicit inclusion?

Meanwhile, I will try putting a 'dummy' import to my program but I
prefer to specify separately as such hidden imports may change
depending upon which external Python script to be loaded.

Any suggestions will be appreciated.

Thanks in advance.
Aki Niimura


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simosito  
View profile
 More options Jun 26, 3:19 am
From: Simosito <simos...@gmail.com>
Date: Thu, 26 Jun 2008 00:19:10 -0700 (PDT)
Local: Thurs, Jun 26 2008 3:19 am
Subject: Re: Hidden imports from a top-level module
You have to run a script importing it from your app, is that right?
Have you tried with __import__('file.py') or you're using this yet?

I hope you'll solve this problem soon,
Simone Ramacci

On 19 Giu, 19:01, akineko <akin...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
akineko  
View profile
 More options Jun 26, 5:44 am
From: akineko <akin...@gmail.com>
Date: Thu, 26 Jun 2008 02:44:45 -0700 (PDT)
Local: Thurs, Jun 26 2008 5:44 am
Subject: Re: Hidden imports from a top-level module
Hello  Simone Ramacci,

Thank you for your posting.
Yes, my top-level script uses __import__(file.py).
Therefore, it doesn't know what kind of modules are needed until
runtime.
I'm trying to create an executable for one common case out of many
possible cases.
ex.

top_level.py A.py  (extra imports required for A.py)
top_level.py B.py  (extra imports required for B.py)

I can place phoney imports into top_level.py but it will clutter
top_level.py so I would like to avoid.
I would like specify those extra imports in my PyInstaller script.

Aki Niimura

On Jun 26, 12:19 am, Simosito <simos...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simone Ramacci - Simosito.it  
View profile
 More options Jun 26, 5:57 am
From: "Simone Ramacci - Simosito.it" <simos...@gmail.com>
Date: Thu, 26 Jun 2008 11:57:38 +0200
Local: Thurs, Jun 26 2008 5:57 am
Subject: Re: [PyInstaller] Re: Hidden imports from a top-level module
akineko ha scritto:

If the thing you want to do is bundle the modules imported by those
external scripts into your executable I think you can't, unless you know
exactly what will import every possible script you're going to pass to
your program.

If you know that, just import every module that might be necessary.
(Of course the executable will be heavier)
IMHO the isn't any other way to do what you're trying to realize.

I hope I'm wrong about the last sentence,
Simone Ramacci


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
akineko  
View profile
 More options Jun 26, 12:11 pm
From: akineko <akin...@gmail.com>
Date: Thu, 26 Jun 2008 09:11:22 -0700 (PDT)
Local: Thurs, Jun 26 2008 12:11 pm
Subject: Re: Hidden imports from a top-level module
Hello Simone Ramacci,

Which imports are required is determined once which script to be
executed.
hooks scheme is the way to provide such info that only user can know.
But it was not quite usable with my case as no imports except system
modules.
PyInstaller is creating a database of all collected imports. So, the
question is how to influence the database creation.
I can resolve my problem by:
(1) Create a phoney import to use hook-<module> scheme
(2) Create a separate hook directory and use hook-<module> scsheme
using system module import
(3) Tweak PyInstaller scripts to add a list of imports explicitly
(4) Put phoney imports to the top level

I don't like none of them but I may need to resort to such.

Thank you,
Aki Niimura

On Jun 26, 2:57 am, "Simone Ramacci - Simosito.it"


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
akineko  
View profile
 More options Jun 28, 7:45 pm
From: akineko <akin...@gmail.com>
Date: Sat, 28 Jun 2008 16:45:19 -0700 (PDT)
Local: Sat, Jun 28 2008 7:45 pm
Subject: Re: Hidden imports from a top-level module
Hi,

(This is to record my approach to solve the problem)

After pondering for days, I decided to use the (1) scheme I mentioned:
(1) Create a phony import to use hook-<module> scheme

I created a completely empty module (ex. A.py) and added an import to
the toplevel module.
Then I created hook file (hook-A.py) and listed all hidden imports (I
found many).
Listed modules are considered when PyInstaller tries to import A.py.
(It is a well crafted mechanism, I would say.)

Of course, this hook file may need to be changed if I try to execute a
different script.
But that is not a problem for now as I know which script to be
executed.

I resisted adding a completely empty file to my project but I
concluded that (1) is better than other alternatives.
I also found that analyzer.modules is the database that holds
collected modules. Therefore, you can manipulate it to add modules
directly.

Aki-

On Jun 26, 9:11 am, akineko <akin...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google