DevelopersWin32Environment

Version 19 (Dan Smith, 06/19/2015 07:00 pm)

1 1 Dan Smith
h1. Setting up a Win32 Development Environment
2 1 Dan Smith
3 9 Robert Terzi
{{toc}}
4 9 Robert Terzi
5 14 Robert Terzi
h2. Overview
6 14 Robert Terzi
7 15 Robert Terzi
Chirp is written in Python, an interpreted language. To run the chirp code directly you need Python installed as well as several other external libraries:
8 14 Robert Terzi
9 14 Robert Terzi
 * PyGTK - GTK cross-platform GUI,
10 14 Robert Terzi
 * PySerial - serial port connectivity for Python
11 14 Robert Terzi
 * PyLibXML2 - XML processing
12 14 Robert Terzi
13 15 Robert Terzi
You must also obtain a copy of the chirp source code, either by downloading the .tar.gz archive or by using the Mercurial source code management system, known as hg. Installing Mercurial will allow you to pull the latest updates from the chirp site and automates submission of patches for inclusion in future chirp builds. If you intend on submitting patches and working with the chirp development community is it strongly recommended that you install Mercurial and use it for submitting patches and keeping your sources current.
14 1 Dan Smith
15 15 Robert Terzi
For MS windows, chirp is distributed as a compiled .exe file that installs the compiled code and the necessary runtime dependencies. The compiled .exe files eliminate the need for the Python interpreter. Additional downloads and steps are needed to create chirp installer (.exe) files if you need to distribute your work to other systems for testing.
16 1 Dan Smith
17 15 Robert Terzi
To summarize the steps are:
18 15 Robert Terzi
19 15 Robert Terzi
 # install python
20 15 Robert Terzi
 # install additional python libraries PyGTK, PySerial, PyLibXML2
21 15 Robert Terzi
 # install Mercurial (hg) SCM
22 15 Robert Terzi
 # Use Mercurial to download the current chirp source code and keep it up to date.
23 15 Robert Terzi
24 13 Robert Terzi
h2. Installing Python
25 1 Dan Smith
26 15 Robert Terzi
To run chirp you will need to install Python 2.7.x from either "Python.org":http://python.org or "ActiveState":http://www.activestate.com/activepython.  Do not install Python 3 as chirp is currently written for Python 2.7 and above, but will generally run on Python 2.6.x.
27 13 Robert Terzi
28 13 Robert Terzi
 * "Python 2.7.x":http://python.org/download/releases/2.7.6/
29 13 Robert Terzi
 * "ActivePython Community Edition":http://www.activestate.com/activepython/downloads
30 13 Robert Terzi
31 13 Robert Terzi
See the steps below to add Python to your system's path after installation.
32 13 Robert Terzi
 
33 13 Robert Terzi
34 1 Dan Smith
h2. Library and Runtime Prerequisites
35 1 Dan Smith
36 13 Robert Terzi
In addition to Python, several other libraries are needed for the GTK cross-platform GUI, serial port connectivity, and XML processing.
37 13 Robert Terzi
38 1 Dan Smith
Get and install the following in this order:
39 7 Jens Jensen
40 1 Dan Smith
 # "PyGTK Win32 All-in-one installer":http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/
41 1 Dan Smith
 # "PyLibXML2":http://users.skynet.be/sbi/libxml-python/
42 1 Dan Smith
 # "PyWin32":http://sourceforge.net/projects/pywin32/files/pywin32/
43 1 Dan Smith
 # "PySerial":http://sourceforge.net/projects/pyserial/files/pyserial/2.5/
44 1 Dan Smith
45 3 Dan Smith
Notes:
46 4 Dan Smith
47 3 Dan Smith
 * For any of the above, be sure to get the latest version, and the py27 variant if/when available.
48 12 Robert Terzi
 * If you are on 64-bit Windows, you must download the versions with the same bitness (either 64-bit or 32-bit) in order for everything to work together, all 32-bit or all 64-bit. 
49 3 Dan Smith
 ** If your intent is to be able to build an .exe for others to test/use, you should use only the 32-bit versions to ensure the generated .exe will install and run on the widest range of Windows systems.
50 5 Dan Smith
 * On Windows 7 (and possibly other newer versions of Windows with UAC) the PyLibXML2 installer will generate an error during the installation about not being able to modify the runtime directory. (This appears to be bening but needs to be confirmed.)
51 1 Dan Smith
52 13 Robert Terzi
When everything is installed, you will want to make sure that Python is in your system PATH variable:
53 13 Robert Terzi
54 13 Robert Terzi
55 13 Robert Terzi
h2. Putting Python in your path.
56 13 Robert Terzi
57 13 Robert Terzi
After installing python, you will need to add it to your path.  The Active State Python installer for ActivePython handles this for you.  If you installed from python.org follow these instructions.
58 13 Robert Terzi
59 5 Dan Smith
h3. Windows XP
60 5 Dan Smith
61 5 Dan Smith
 * On the Desktop or in the Start menu, right-click on *My Computer* and choose *Properties*
62 5 Dan Smith
 * In the dialog that opens, on the *Advanced* tab, click on *Environment Variables*
63 5 Dan Smith
 * Under *System variables*, find *Path*, select it, and then edit *Edit*
64 8 Jens Jensen
 * At the end of the existing value, add exactly this string: @;C:\Python27@ (obviously adjust this path if you installed it elsewhere. Don't forget the leading semicolon)
65 5 Dan Smith
 * Click the *OK* buttons until you're done.
66 5 Dan Smith
67 5 Dan Smith
h3. Windows Vista/7
68 5 Dan Smith
69 1 Dan Smith
 * In the Windows menu, right-click on the *Computer* item and choose *Properties*
70 5 Dan Smith
 * Click on *Advanced System Settings* on the left
71 1 Dan Smith
 * In the dialog that opens, click on *Environment Variables*
72 1 Dan Smith
 * Under *System variables*, find *Path*, select it, and then edit *Edit*
73 1 Dan Smith
 * At the end of the existing value, add exactly this string: @;C:\Python27\bin@ (obviously adjust this path if you installed it elsewhere. Don't forget the leading semicolon)
74 1 Dan Smith
 * Click the *OK* buttons until you're done.
75 5 Dan Smith
76 15 Robert Terzi
h1. CHIRP source code and development process.
77 5 Dan Smith
78 17 Ben Weiss
The chirp developers use the "Mercurial source code management system":http://mercurial.selenic.com/, also known as hg for managing the chirp source code and supporting distributed development. Installing Mercurial will allow you to pull the latest updates from the chirp site and automates submission of patches for inclusion in future chirp builds. While you can download a .tar.gz copy of the chirp sources this is not recommend as your sources will become quickly out of date.
79 15 Robert Terzi
80 15 Robert Terzi
h2. Install Mercurial
81 15 Robert Terzi
82 1 Dan Smith
Get and install the mercurial source code management tool:
83 1 Dan Smith
84 16 Ben Weiss
 * "Mercurial SCM":http://mercurial.selenic.com/
85 1 Dan Smith
86 1 Dan Smith
h2. Clone the repository
87 1 Dan Smith
88 1 Dan Smith
The next step is to download a copy of the repository. This is done from the command-line, and will create a @chirp.hg/@ directory in your current directory. Thus, you should change to the place you want it to be first. For example:
89 1 Dan Smith
90 1 Dan Smith
<pre>
91 1 Dan Smith
C:\Users\Foo> cd \MyWorkspace
92 2 Dan Smith
C:\MyWorkspace> hg clone http://d-rats.com/hg/chirp.hg
93 1 Dan Smith
</pre>
94 2 Dan Smith
95 15 Robert Terzi
h2. Learn about the Chirp development process and how to use Mercurial
96 15 Robert Terzi
97 15 Robert Terzi
See [[DevelopersProcess|Chirp Development Processs|]].
98 15 Robert Terzi
99 15 Robert Terzi
h1. Run chirp
100 2 Dan Smith
101 1 Dan Smith
Python should be in your search path from the install, but if not, put it in the system PATH environment variable. Once you do that, you should be able to enter the directory that was created in the clone step above, and run chirpw with python:
102 2 Dan Smith
103 2 Dan Smith
<pre>
104 2 Dan Smith
C:\MyWorkspace> cd chirp.hg
105 2 Dan Smith
C:\MyWorkspace\chirp.hg> python chirpw
106 1 Dan Smith
</pre>
107 9 Robert Terzi
108 13 Robert Terzi
h1. Setting up a Win32 Build Environment to create chirp .exe files
109 9 Robert Terzi
110 9 Robert Terzi
The following notes are for setting up a chirp build environment on a Win32 system, that can be used to create chirp .exe files and the installer for running on other Win32 systems without requiring a Python environment. Note: it is probably best to use the 32 bit versions of all of the components if your intent is to build an .exe that will work on the widest range of Windows systems.
111 9 Robert Terzi
112 9 Robert Terzi
# Follow the directions above to create a working chirp development environment
113 9 Robert Terzi
# Install py2exe - This utility creates .exe files from python environments.  See http://www.py2exe.org/
114 1 Dan Smith
# Install cygwin - Cygwin provides a Unix/Linux like environment on a Windows system using the freely available GNU tools. See http://www.cygwin.com/
115 19 Dan Smith
## During the cygwin installation, make sure the following packages are selected for install:
116 19 Dan Smith
## zip
117 19 Dan Smith
## unzip
118 19 Dan Smith
## make
119 19 Dan Smith
## dos2unix
120 9 Robert Terzi
# install NSIS - The free Nullsoft Scriptable Install System is used to create Windows installer packages.  These are the .exe's that most users will download to install chirp on a Windows system.  See http://nsis.sourceforge.net/
121 9 Robert Terzi
122 9 Robert Terzi
h2. Creating Win32 .exe files
123 9 Robert Terzi
124 9 Robert Terzi
Follow the above instructions to setup a chirp build environment on a Windows system.
125 9 Robert Terzi
126 9 Robert Terzi
# Launch Cygwin Terminal to get a command prompt.
127 9 Robert Terzi
# cd to the chirp.hg directory where your sources are.
128 9 Robert Terzi
# run ./build/make_Win32_build.sh 
129 9 Robert Terzi
# The output in winds up in c:\cygwin (To Be Verified)