Thanks! I've installed your patch in materials.py and rebuilt VPython
5.72, which was only a few days old.
Bruce Sherwood
On Sat, Oct 22, 2011 at 6:50 AM, Jason Morgan <j.a...@gm...> wrote:
> Hi,
> There is a bug in vpython where it fails with py2exe.
>
> The problem is that it fails to find the texture bitmap files and raises an
> exception.
>
> I can see that it is because Visual loads a number of texture bitmaps in
> vis/material.py regardless of even if material are being used (for me they
> are not).
> Then to make matters worse they don't seem to be referred to in such a way
> as is compatible with py2exe.
>
> It seems the use of __file__ to find the location of the module in
> materials.py is not very portable as __file__ becomes the name of the .exe
> when compiled into a standalone program.
>
> I have found that you can modify materials.py, at about line 151, thus:
>
> ...
> import sys
> if hasattr(sys,'frozen') and (sys.frozen=="windows_exe" or
> sys.frozen=="console_exe"):
> texturePath="visual\\"
> else:
> texturePath = os.path.split( __file__ )[0] + "/"
> del sys
> ...
>
> and then add to your setup.py something like:
>
> ...
> import sys,glob
> ...
> visual_materials = ( r'visual',
> glob.glob(sys.exec_prefix+'\\Lib\site-packages\\vis\\*.tga' ))
> ...
> setup(
> data_files = [visual_materials], ...etc...
> ...
>
> This creates a \visual\ folder in your distribution and that contains the
> missing bitmaps.
>
> Please consider adding the above fix to the visual materials module.
>
> However I still don't think this is ideal.
> I think it should be possible to use img2py (from wxPython) to embed the
> images in a file if the code is frozen (i.e. has been .exe'd)
>
> A more impressive solution would be to make it such that they are only
> loaded if an instance of a material that uses them is created, but I am not
> confident with the inner workings of visual to make that so.
>
> Cheers,
> Jason
>
>
>
> ------------------------------------------------------------------------------
> The demand for IT networking professionals continues to grow, and the
> demand for specialized networking skills is growing even more rapidly.
> Take a complimentary Learning@Cisco Self-Assessment and learn
> about Cisco certifications, training, and career opportunities.
> http://p.sf.net/sfu/cisco-dev2dev
> _______________________________________________
> Visualpython-users mailing list
> Vis...@li...
> https://lists.sourceforge.net/lists/listinfo/visualpython-users
>
>
|