gytha, building on windows

| quozl@us.netrek.org | up |

Setting up a python development environment in MS Windows for gytha - a netrek client
by Zachary Uram.

(Copied from revision 1.3 dated 4th November 2010 and processed with txt2html)

  1. Download and Install Python
    1. Go to http://www.python.org/ftp/python/2.6.6/
    2. For 32-bit OSes download http://www.python.org/ftp/python/2.6.6/python-2.6.6rc2.msi For 64-bit OSes download http://www.python.org/ftp/python/2.6.6/python-2.6.6rc2.amd64.msi Note: You may have problems with py2exe if you use an earlier version of Python.
    3. Save the appropriate file to your Desktop
    4. Double click the file to launch the installer and note the install options (I used the defaults).
    5. You will probably have to add the Python installation directory to your system PATH. In Windows 7 I did this by going to Control Panel, searching on the word Environment and then selecting

      "Edit the system environment variables" and under the System Properties dialog box click on the Advanced tab then select Environmental Variables, and look under the System variables section, scroll down until you see the word Path then select it with your mouse and click Edit. Now you will see a dialog box Edit System Variable, go to the section marked Variable value: and append the Python installation directory PATH to the line you see there, there are no spaces, and make sure you add a ";" after the PATH you add.

      So for example my Python installation directory is C:\Python26 and the existing Path I see is C:\Perl64\site\bin I would change it to C:\Perl64\site\bin;C:\Python26; When you are finished click OK, OK and OK. Now you can open a command prompt window, in Windows 7 press your Windows system key to bring up the run dialog area and type "cmd" then hit ENTER, and invoke the Python interpreter from any directory by typing "python" and hitting ENTER/RETURN.

  2. Download and Install pygame
    1. Go to http://pygame.org/ and click on "Downloads" Note: this is for 32-bit installers. If you need a 64-bit version go here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
    2. Select the installer that matches your python version and architecture type. So if you have Python 2.6 installed and you are running a 64-bit MS Windows OS you would want to download pygame-1.9.2pre.win-amd64-py2.6.exe
    3. Save the appropriate file to your Desktop
    4. Double click the file to launch the installer. Note: It should detect your Python installation directory. If it doesn't you can manually select the directory.
  3. Download the Netrek pygame client source
    1. Go to http://pygame.org/project-Netrek-1679-2916.html
    2. Look for the "Source" link and download it, such as: http://quozl.linux.org.au/gytha/gytha-0.6.1.tar.gz
    3. Load the gzipped TAR file in a good file archiver such as the excellent open-source program 7-Zip (http://www.7-zip.org/)
    4. Extract the archive contents to wherever you plan on working with Python. I put mine in C:\Users\Administrator\Desktop\Python\Sandbox\netrek-client-pygame
  4. Install a Python editor or a Python IDE (a GUI that lets you compile and edit inside 1 program)
    1. I like to use Notepad++ since it is lightweight and has Python syntax highlighting: http://notepad-plus-plus.org/
    2. You can find a list of Python Editors here: http://wiki.python.org/moin/PythonEditors
    3. You can find a list of Python IDEs here: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
  5. Now load the Netrek pygame source files in your Python Editor or IDE and have fun hacking!
    1. If you have trouble loading a Python program in MS Windows consult the Python wiki, here's a link to get you started: http://docs.python.org/faq/windows#how-do-i-run-a-python-program-under-windows
  6. Download, install and configure Py2exe. It lets you run a Python program in MS Windows without needing Python installed.
    1. Download py2exe from https://sourceforge.net/projects/py2exe/files/, make sure you select the correct version and architecture type. So if you have Python 2.6 installed and you are running a 64-bit MS Windows OS you would want to download py2exe-0.6.9.win64-py2.6.amd64.exe
    2. Save the appropriate file to your Desktop
    3. Double click the file to launch the installer. Note: It should detect your Python installation directory. If it doesn't you can manually select the directory.
    4. Open up a command prompt window: in Windows 7 press your Windows system key to bring up the run dialog area and type "cmd"

      then hit ENTER. In your Windows File Explorer go to the directory where you unpacked the netrek-client-pygame source files. Go to the address bar and select "Copy address". Now go to the command prompt window and enter: "CD " then click your right mouse button and select Paste, now hit ENTER. This will paste the address of the netrek-client-pygame directory.

    5. Download the py2exe build script:

      http://gytha.oggthebase.org/files/build.py

    6. Enter this command in the command prompt: copy netrek-client-pygame start.py
    7. Now go back to the command prompt and enter this command: python build.py py2exe py2exe will process the build file and generate a "dist" subdirectory. This is what contains our executable and library files.

      It also creates a "build" subdirectory, but you don't have to worry about that.

    8. Go to the \dist subdirectory and run start.exe
    9. You can create an archive of the \dist subdirectory with your favorite file archiver and make it available for download. Now anyone can download and unpack the archive file, go into the dist directory and run start.exe to play even if they don't have python installed!
    10. Note: if you run start.exe and get an error regarding MSVCR90.DLL then install the Microsoft Visual C Runtime 9.0. This DLL file is included in the Microsoft Visual C++ 2008 Redistributable Package which you may download here:

      For 32-bit OSes (x64): http://www.microsoft.com/downloads/en/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6&displaylang=en For 64-bit OSes (x86): http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en

  7. Creating an installer for netrek-client-pygame using Inno Setup
    1. Go to http://www.jrsoftware.org/isdl.php and download setup-5.4.0.exe
    2. Save the file to your Desktop
    3. Double click the file to launch the installer
    4. Download these files:

      http://gytha.oggthebase.org/files/gytha.iss http://gytha.oggthebase.org/files/gytha.ico Save them in your py2exe build directory - such as "C:\Users\Administrator\Desktop\Python\Sandbox\netrek-client-pygame"

    5. Copy "gytha.iss" into your \dist directory.
    6. Start Inno Setup Compiler.
    7. Go to the "Open file" area of the dialog box and select "Open an existing script file" and select \dist\gytha.iss
    8. Go to the build menu and select "Compile". The compiler will build the installer file now.
    9. Look in \dist\Output and you will see the finished installer: setup-gytha_.exe
    10. You may now distribute this installer file. Enjoy!


| quozl@us.netrek.org | up |