Skip to content

Building an APAF application on Windows

fpietrosanti edited this page May 19, 2012 · 20 revisions

Introduction

This how-to will guide you in the preparation of build environment for Apaf applications for Windows with all it's own dependencies.

Requirements

Download and verify

TODO: Hellais to setup

http://files.gpg4win.org/Beta/gpg4win-2.1.1-34299-beta.exe

Launch kleopatra

Settings -> Configure Kleopatra -> New

Lookup on certificates server:

Import key: 0x7D9DC8D2

File -> Decrypt/Verify files -> Find the file of python-2.7.3.msi -> Input file python-2.7.3.msi.asc -> Decrypt/Verify

Install Python for Windows

Download

http://www.python.org/download/releases/2.7.3/

http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi

Verify signature of application:

http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi.asc

Install the software.

Install 7zip

http://downloads.sourceforge.net/sevenzip/7z920.exe

This will install 7zip in "C:\Program Files\7-Zip\7z.exe"

install setuptools

http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe#md5=57e1e64f6b7c7f1d2eddfc9746bbaf20

Install Twisted

http://twistedmatrix.com/trac/

http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.0.0.win32-py2.7.msi

Install zope.interface

Now start a cmd and install Zope core dependancy:

C:\Python27\Scripts\easy_install.exe zope.interface

Install pip

Now start a cmd and install pip:

C:\Python27\Scripts\easy_install.exe pip

Install psutils

Required for txtorconn

http://code.google.com/p/psutil/ http://psutil.googlecode.com/files/psutil-0.4.1.win32-py2.7.exe

Install PyGeoIP

Now start a cmd and install PyGeoIP txtorconn's dependancy:

C:\Python27\Scripts\pip.exe install pygeoip

Install IpAddr

Now start a cmd and install IpAddr txtorconn's dependancy:

C:\Python27\Scripts\pip.exe install ipaddr

Install Pywin32

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/pywin32-217.win32-py2.7.exe/download

Install Py2exe

http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download

Patch Twisted

Twisted have a bug that prevent it from working fine with TxTorcon

To fix it, edit the file "C:\Python27\lib\site-packages\twisted\internet\process.py" and comment out the call to the following function:

''- detectLinuxBrokenPipeBehavior()''
''+ # detectLinuxBrokenPipeBehavior()''

Install Txtorconn

https://github.com/meejah/txtorcon/

Download Apaf ZIP archive and extract the file meejah-txtorcon-XXXXX into your working directory: https://github.com/meejah/txtorcon/zipball/master

To install txtorcon use it's setup.py rather than easy_install (there's a bug).

Move on the working directory where it has been downloaded. For example in path "C:\Documents and Settings\VM\Desktop\apaf\meejah-txtorcon-v0[1].1-40-g8132bce\meejah-txtorcon-8132bce" start:

cd "C:\Documents and Settings\VM\Desktop\apaf\meejah-txtorcon-v0[1].1-40-g8132bce\meejah-txtorcon-8132bce"

start now:

c:\Python27\python.exe setup.py install

C:\Documents and Settings\VM\Desktop\apaf\meejah-txtorcon-v0[1].1-40-g8132bce\me
ejah-txtorcon-8132bce>c:\Python27\python.exe setup.py install

Test Python dependency installation

Now test that twisted and py2exe can be successfully imported: Start -> All Programs -> Python 2.7 -> Python

import twisted

import py2exe

import psutil

import txtorcon

import ipaddr

import pygeoip

import pywin32

Download Apaf

Download Apaf ZIP archive and extract the file mmaker-APAF-XXXXX into your working directory: https://github.com/mmaker/APAF/zipball/master

Enter into the working directory, for example:

cd "C:\Documents and Settings\VM\Desktop\apaf\mmaker-APAF-f059782\mmaker-APAF-f059782"

Download Tor

Download the latest version of Tor binaries for Windows.

Go to download page https://www.torproject.org/download/download.html.en and download "Expert Bundle": https://www.torproject.org/dist/win32/tor-0.2.2.35-win32-1.exe

Now decompress the tor binary with 7zip and move it to contrib/tor/ directory of APAF:

c:\Program Files\7-Zip\7z.exe" x tor-0.2.2.35-win32-1.exe tor.exe
move tor.exe PATH_WHERE_IS_BUILD_ENVIRONMENT/contrib/tor

Build the Apaf application into a win32 executable

Then to build the .exe:

C:\Python27\python.exe setup.py py2exe

Now check the resulting file in "dist\run.exe"


C:\Documents and Settings\VM\Desktop\apaf\mmaker-APAF-f059782\mmaker-APAF-f059782> dir dist\run.exe
 Volume in drive C has no label.
 Volume Serial Number is 80B6-BA0E

 Directory of C:\Documents and Settings\Administrator\dist

05/18/2012  12:14 AM            19,456 run.exe

Start the daemon by executing "dist\run.exe"

Test by loading http://127.0.0.1:4242