Eliminate / replace remaining cPickle references in test scripts.
[scons.git] / doc / user / build-install.xml
1 <!--
2
3   __COPYRIGHT__
4
5   Permission is hereby granted, free of charge, to any person obtaining
6   a copy of this software and associated documentation files (the
7   "Software"), to deal in the Software without restriction, including
8   without limitation the rights to use, copy, modify, merge, publish,
9   distribute, sublicense, and/or sell copies of the Software, and to
10   permit persons to whom the Software is furnished to do so, subject to
11   the following conditions:
12
13   The above copyright notice and this permission notice shall be included
14   in all copies or substantial portions of the Software.
15
16   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17   KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18   WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 -->
25
26   <para>
27
28   This chapter will take you through the basic steps
29   of installing &SCons; on your system,
30   and building &SCons; if you don't have a
31   pre-built package available
32   (or simply prefer the flexibility of building it yourself).
33   Before that, however, this chapter will also describe the basic steps
34   involved in installing Python on your system,
35   in case that is necessary.
36   Fortunately, both &SCons; and Python
37   are very easy to install on almost any system,
38   and Python already comes installed on many systems.
39
40   </para>
41
42   <!--
43
44   <para>
45
46   Lastly, this chapter also contains a section that
47   provides a brief overview of the Python programming language,
48   which is the language used to implement &SCons;,
49   and which forms the basis of the &SCons; configuration files.
50   Becoming familiar with some Python concepts will make it easier
51   to understand many of the examples in this User's Guide.
52   Nevertheless, it <emphasis>is</emphasis> possible
53   to configure simple &SCons; builds without knowing Python,
54   so you can skip this section if you
55   want to dive in and pick up things
56   by example- -or, of course, if you are 
57   already familiar with Python.
58
59   </para>
60
61   -->
62
63   <section>
64   <title>Installing Python</title>
65
66     <para>
67
68     Because &SCons; is written in Python,
69     you must obviously have Python installed on your system
70     to use &SCons;.
71     Before you try to install Python,
72     you should check to see if Python is already
73     available on your system  by typing
74     <userinput>python -V</userinput>
75     (capital 'V')
76     or
77     <userinput>python --version</userinput>
78     at your system's command-line prompt.
79
80     </para>
81
82     <screen>
83        $ <userinput>python -V</userinput>
84        Python 2.5.1
85     </screen>
86
87     <para>
88
89     And on a Windows system with Python installed:
90
91     </para>
92
93     <screen>
94        C:\><userinput>python -V</userinput>
95        Python 2.5.1
96     </screen>
97
98     <para>
99
100     If Python is not installed on your system,
101     you will see an error message
102     stating something like "command not found"
103     (on UNIX or Linux)
104     or "'python' is not recognized
105     as an internal or external command, operable progam or batch file"
106     (on Windows).
107     In that case, you need to install Python
108     before you can install &SCons;.
109
110     </para>
111
112     <para>
113
114     (Note that the <option>-V</option> option
115     was added to Python version 2.0,
116     so if your system only has an earlier version available
117     you may see an
118     <literal>"Unknown option: -V"</literal>
119     error message.)
120
121     </para>
122
123     <para>
124
125     The standard location for information
126     about downloading and installing Python is
127     <ulink url="http://www.python.org/download/">http://www.python.org/download/</ulink>.
128     See that page for information about
129     how to download and install Python on your system.
130
131     </para>
132
133     <para>
134
135     &SCons; will work with any version of Python from 1.5.2 or later.
136     If you need to install Python and have a choice,
137     we recommend using the most recent Python 2.5 version available.
138     Python 2.5 has significant improvements
139     that help speed up the performance of &SCons;.
140
141     </para>
142
143   </section>
144
145   <section>
146   <title>Installing &SCons; From Pre-Built Packages</title>
147
148     <para>
149
150     &SCons; comes pre-packaged for installation on a number of systems,
151     including Linux and Windows systems.
152     You do not need to read this entire section,
153     you should need to read only the section
154     appropriate to the type of system you're running on.
155
156     </para>
157
158     <section>
159     <title>Installing &SCons; on Red Hat (and Other RPM-based) Linux Systems</title>
160
161       <para>
162
163       &SCons; comes in RPM (Red Hat Package Manager) format,
164       pre-built and ready to install on Red Hat Linux,
165       Fedora,
166       or any other Linux distribution that uses RPM.
167       Your distribution may
168       already have an &SCons; RPM built specifically for it;
169       many do, including SUSE, Mandrake and Fedora.
170       You can check for the availability of an &SCons; RPM
171       on your distribution's download servers,
172       or by consulting an RPM search site like
173       <ulink url="http://www.rpmfind.net/">http://www.rpmfind.net/</ulink> or
174       <ulink url="http://rpm.pbone.net/">http://rpm.pbone.net/</ulink>.
175
176       </para>
177
178       <para>
179
180       If your distribution supports installation via
181       <application>yum</application>,
182       you should be able to install &SCons; by running:
183
184       </para>
185
186       <screen>
187         # <userinput>yum install scons</userinput>
188       </screen>
189
190       <para>
191
192       If your Linux distribution does not already have
193       a specific &SCons; RPM file,
194       you can download and install from the
195       generic RPM provided by the &SCons; project.
196       This will install the 
197       SCons script(s) in <filename>/usr/bin</filename>,
198       and the SCons library modules in
199       <filename>/usr/lib/scons</filename>.
200
201       </para>
202
203       <para>
204
205       To install from the command line, simply download the
206       appropriate <filename>.rpm</filename> file,
207       and then run:
208
209       </para>
210
211       <screen>
212         # <userinput>rpm -Uvh scons-__VERSION__-1.noarch.rpm</userinput>
213       </screen>
214
215       <para>
216
217       Or, you can use a graphical RPM package manager.
218       See your package manager application's documention
219       for specific instructions about
220       how to use it to install a downloaded RPM.
221
222       </para>
223
224     </section>
225
226     <section>
227     <title>Installing &SCons; on Debian Linux Systems</title>
228
229       <para>
230
231       Debian Linux systems use a different package management
232       format that also makes it very easy to install &SCons;.
233
234       </para>
235
236       <para>
237
238       If your system is connected to the Internet,
239       you can install the latest official Debian package
240       by running:
241
242       </para>
243
244       <screen>
245         # <userinput>apt-get install scons</userinput>
246       </screen>
247
248       <!--
249
250       <para>
251
252       Alternatively,
253       you can download the Debian package built
254       by the &SCons; project
255       and install it manually by running:
256
257       </para>
258
259       <screen>
260         # <userinput>db-XXX scons-*.deb</userinput>
261       </screen>
262
263       -->
264
265     </section>
266
267     <section>
268     <title>Installing &SCons; on Windows Systems</title>
269
270       <para>
271
272       &SCons; provides a Windows installer
273       that makes installation extremely easy.
274       Download the <filename>scons-__VERSION__.win32.exe</filename>
275       file from the &SCons; download page at
276       <ulink url="http://www.scons.org/download.php">http://www.scons.org/download.php</ulink>.
277       Then all you need to do is execute the file
278       (usually by clicking on its icon in Windows Explorer).
279       These will take you through a small
280       sequence of windows that will install
281       &SCons; on your system.
282
283       <!--
284       Things are a little more complicated
285       if you are using the Cygwin version of Python.
286       This is because Cygwin
287       tries to make a Windows system look more
288       POSIX-like (or UNIX-like or Linux-like, if you prefer)
289       by having the Cygwin utilities,
290       including Cygwin Python,
291       interpret file name arguments on the command line
292       using the forward-slash (<filename>/</filename>)
293       as the directory separator,
294       instead of the normal Windows behavior of the
295       backslash (<filename>\</filename>) as the directory separator.
296       -->
297
298       </para>
299
300       <!--
301
302       <section>
303       <title>Installing &SCons; on Windows Systems Without Cygwin Python</title>
304
305         <para>
306
307         XXX
308
309         </para>
310
311       </section>
312
313       <section>
314       <title>Installing &SCons; on Windows Systems With Cygwin Python</title>
315
316         <para>
317
318         XXX
319
320         </para>
321
322       </section>
323
324       -->
325
326       <!--
327
328       XXX - don't have the kinks worked out on how to
329       get these to display properly in all formats,
330       so comment them out for now.
331
332       <screenshot>
333       <mediaobject>
334         <imageobject>
335           <imagedata fileref="SCons-win32-install-1.jpg" format="jpg" align="center">
336         </imageobject>
337       </mediaobject>
338       </screenshot>
339
340       <screenshot>
341       <mediaobject>
342         <imageobject>
343           <imagedata fileref="SCons-win32-install-2.jpg" format="jpg" align="center">
344         </imageobject>
345       </mediaobject>
346       </screenshot>
347
348       <screenshot>
349       <mediaobject>
350         <imageobject>
351           <imagedata fileref="SCons-win32-install-3.jpg" format="jpg" align="center">
352         </imageobject>
353       </mediaobject>
354       </screenshot>
355
356       <screenshot>
357       <mediaobject>
358         <imageobject>
359           <imagedata fileref="SCons-win32-install-4.jpg" format="jpg" align="center">
360         </imageobject>
361       </mediaobject>
362       </screenshot>
363
364       -->
365
366     </section>
367
368   </section>
369
370   <section>
371   <title>Building and Installing &SCons; on Any System</title>
372
373     <para>
374
375     If a pre-built &SCons; package is not available for your system,
376     then you can still easily build and install &SCons; using the native
377     Python <filename>distutils</filename> package.
378
379     </para>
380
381     <para>
382
383     The first step is to download either the
384     <filename>scons-__VERSION__.tar.gz</filename>
385     or <filename>scons-__VERSION__.zip</filename>,
386     which are available from the SCons download page at
387     <ulink url="http://www.scons.org/download.html">http://www.scons.org/download.html</ulink>.
388
389     </para>
390
391     <para>
392
393     Unpack the archive you downloaded,
394     using a utility like <application>tar</application>
395     on Linux or UNIX,
396     or <application>WinZip</application> on Windows.
397     This will create a directory called
398     <filename>scons-__VERSION__</filename>,
399     usually in your local directory.
400     Then change your working directory to that directory
401     and install &SCons; by executing the following commands:
402
403     </para>
404
405     <screen>
406       # <userinput>cd scons-__VERSION__</userinput>
407       # <userinput>python setup.py install</userinput>
408     </screen>
409
410     <para>
411
412     This will build &SCons;,
413     install the &scons; script
414     in the python which is used to run the setup.py's scripts directory
415     (<filename>/usr/local/bin</filename> or
416     <filename>C:\Python25\Scripts</filename>),
417     and will install the &SCons; build engine
418     in the corresponding library directory for the python used
419     (<filename>/usr/local/lib/scons</filename> or
420     <filename>C:\Python25\scons</filename>).
421     Because these are system directories,
422     you may need root (on Linux or UNIX) or Administrator (on Windows)
423     privileges to install &SCons; like this.
424
425     </para>
426
427     <!--
428
429     <section>
430     <title>Building and Installing &SCons; in the Standard Python Library Directories</title>
431
432       <para>
433
434       XXX
435
436       </para>
437
438     </section>
439
440     -->
441
442     <section>
443     <title>Building and Installing Multiple Versions of &SCons; Side-by-Side</title>
444
445       <para>
446
447       The &SCons; <filename>setup.py</filename> script
448       has some extensions that support
449       easy installation of multiple versions of &SCons;
450       in side-by-side locations.
451       This makes it easier to download and
452       experiment with different versions of &SCons;
453       before moving your official build process to a new version,
454       for example.
455
456       </para>
457
458       <para>
459
460       To install &SCons; in a version-specific location,
461       add the <option>--version-lib</option> option
462       when you call <filename>setup.py</filename>:
463
464       </para>
465
466       <screen>
467         # <userinput>python setup.py install --version-lib</userinput>
468       </screen>
469
470       <para>
471
472       This will install the &SCons; build engine
473       in the
474       <filename>/usr/lib/scons-__VERSION__</filename>
475       or
476       <filename>C:\Python25\scons-__VERSION__</filename>
477       directory, for example.
478
479       </para>
480
481       <para>
482
483       If you use the <option>--version-lib</option> option
484       the first time you install &SCons;,
485       you do not need to specify it each time you install
486       a new version.
487       The &SCons; <filename>setup.py</filename> script
488       will detect the version-specific directory name(s)
489       and assume you want to install all versions
490       in version-specific directories.
491       You can override that assumption in the future
492       by explicitly specifying the <option>--standalone-lib</option> option.
493
494       </para>
495
496     </section>
497
498     <section>
499     <title>Installing &SCons; in Other Locations</title>
500
501       <para>
502
503       You can install &SCons; in locations other than
504       the default by specifying the <option>--prefix=</option> option:
505
506       </para>
507
508       <screen>
509         # <userinput>python setup.py install --prefix=/opt/scons</userinput>
510       </screen>
511
512       <para>
513
514       This would
515       install the <application>scons</application> script in
516       <filename>/opt/scons/bin</filename>
517       and the build engine in 
518       <filename>/opt/scons/lib/scons</filename>,
519
520       </para>
521
522       <para>
523
524       Note that you can specify both the <option>--prefix=</option>
525       and the <option>--version-lib</option> options
526       at the same type,
527       in which case <filename>setup.py</filename>
528       will install the build engine
529       in a version-specific directory
530       relative to the specified prefix.
531       Adding <option>--version-lib</option> to the
532       above example would install the build engine in
533       <filename>/opt/scons/lib/scons-__VERSION__</filename>.
534
535       </para>
536
537     </section>
538
539     <section>
540     <title>Building and Installing &SCons; Without Administrative Privileges</title>
541
542       <para>
543
544       If you don't have the right privileges to install &SCons;
545       in a system location,
546       simply use the <literal>--prefix=</literal> option
547       to install it in a location of your choosing.
548       For example,
549       to install &SCons; in appropriate locations
550       relative to the user's <literal>$HOME</literal> directory,
551       the &scons; script in
552       <filename>$HOME/bin</filename>
553       and the build engine in 
554       <filename>$HOME/lib/scons</filename>,
555       simply type:
556
557       </para>
558
559       <screen>
560         $ <userinput>python setup.py install --prefix=$HOME</userinput>
561       </screen>
562
563       <para>
564
565       You may, of course, specify any other location you prefer,
566       and may use the <option>--version-lib</option> option
567       if you would like to install version-specific directories
568       relative to the specified prefix.
569
570       </para>
571
572       <para>
573
574       This can also be used to experiment with a newer
575       version of &SCons; than the one installed
576       in your system locations.
577       Of course, the location in which you install the
578       newer version of the &scons; script
579       (<filename>$HOME/bin</filename> in the above example)
580       must be configured in your &PATH; variable
581       before the directory containing
582       the system-installed version
583       of the &scons; script.
584
585       </para>
586
587     </section>
588
589   </section>
590
591   <!--
592
593   <section>
594   <title>Python Basics</title>
595
596     <para>
597
598     This section will provide a brief overview of
599     the Python programming language.
600     Skip this section if you are already familiar with Python
601     (or you're really intent on diving into &SCons;
602     and just picking up things as you go).
603
604     </para>
605
606     <para>
607
608     Python has a lot of good
609     documentation freely available on-line
610     to help you get started.
611     The standard tutorial is available at XXX.
612
613
614     </para>
615
616     <para>
617
618     Python is very easy to pick up.
619
620     </para>
621
622     <para>
623
624     Python variables must be assigned to before they can be referenced.
625
626     </para>
627
628     <para>
629
630     Assignment is like most programming languages:
631
632     x = 1 + 2
633     z = 3 * x
634
635     </para>
636
637     <para>
638
639     Function calls look like most language function calls:
640
641     a = f(g)
642
643     </para>
644
645     <para>
646
647     Define functions like so:
648
649         def func(arg1, arg2):
650             return arg1 * arg 2
651
652     The number of parameters
653
654     </para>
655
656     <para>
657
658     Strings can be enclosed in single quotes or double quotes,
659     backslashes are used to escape characters,
660     triple-quote syntax lets you include quotes and newlines,
661     raw strings begin with 'r'.
662
663     </para>
664
665     <para>
666
667     Lists are enclosed in square brackets,
668     list items are separated by commas.
669     List references use square brackets and integer index values,
670     slice notation lets you select, delete or replace a range.
671
672     </para>
673
674     <para>
675
676     Dictionaries (hashes) are enclosed in curly brackets,
677     : separates keys from values,
678     , separates items.
679     Dictionary values are referenced using square brackets.
680
681     </para>
682
683     <para>
684
685     Access class attributes (including methods) using a '.'.
686
687     </para>
688
689     <para>
690
691     if: statements look like
692
693     elif: statements look like
694
695     else: statements look like
696
697     </para>
698
699     <para>
700
701     for: statements look like
702
703     while: statements look like
704
705     break statements look like
706     
707     continue statements look like
708
709     </para>
710
711     <para>
712
713     pass
714
715     </para>
716
717   </section>
718
719   -->