#83: scipy namespace not detected correctly
---------------------------+------------------------------------------------
 Reporter:  peteburgers    |        Owner:  williamcaban
     Type:  defect         |       Status:  new         
 Priority:  normal         |    Milestone:              
Component:  Documentation  |      Version:              
 Severity:  blocker        |   Resolution:              
 Keywords:                 |  
---------------------------+------------------------------------------------
Comment (by giovannibajo):

 Wow, I'm actually impressed that people prefer to write something like 300
 lines of code (numpy._importtools.py) just to save a dozen of import
 statements... and of course break packaging of Python programs :)

 AFAICT, {{{scipy/__init__.py}}} relies on numpy._importtools to import all
 sub-packages into its namespace. We have two problems here to solve:

  1. We need to make sure that all subpackges are bundled by !PyInstaller.
 It cannot detect it by itself, because it doesn't see a raw import
 statement. So it should be sufficient to add something like:
 {{{
 hiddenimports = ['scipy.misc', 'scipy.ffpack', 'scipy.lib', ...]
 }}}
  If we want to be very fancy, we could glob the filesystem and find out
 all subdirectories instead of hard-coding a list (given that scipy itself
 searches on the filesystem, it would strictly be correct).
  To verify that this step has been succesful, it is sufficient to run
 !ArchiveViewer.py onto the generated executable and look if all the
 modules have been packaged.
  1. At runtime, we need to fix the namespaces. This can be done through a
 runtime hook (which is a file which is executed BEFORE the application
 starts; look at rthooks.dat). There are couple of ways:
     1. Something exactly like your suggested workaround. The import hook
 can simply import the subpackages one by one and do a for loop to copy all
 the symbols into the scipy namespace.
     1. Monkey-patch numpy._importtools.py so that, instead of searching
 within the disk, searches within the packaged archive (I am not sure how
 exactly, though...)
     1. Re-run scipy.pkgload() by passing it an explicit list of
 subpackages; given its documentation, it should work. It should be
 sufficient something like:
 {{{
 import scipy
 scipy.pkgload("misc", "ffpack", "lib", ..) # same list of the import hook
 }}}

 I won't have time to face this in the next weeks (until the end of
 August), so if you want to try for yourself go ahead and let me know.

-- 
Ticket URL: <http://www.pyinstaller.org/ticket/83#comment:1>
Pyinstaller <http://www.pyinstaller.org>
PyInstaller Project
--~--~---------~--~----~------------~-------~--~----~
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