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