Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
catenary
committed
Mar 27, 2010
1 parent
b30d2c7
commit fb2bd85
Showing
30 changed files
with
1,144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
This version of Gnofract 4D is distributed under the BSD License. | ||
|
||
Note that earlier versions (versions 1.0 to 1.9 inclusive) were | ||
distributed under the GNU GPL. | ||
|
||
Copyright (c) 1999-2006, Tim Whidbey | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following disclaimer | ||
in the documentation and/or other materials provided with the | ||
distribution. | ||
|
||
* Neither the name of Tim Whidbey nor the names of any other | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import os | ||
from time import time as now | ||
|
||
class Benchmark: | ||
def __init__(self, command, args): | ||
self.last_time = None | ||
self.pos = 0 | ||
self.args = args | ||
self.command = command | ||
|
||
def build(self): | ||
cmd = self.command + " --buildonly foo.so " + self.args | ||
print cmd | ||
result = os.system(cmd) | ||
assert result == 0 | ||
|
||
def run(self): | ||
last_time = now() | ||
result = os.system(self.command + " --usebuilt ./foo.so " + self.args) | ||
assert result == 0 | ||
new_time = now() | ||
return new_time - last_time | ||
|
||
repeats = 1 | ||
command = "./gnofract4d -i 2560 -j 2048 --nogui " | ||
args = "" | ||
for arg in sys.argv[1:]: | ||
if arg == "--repeat": | ||
repeats = 5 | ||
else: | ||
args += " " + arg | ||
|
||
bench = Benchmark(command, args) | ||
bench.build() | ||
times = [] | ||
for i in xrange(repeats): | ||
t = bench.run() | ||
print t | ||
times.append(t) | ||
|
||
print "stats" | ||
print "min:(%.4f), max(%.4f), average(%.4f)" % (min(times), max(times), sum(times)/len(times)) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import os | ||
import getopt | ||
import operator | ||
from time import time as now | ||
|
||
# gettext | ||
import gettext | ||
os.environ.setdefault('LANG', 'en') | ||
if os.path.isdir('po'): | ||
gettext.install('gnofract4d','po') | ||
else: | ||
gettext.install('gnofract4d') | ||
|
||
import gtk | ||
|
||
from fract4d import fractmain, image | ||
from fract4dgui import main_window | ||
|
||
files = [ | ||
'testdata/std.fct', | ||
'testdata/param.fct', | ||
'testdata/valley_test.fct', | ||
'testdata/trigcentric.fct', | ||
'testdata/zpower.fct' | ||
] | ||
|
||
class Benchmark: | ||
def __init__(self, useGui): | ||
self.last_time = None | ||
self.pos = 0 | ||
self.useGui = useGui | ||
self.w = 320 | ||
self.h = 240 | ||
|
||
def run_gui(self): | ||
|
||
window = main_window.MainWindow() | ||
|
||
window.f.set_size(self.w,self.h) | ||
window.f.thaw() | ||
|
||
times = [] | ||
self.last_time = now() | ||
|
||
def status_changed(f,status): | ||
if status == 0: | ||
# done | ||
new_time = now() | ||
times.append(new_time - self.last_time) | ||
self.last_time = new_time | ||
self.pos += 1 | ||
if self.pos < len(files): | ||
window.load(files[self.pos]) | ||
else: | ||
gtk.main_quit() | ||
|
||
window.f.connect('status-changed', status_changed) | ||
window.load(files[0]) | ||
gtk.main() | ||
return times | ||
|
||
def run_nogui(self): | ||
main = fractmain.T() | ||
print main.compiler.path_lists | ||
times = [] | ||
last_time = now() | ||
for file in files: | ||
main.load(file) | ||
im = image.T(self.w,self.h) | ||
main.draw(im) | ||
im.save(file + ".png") | ||
new_time = now() | ||
times.append(new_time - last_time) | ||
|
||
return times | ||
|
||
def run(self): | ||
if self.useGui: | ||
times = self.run_gui() | ||
else: | ||
times = self.run_nogui() | ||
|
||
for (file,time) in zip(files,times): | ||
print "%.4f %s" % (time,file) | ||
|
||
print reduce(operator.__add__,times,0) | ||
|
||
useGui = True | ||
repeats = 1 | ||
for arg in sys.argv[1:]: | ||
if arg == "--nogui": | ||
useGui = False | ||
if arg == "--repeat": | ||
repeats = 3 | ||
|
||
for i in xrange(repeats): | ||
bench = Benchmark(useGui) | ||
bench.run() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env python | ||
|
||
# Override the default bdist_rpm distutils command to do what I want | ||
|
||
import re | ||
import glob | ||
import os | ||
import sys | ||
|
||
from distutils.command.bdist_rpm import bdist_rpm | ||
from distutils.core import Command | ||
|
||
topdir_re = re.compile(r'.*topdir (.*)') | ||
|
||
class my_bdist_rpm (bdist_rpm): | ||
user_options = bdist_rpm.user_options | ||
def __init__(self, dict): | ||
bdist_rpm.__init__(self,dict) | ||
|
||
def insert_after(self,spec, find,add): | ||
for i in xrange(len(spec)): | ||
if spec[i].startswith(find): | ||
spec.insert(i,add) | ||
return | ||
|
||
def replace(self,spec,find, new): | ||
for i in xrange(len(spec)): | ||
if spec[i].startswith(find): | ||
print "replacing %s with %s" % (spec[i], new) | ||
spec[i] = new | ||
return | ||
|
||
def add_to_section(self,spec,sect,add): | ||
found = False | ||
for i in xrange(len(spec)): | ||
if spec[i].startswith(sect): | ||
found = True | ||
elif spec[i].startswith('%'): | ||
if found: | ||
spec.insert(i,add) | ||
return | ||
if found: | ||
# this is the last section | ||
spec.insert(i,add) | ||
else: | ||
raise IndexError("sect %s not found" % sect) | ||
|
||
def spawn(self,cmd): | ||
'''HACK: On FC4 rpmbuild creates 2 RPMS, the normal one and a | ||
debuginfo one. This horrifies the bdist_rpm which comes with pythons | ||
older than 2.4 - these only expect 1 RPM. This works around | ||
that by deleting the extraneous debuginfo RPM. Overriding this | ||
method rather than run() because there's less code. ''' | ||
bdist_rpm.spawn(self,cmd) | ||
v = sys.version_info[0] * 10 + sys.version_info[1] | ||
if v < 24 and cmd[0] == "rpmbuild": | ||
for arg in cmd: | ||
m = topdir_re.match(arg) | ||
if m: | ||
print "doing 2.3-cleanup" | ||
dir = m.group(1) | ||
debuginfo_glob = os.path.join( | ||
dir,"RPMS", "*", "*debuginfo*") | ||
rpms = glob.glob(debuginfo_glob) | ||
print "found extraneous rpms", rpms | ||
for rpm in rpms: | ||
os.remove(rpm) | ||
|
||
|
||
def _make_spec_file(self): | ||
'''HACK: override the default PRIVATE function to specify: | ||
AutoReqProv: no | ||
add some commands to update mime types | ||
''' | ||
|
||
spec = bdist_rpm._make_spec_file(self) | ||
|
||
# reduce the number of explicit pre-requisites | ||
self.insert_after(spec, 'Url','AutoReqProv: no') | ||
|
||
# remove an old tag that newer rpmbuilds dislike | ||
self.replace(spec, 'Copyright', 'License: BSD') | ||
|
||
# install a .desktop file and register .fct files with ourselves | ||
self.insert_after(spec, '%define', '%define desktop_vendor ey') | ||
self.add_to_section(spec, '%install', ''' | ||
%post | ||
update-mime-database %{_datadir}/mime &> /dev/null || : | ||
update-desktop-database &> /dev/null || : | ||
%postun | ||
update-mime-database %{_datadir}/mime &> /dev/null || : | ||
update-desktop-database &> /dev/null || : | ||
''') | ||
|
||
print "SPEC>" | ||
print "\n".join(spec) | ||
print "EOF>" | ||
|
||
return spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python | ||
|
||
# Override the default build distutils command to do what I want | ||
|
||
from distutils.command.build import build | ||
from distutils.core import Command | ||
|
||
class my_build (build): | ||
user_options = build.user_options | ||
def __init__(self, dict): | ||
build.__init__(self,dict) | ||
|
||
new_commands = [] | ||
for (name,pred) in build.sub_commands: | ||
if name == "build_ext": | ||
name = "my_build_ext" | ||
new_commands.append((name,pred)) | ||
|
||
build.sub_commands = new_commands | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
|
||
# Override the default build distutils command to do what I want | ||
|
||
from distutils.command.build_ext import build_ext | ||
from distutils.core import Command | ||
import os | ||
import re | ||
|
||
remove_mtune = re.compile(r'-mtune=\w*') | ||
|
||
class my_build_ext (build_ext): | ||
user_options = build_ext.user_options | ||
def __init__(self, dict): | ||
build_ext.__init__(self,dict) | ||
self._build_temp = None | ||
|
||
def build_extensions(self): | ||
# python2.2 doesn't honor these, so we have to sneak them in | ||
cxx = os.environ.get("CXX") | ||
cc = os.environ.get("CC") | ||
|
||
print "compiling with", cc | ||
if cc: | ||
self.compiler.preprocessor[0] = cc | ||
self.compiler.compiler_so[0] = cc | ||
self.compiler.compiler[0] = cc | ||
|
||
if cc.find("33") > -1: | ||
print "cc is old" | ||
# rpm thinks we should have -mtune, but older gcc doesn't like it | ||
cflags = os.environ.get("CFLAGS") | ||
if cflags != None: | ||
cflags = remove_mtune.sub("",cflags) | ||
print "cflags", cflags | ||
os.environ["CFLAGS"] = cflags | ||
|
||
self.compiler.compiler = [ | ||
opt for opt in self.compiler.compiler \ | ||
if opt.find("-mtune") == -1 ] | ||
|
||
self.compiler.compiler_so = [ | ||
opt for opt in self.compiler.compiler_so \ | ||
if opt.find("-mtune") == -1 ] | ||
|
||
if cxx: | ||
if hasattr(self.compiler, "compiler_cxx"): | ||
self.compiler.compiler_cxx[0] = cxx | ||
self.compiler.linker_so[0] = cxx | ||
|
||
build_ext.build_extensions(self) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# I need to be able to install an executable script to a data directory | ||
# so scripts= is no use. Pretend it's data then fix up the permissions | ||
# with chmod afterwards | ||
|
||
import os | ||
import stat | ||
|
||
from distutils.command.install_lib import install_lib | ||
|
||
class my_install_lib(install_lib): | ||
def install(self): | ||
#need to change self.install_dir to the library dir | ||
outfiles = install_lib.install(self) | ||
for f in outfiles: | ||
if f.endswith("get.py"): | ||
if os.name == 'posix': | ||
# Set the executable bits (owner, group, and world) on | ||
# the script we just installed. | ||
mode = ((os.stat(f)[stat.ST_MODE]) | 0555) & 07777 | ||
print "changing mode of %s to %o" % (f, mode) | ||
os.chmod(f, mode) | ||
|
||
return outfiles | ||
|
Oops, something went wrong.