Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Wednesday, 2 February 2011

A python script to extract 64 bit opengl binaries (java processing)

Update 21 March 2011 this script is redundant for vanilla processing if you download version >= 0194.

Larry Kyrala wrote a nice ruby script to do this, but not everyone has ruby (but you've got to have python on linux). Actually this is warm-up, what I intended to do was create a similar script for processing.py.


#!/usr/bin/env python
# script to fix opengl processing for 64-bit linux
# needs to be run in the home directory of processing
# backs-up original 32 bit binaries

import os
import os.path 
import shutil  # cross platform support
import glob
import zipfile

home = os.getcwdu()
processing_dir = os.path.join(home, "processing-0191")

library_dir = os.path.join(processing_dir, "libraries", "opengl", "library")
backup_dir = os.path.join(library_dir, "original-native")
unpack_dir = os.path.join(library_dir, "unpack-amd64")
if (os.path.exists(backup_dir)):
    pass
else:  
    os.mkdir(backup_dir, 0777)
if (os.path.exists(unpack_dir)):
    pass
else:  
    os.mkdir(unpack_dir, 0777)  

alljars = glob.glob(os.path.join(library_dir,"*.jar")) 
jars64 = []
for jar in alljars:
    if jar.endswith("linux-amd64.jar"):
      jars64.append(jar)

for jar64 in jars64:
    zfobj = zipfile.ZipFile(jar64)
    for name in zfobj.namelist():
        if (name.endswith('/')):
            pass
        elif (name.endswith(".so")):
            outfile = open(os.path.join(unpack_dir, name), 'wb')
            outfile.write(zfobj.read(name))
            outfile.close()

libraries = glob.glob(os.path.join(unpack_dir, "*.so"))
for so_file in libraries:
        src = os.path.join(library_dir, os.path.basename(so_file))
        if (not os.path.exists(os.path.join(backup_dir, os.path.basename(so_file)))):

            shutil.move(src, backup_dir)
            shutil.copy(so_file, library_dir) 

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2