> Anyway I think I've made a mistake: Collecting the plugins as datafiles
> does not work if they import  modules not imported by the main program.

I used a "from Plugins import *" statement in the main program but
still collecting plugins as data files does not work

Thanks for your patience....I believe I have not fully explained my
problem.
So please allow me to rephrase the question.

I am using PyInstaller to bundle my moderately large application in to
a single executable. The application gives the user an option to
specify a particular network scanning tool (say nmap,xprobe,p0f) and
then scans a given subnet with that tool (I do not re-implement the
tool, simply call it in shell and parse its response for my app),
parses the result and stores in a particular format in DB. This
application is basically a feeder application for another app that
will use the data in DB.

Earlier I had the following structure for my whole project

trunk/
  DBWriter.py  -- All DB related functions
  Scanner/  -- The application that scans the network with user choice
tool
    __init__.py
    network_mapper.py   -- Initialize the scan and such mundane stuff
    Scanner.py   -- The file that had codes for all the scanners
(Codes such as firing scans,parsing results and storing to DB etc)
  Other_Apps/  -- other apps that also use DBWriter

For such a structure creating an executable network_mapper (for linux)
was fairly easy

python Makespec.py --onefile trunk/Scanner/network_mapper.py trunk/
DBWriter.py
python -O Build.py network_mapper/network_mapper.spec

The resulting executable worked correctly.

But now I have restructured my code so that all Scan Tool interfaces
are implemented as plug-ins. The new structure is

trunk/
   DBWriter.py
   Scanner/
      __init__.py
      network_mapper.py
      Scanner.py
      Plugins/
         __init__.py
         nmap.py
         p0f.py
   Others/

So to add a new scan interface, all the developer needs to do is write
a tool.py file (in correct semantics ofcourse) and drop it into
Plugins folder. The said thing works fine if I use python interpreter.
But If I try to make a one executable, as done previously, then the
executable can't find Plugins/ or any py file in that.

Here's the code that I have added (which works correctly for native
python execution)

f,p,d = imp.find_module("Plugins")
x = imp.load_module("Plugins",f,p,d)
path_n = x.__path__
f,p,d = imp.find_module("%s"%(tool),path_n)
tool_mod = imp.load_module("%s"%(tool),f,p,d)

I understand that since in the executable all the stuff is bundled
into one file, the find_module will definitely fail. However from
Bundling data files with PyInstaller (--onefile) question, I gathered
that this data is extracted into a directory defined by _MEIPASS2
environment variable. I tried to add _MEIPASS2 directory to the path
and search but the search failed again.

So my question is how do I enable the executable created with
pyinstaller to correctly interpret imp.find_module and imp.load_module
functions



-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to