Cribbed from http://www.haskell.org/haskellwiki/Mac_OS_X#Mac_OS_X_10.6_.28Snow_Leopard.29:
“
* Open /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc-6.10.4 in a text editor
* Insert -optc-m32 -opta-m32 -optl-m32 just before the last parameter.
The last line in that file is rather long, and should now end like -dynload wrapped -optc-m32 -opta-m32 -optl-m32 ${1+”$@”}
Don’t be tempted to just put an edited local copy of the script in ~/bin/ghc, or edit all the various GHC files in /usr/bin. There is a maze of twisty symlinks that all eventually lead to the above script, and fixing just it is far simpler. Many packages need hsc2hs. To make it work correctly you need similar hackery:
* Open /usr/bin/hsc2hs
* Insert –cflag=”-m32″ –lflag=”-m32″ before $tflag
“
Filed under: Uncategorized | Leave a Comment
I’ve just had to do it again…
Install Cabal that is. This time (many thanks once again jan) I’m putting out the details inline.
ghc –make Setup.hs
./Setup configure
./Setup build
sudo ./Setup install
Download HTTP and zlib from HackageDB:
ghc –make Setup.lhs (.lhs in case of HTTP, zlib uses the .hs extension)
./Setup configure
./Setup build
sudo ./Setup install
Change into the cabal-install directory and repeat these steps again. Run cabal update to obtain the latest package list.
Filed under: Uncategorized | Leave a Comment
Just ran through the instructions here and my firefox/flash setup is sorted. Nice.
Filed under: Uncategorized | Leave a Comment
fixing git-svn woes
At work we mostly use subversion for revision control, although some of the cooler kids are using git. I find subversion a bit of a pain compared to git, so I use the git-svn wrapper to get the best of both worlds whilst at work. Since upgrading to the latest Ubuntu however, I’ve noticed that a clash between gnutls and open-ssl causes git/subversion integration to fail. A fellow git-ite pointed out a quick fix however!
$ sudo rm /usr/lib/libneon-gnutls.so.27
$ sudo ln -s /usr/lib/libneon.so.27 /usr/lib/libneon-gnutls.so.27
Works a treat.
Filed under: Uncategorized | Leave a Comment
I ran into a problem installing (wait for it…..) Borland Together 2007 (gasp!) on Ubuntu this morning. The binary installation package failed to load with an interesting stack trace:
An internal LaunchAnywhere application error has occured and this application cannot proceed. (LAX)
Stack Trace:
java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
at java.util.Properties.loadConvert(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.zerog.common.java.util.PropertiesUtil.loadProperties(DashoA8113)
at com.zerog.lax.LAX.<init>(DashoA8113)
at com.zerog.lax.LAX.main(DashoA8113)
After some googling around, I discovered that Launch Anywhere often screws around with PS1, so changing this for the current shell resolves the issue:
$ export PS1=">"
And after that everything works fine (apart from having to use Together 2007 in the first place).
Filed under: Uncategorized | Leave a Comment
quote for today
In ancient times skillful warriors first made themselves invincible,
And then watched for vulnerability in their opponents.
Making yourself invincible means knowing your self,
Seeing vulnerability in opponents means understanding others.
Sun Tzu ~ The Art of War
Filed under: Uncategorized | Leave a Comment
pattern matching in python?
Well, not really pattern matching as such, but I’ve taken to blanking out unwanted values when unpacking a sequence. The (visual) effect looks a lot like a pattern match, even though it is nothing of the sort. I’m not sure what folks from a non-functional background would make of this coding style (some will probably hate it), but to a happy FP advocate like myself, this clearly communicates the intent of the code (which is to ignore certain values).
def path_components(uri):
(_,_,relative_path,_,_) = urlsplit(uri)
return filter(lambda x: len(x) > 0, relative_path.split('/'))
I like it anyway. :p
Filed under: Uncategorized | Leave a Comment
using awk inside makefiles
Got bitten by this early in the morning. When using awk inside a makefile, many of awk’s built-in variables ($0..n, $NF, $FS, etc) disappear because make substitutes the dollar sign and first letter out into a (presumably) undefined value, leaving you with a mess that doesn’t work.
After a little time with google, it transpires that the solution is to use two dollar signs, which make doesn’t interpolate, leaving you with a working script and leaving me with only this horror to content with (some formatting changes made so wordpress renders correctly)
find src -type f
| awk -F "/"
'{ print substr($$0, 0, index($$0, $$NF) - 1) }'
| sort -u
| awk -v cwd=$(CWD) '{
print "{""\""$$0"*\",[\ndebug_info,\n{outdir, "
"\"""ebin""\"""}\n
{i,"cwd"/include}\n]""}." }' >> Emakefile
Filed under: builds | 1 Comment
Tags: awk, make, shell-scripting
testing django with badrabbit
One of the design decisions I made when writing badrabbit was to make it fully compatible with unittest (one of the two unit testing frameworks that come with the python stdlib). My reasoning was twofold, firstly to minimize the amount of disruption caused by having to learn a new API and secondly, to give folks a chance to integrate badrabbit’s mocking library and test decorator syntax in to existing tests with a minimum of fuss.
This decision paid off recently when I tried integrating badrabbit unit tests into a django application. Django has built in support for running unit tests as part of the development lifecycle. The manage.py script that gets generated when you run django’s equivalent of Rails’ scaffolding, takes one of a several commands and one of these is ./manage.py test <appname>.
This has the effect of going off a running all your tests, where the tests for an application are either in your model definition (models.py) a file named tests.py, or contained in (multiple) modules in a package of the same name. By default as described here, django will go off and look for tests defined with the unittest and doctest frameworks, both of which are part of python’s stdlib. You can override this behavior by providing your own test runner and doing so is, in fact, ridiculously easy. Nevertheless, this isn’t neccessary because badrabbit is 100% compatible with unittest. And so all you need do to use it in your tests is put and import statement in your script, subclass badrabbit.testmagic.autotest instead of unittest.TestCase and you’re off. Here’s an abridged example:
#!/usr/bin/env python
import badrabbit
from badrabbit import *
from users.models import ServiceUser
class ServiceUserTests(autotest):
@test
def it_should_set_absolute_uri_correctly(self):
user = ServiceUser(username='Johannes')
assert_that(user.get_absolute_url(),
equal_to("/users/Johannes/"))
Of course, django has its own subclass of unittest.TestCase already, making subclassing badrabbit.testmagic.autotest less attractive (not least since they share the same superclass!) so there is another way. If you were to go take a peek at the implementation of badrabbit’s autotest class you would soon notice that it does nothing apart from setting the metaclass to AutoTest:
class AutoTestCase(unittest.TestCase):
__metaclass__ = AutoTest
autotest = AutoTestCase
So instead of subclassing autotest you can just as well set the metaclass (in exactly this way) on your own test class which can then happily subclass django’s TestCase instead.
I can’t imagine the integration being much simpler really. Because badrabbit depends on hamcrest-python, which doesn’t appear to come with an installer, we stuck it a couple of directories above our code and run the manage.py utility using a wrapper shell script which configures the PYTHON_PATH environment variable to include this first.
Filed under: TDD, badrabbit, open source, python | Leave a Comment
Recent Entries
- Getting GHC/Cabal-Install working on Snow Leopard
- Archived flash players for testing…
- I’ve just had to do it again…
- Getting the firefox flash plugin working on Ubuntu
- fixing git-svn woes
- Launch Anywhere fails on Ubuntu 9
- quote for today
- pattern matching in python?
- using awk inside makefiles
- testing django with badrabbit
- urlconf for erlang