PyOpenGL without SetupTools

Carl Banks pavlovevidence at gmail.com
Mon Oct 1 11:49:27 CEST 2007


On Oct 1, 4:04 am, seb.ha... at gmail.com wrote:
> Hi,
> I am distributing a package with a precompiled collection of modules
> and packages useful for Python based medical/biological/astronomical
> image analysis and algorithm development. (Codename: Priithon).
> For Priithon I put all modules/packages in a simple / single directory
> (tree) including one starting batch/script file. This script sets up
> PYTHONPATH to find modules at this place.
> It works fine for Windows,Linux and Mac-OSX.
>
> Now I want to upgrade everything to Python 2.5  and thought it might
> be time get PyOpengl version 3 (aka. pyOpengl-ctypes).
>
> The problem at hand is now that PyOpenGL  uses "all this setup-tools
> machinery" just to initialize the formathandlers for the different
> ways to deal with arrays. (I really need only numpy support !)
> This is done via the pkg_resources mechanism called "entry_points".
>
> Can I include a simple non-system-install of pkg_resources that makes
> at least the entry_point stuff work ?  Where do I put pyOpenGL's
> "entry_points.txt"  file ?


The simple answer is "don't bother with PyOpenGL-ctypes if you don't
have to".  Besides the hassles with binary packaging, it's quite a bit
slower then PyOpenGL 2.0.

Anyways, when I saw that I couldn't easily figure out how to register
a setuptools package by hand (the point you seem to be at now), I
resorted to using the same hack that setuptools uses to register its
packages.  Setuptools puts a pth file, something like
"ezsetup_XXXX.pth", in the site-packages directory.  The file has a
couple lines of Python code that mark the start and end of the eggs on
sys.path; then they call setuptools to postprocess and register the
eggs.

What I did was to duplicate the effect of these lines in my main
script.  I don't have it in front of me, but it was something along
these lines:

    sys.__eggindex = len(sys.path)
    sys.path.append("OpenGL-cytpes-3.0.0a7-whatever.egg")
    setuptools.register_packages()

I copied the OpenGL egg to my distro directory, and it worked.

Another possibility is to do it the "setuptools" way: by not packaging
PyOpenGL 3.0 at all, and instead marking it as a dependency.  Then,
setuptools will helpfully download it for the user.  (Personally, I
hate that scripts can recklessly download and install stuff into your
site packages without even asking; seems like a possible security hole
as well.)  But it's an option.



Carl Banks




More information about the Python-list mailing list