Building PyCrypto-2.5 using MinGW and Python 2.7 on Windows XP

Hi there!

It took me some time to figure this out. I hope this page provides the info that you require. What I wanted to do was to install PyCrypto ( on Windows XP. Due to law restrictions, the PyCrypto website doesn’t supply binaries. I have the Python 2.7.2 installed and MinGW as compiler. For more information about setting up Python and MinGW, see my previous post.

First I tried to use the ‘so called’ easy_install setuptools method: easy_install pycrypto

Nice try, but no cigar. Apparently there’s more to it, since it fails with the following error:
error: Unable to find vcvarsall.bat

Well at least we know where the PyCrypto source package came from. 🙂

  1. After downloading the package, open a windows command prompt.
  2. Move to the directory which contains the source.
  3. Extract the package: tar -zxvf pycrypto-2.5.tar.gz
  4. Move to the new directory: cd pycrypto-2.5
  5. Build the package: python build -c mingw32
  6. Install the package: python install
  7. Tip: If you want to build binary installable package which you can distribute, execute the following command: python bdist_wininst

If the building is successful, you can find the executable in the ‘dist’ directory named: ‘pycrypto-2.5.win32-py2.7

Posted in MinGW, Programming, Python | 5 Comments

Setup Python 2.7.2 and MinGW on Windows XP

This post demonstrates how to setup and configure Python 2.7.2 and MinGW on Windows XP.

MinGW Installation

You can get the MinGW installer from here.

When you run it, please select ‘download latest repository catalogues’. Next you select a folder (i.e. C:\MinGW) and the programming support you require: C and C++ (I leave Fortran and ObjC deselected). It’s a must to have the MinGW Developer Toolkit installed as well, if you select this option you’ll get MSYS as well. (The basic must have commands like awk).

Next you have to configure your PATH environment variable.

  1. Right-click on this computer and select properties
  2. Go to the tab ‘Advanced’ and select ‘Environment variables’
  3. Select ‘Path’ from the ‘System Variables’ and click the ‘Edit button’
  4. Add the following paths to your variables: ‘C:\MinGW\bin;C:\MinGW\msys\1.0\bin;’
  5. Test them by opening a command prompt and typing the commands ‘gcc’ and then ‘awk’
  6. Tip: If you want to check your environment variables in the command prompt, use the command ‘echo %PATH%’. If you change your variables, you have to reopen the command prompt to have the new settings work.

Python Installation

Next it’s time to install Python! You can get the python installer from here.

When you install it, you have to specify a installation location i.e. C:\Python27

After the installation I recommend to install a handy tool that will easy setup of packages, named ‘setuptools’. This package is available here:

Again, you have to configure your PATH environment variable to be able to use the ‘python’ and the ‘easy_install’ command directly.

  1. Add the following paths to your PATH system variable: ‘C:\Python27;C:\Python27\Scripts;’

Post-configuration steps

Now we need to configure Python’s compiler to be MinGW.

  1. Create the following file: C:\Python27\Lib\distutils.cfg
  2. Add the following content:
  3. Save the file

You might encounter the following issue when compiling Python software using MinGW:
gcc: error: unrecognized command line option '-mno-cygwin'

You can fix this easily by editing the following file: C:\Python27\Lib\distutils\

Look for the class: Mingw32CCompiler

Alter the executables, so that the deprecated option is now deleted:

self.set_executables(compiler='gcc -O -Wall',
compiler_so='gcc -mdll -O -Wall',
compiler_cxx='g++ -O -Wall',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,

There, you should be ready to play new development environment!

Posted in MinGW, Programming, Python | 5 Comments

Increase Firefox browsing security

Even some of my most frequently used web sites, like google search, youtube and Dutch news websites are getting on my nerves. To give you an example; yesterday I noticed that youtube served Scientology advertisements in between songs I was listening. Since I decided that it was time to take back control of the web.

Lots of website have tracking scripts to monitor you, they place it in 1×1 pixel images, hide it in the background etc. You can’t take forever to filter this out manually, so therefore I’ve listed two must have Firefox add-ons:

Ghostery –

Ghostery sees the invisible web – tags, web bugs, pixels and beacons. Ghostery tracks the trackers and gives you a roll-call of the ad networks, behavioral data providers, web publishers, and other companies interested in your activity.

NoScript –

The NoScript Firefox extension provides extra protection for Firefox, Seamonkey and other mozilla-based browsers: this free, open source add-on allows JavaScript, Java, Flash and other plugins to be executed only by trusted web sites of your choice (e.g. your online bank). NoScript also provides the most powerful anti-XSS and anti-Clickjacking protection ever available in a browser.

Some additional tips:

Disable unused / unsafe firefox add-ons i.e. toolbars
Install a smart proxy to filter adds like Privoxy –

Posted in Security | 1 Comment

The new years post

Hi everyone,

I just wanted to say I’m quite late with posting the first post for 2012. I guess the all the holidays and getting unemployed are the biggest reasons for not staying in touch. Anyway, so there it is… I’m looking for a new job and went on holiday twice. It was so nice being abroad together with my girlfriend and celebrate NYE in one of Europe’s most beautiful country, Ireland! Our destination was Belfast and later we moved by train to Dublin. Belfast is full of signs (murals) depicting the long lasting (historical) troubles between Irish Catholics and Protestants / Loyalists. Belfast is quite small compared to major cities, but very nice and friendly inhabitants.

Furthermore, I went on my first holiday ever in Austria. It lasted just a bit more than a week, but I was shocked that I never discovered the beauty and fun of seeing Europe’s mountains and do some snowboarding. I picked up the technique of snowboarding fast, but after 3,5 days of fun I flipped over and broke my upper arm bone. This hurts like hell, but it’s getting better. Only getting up in the morning at 5AM in agonising pain is just such a major bummer.

Posted in Uncategorized | Leave a comment

Obtaining a proper list of installed packages on Red Hat

On Red Hat Enterprise Linux there is the rpm command to install and query packages. Of course this command is also available on Red Hat derivatives as CentOS, Fedora and more. However standard use of the rpm command will show just basic information i.e.:

# rpm -qa sysstat

This information is useful but doesn’t help when you want to compare the installed packages on two systems. I use the following query to get the full list of installed packages with proper file name including architecture and release version (as they appear on the installation media):

# rpm -qa --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n' | sort | uniq > RH_packages.txt

You can also use this information to make a stripped down version of the installation media image which I will demonstrate in a later post.

Posted in Linux, Red Hat | Leave a comment

A memorable quote

I say never be complete. I say stop being perfect. I say let’s evolve. Let the chips fall where they may.
– Fight Club, Chuck Palahniuk

Posted in Uncategorized | Leave a comment

Using pidstat to gather process statistics

Pidstat is a statistics report tool for Linux which is part of the sysstat utilities. You can capture the CPU and memory utilization easily for processes. You can use PID’s and even regular expressions on the process names to filter them out.

# Filter on processes with regular expression that will match commands proc_a, proc_b, proc_c with an interval of 5 seconds:
$ pidstat -C 'proc_a|proc_b|proc_c' -hur -p ALL 5

You can output this information to a file. After you captured your file you can create csv file (comma separated values format) out of this raw data for plotting it in a spreadsheet processor like Microsoft Excel. I use sed to do so:

# remove the first line, lines that start with a hash, lines that are empty, remove the starting space and finally replace space(s) with a comma:
sed '1d;/^[#]/d;/^$/d;s/^[ ]*//;s/[ ]\+/,/g' raw_data_file_input > nice_data_file.csv

Posted in Linux | Leave a comment

Arch Linux Sick Beard init script

Sick Beard is a nice open source PVR for newsgroup users which keeps track of your favourite TV shows. The website is located here. The source is available at github.

I noticed that there are a lot of strange init script examples out there to start and stop Sick Beard as a daemon under Linux. For Arch Linux I found multiple that use sudo to start and wget or curl to stop the program using the HTTP interface. Why would you possibly want to do that in the first place?

If you take a quick look in the executable Python script you’ll notice that Sick Beard provides a way to start as a daemon and also the option to create a PID file exists. With those two command line switches and the knowledge that the program is able to handle signals I decided it would be nice to write my own Sick Beard init script for Arch Linux.

This is the daemon configuration script, it is located under: /etc/conf.d/sickbeard.conf.


As you see I save the PID file under the /var/run/user/ directory. It should always be discouraged to run daemons as root user. However when you are running a daemon as regular user, make sure you have correct permission to the directory for storing the PID file. You’ll likely lack permission for storing the PID file in the /var/run/ directory (since that directory is owned by root). So if you create a subdirectory and change the ownership to the designated user you’ll have a nice placeholder for your daemons.

This is the init script for the daemon, it is located under: /etc/rc.d/sickbeard


. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/sickbeard.conf

case "$1" in
stat_busy "Starting Sick-Beard"

if [ -f $SB_PIDFILE ]; then
echo "Sick-Beard is already running: $PID"

su - $SB_USER -c "$SB_PYTHON $SB_BIN -q -d --config $SB_CONF --port $SB_PORT --pidfile $SB_PIDFILE" -s /bin/sh
if [ $? -gt 0 ]; then
add_daemon sickbeard
stat_busy "Stopping Sick-Beard"

if [ -f $SB_PIDFILE ]; then
kill -TERM $PID
rm_daemon sickbeard
$0 stop
sleep 1
$0 start
echo "usage: $0 {start|stop|restart}"
exit 0

When setting the executable permissions for this script you should be ready to go!

# /etc/rc.d/sickbeard start
:: Starting Sick-Beard [PASS]

You can start Sick Beard at boot time by adding it to the /etc/rc.conf file under the following section (ommit the dots):

DAEMONS=(... sickbeard ...)

Posted in Arch Linux, Linux | 7 Comments

Back home

Ja, het is alweer een maand geleden dat ik zonder kleerscheuren thuis ben gekomen. Het was te gek om m’n hele familie met zelfgemaakt bord mij te zien opwachten op Schiphol Airport. Helaas had de webfuhrer deze dagen het een beetje te druk met werk, sociale zaken, mooi weer scenario’s, concerten en ook nog het fantastische Roadburn festival. Hierdoor ben ik m’n website een beetje uit het oog verloren. Ik beloof plechtig snel een complete collectie foto’s naar boven te laden en nog een lijstje vol onzinfeiten over de reis neer te zetten. Ajuus en bedankt voor het volgen!

Posted in Uncategorized | Leave a comment

Andaman, Havelock Is.

Beste thuisblijverts! Maarten en yours truly hebben zich ontzettend goed vermaakt op Havelock Island op Andaman! Het ultieme paradijsgevoel hier versloeg de stranden van Sri Lanka. Chillen in je hangmat, Kingfisher uit de koeling en gezellig feestjes bouwen zijn hoofdzaken in de dagbesteding. Ik ben na 4 dagen officieel een Open Water Diver geworden en Maarten Advanced Diver. Kleine domper was de regen op de laatste dagen en een kokosnoot die op m’n voet gevallen was (joepie! ik leef nog! kansberekening). Om het strandleven te eren hebben deze heren besloten om hun laatste dagen van de India reis in Goa door te brengen. Een zonnige groet vanuit Vagator!

Posted in Uncategorized | Leave a comment