[vtkusers] VTK post-install for Python [Win32]

Eric Boix frog at creatis.insa-lyon.fr
Sun Jan 20 09:57:56 EST 2002


	Dear users,

	On unices the VTK postinstall stage for Python (that is doing the
necessary for the command python -c 'import vtkpython' to work) can be nicely
handled by packaging mecanism (say rpm :). On Win32, AFAIK, the precompiled
binaries self-installers, as given by Kitware, miss this post-install step.
If you are a wxPython user this lieds to the failure of the demo of the
wxVTKRenderWidget (wxPython Library section of the demo.py of wxPython).
      Independently from wxPython, using vtkpython on Win32 imposes to the
user to manually realize this post-install step : and unless you are
using the wonderfull bash shell from Cygwin, you won't be able to use
the PYTHONPATH trick...

	In order to achieve this post-install step, I see four possible
solutions :
 * modify the Win32 installers so they realize it (this means KitWare does
   the job). I'm not a WIn32 packager (casual use of MyInno) and I don't
   know how far this can lead to.

 * Handle it manually, [what I do for the time being] : suppose Python
   was installed in Python21HOME and VTK in vtkNightly directories :
    - create a vtkpython sub-directory in Python21HOME\Lib 
    - Copy all the dll from vtkNightly\bin to the newly created 
      Python21HOME\Lib\vtkpython (the vtk*TCL.dll come alltogether but
      who cares).
    - Copy all the .py python files from vtkNightly\Wrapping\Python to
      Python21HOME\Lib\vtkpython 
    - In Python21HOME\Lib\vtkpython rename the vtkpython.py file to __init__.py 

 * Use Python distutils module. I've written a small setup.py (see the end
   of email) which users can use by a double click (my users are big mouse
   addicts). Still for this schema to work I couldn't avoid some manual
   steps :
    - Rename vtkNightly\Wrapping\Python\vtkpython.py to __init__py
    - Rename vtkNightly\Wrapping\Python to vtkNightly\Wrapping\vtkpython
    - launch setup.py
   Hence for this to be easier, it would require the hierarchy of vtkNightly
   (as deployed by the VTK Win32 installers) to be sligthly different :
   either rename Python subdir to vtkpython or introduce another subdirectory
   with this name, and rename the contained vtkpython.py to __init__.py.

 * Use the vtkpython.pth import trick. This simply requires creating a
   file containing the pathes to the vtk*Python.dll and the vtk *.py scripts
   (no renaming needed). Alas I cound't automatize this mecanism with 
   Python : I ended up with unsolvable problems (to me) when either
   Python or vtkNightly are not installed on the same partition.

How to improve all this, and get things as fully automatic as they can be
without putting to much pressure on the KitWare folks ?

	Yours,
	Eric Boix.

--------------------------------------------------------------------
#### A setup.py for VTK on WIn32
from distutils.core import setup
import os
import sys
import glob

# Defaulting an install when no arguments are given
if not sys.argv[1:]:
   sys.argv.append("install")

# On Unices, rpm avoids this postinstall step :
if os.name == 'posix':
   print '  Use the rpm mecanism.'
   sys.exit()

# The site-package equivalent on Win32 seems to be Lib/
targetDir='Lib'
PackageName='vtkpython'


##########################
setup(name="VTK",
      version="4.X",
      description="VTK",
      url="http://public.kitware.com/VTK",
      packages=[PackageName],
      extra_path = targetDir,
      data_files=[(os.path.join(targetDir,PackageName),
                  glob.glob(os.path.join('..','bin','*.dll')))],
     )




More information about the vtkusers mailing list