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
|
<?xml version='1.0'?>
<!DOCTYPE sconsdoc [
<!ENTITY % version SYSTEM "../version.xml">
%version;
<!ENTITY % scons SYSTEM "../scons.mod">
%scons;
<!ENTITY % builders-mod SYSTEM "../generated/builders.mod">
%builders-mod;
<!ENTITY % functions-mod SYSTEM "../generated/functions.mod">
%functions-mod;
<!ENTITY % tools-mod SYSTEM "../generated/tools.mod">
%tools-mod;
<!ENTITY % variables-mod SYSTEM "../generated/variables.mod">
%variables-mod;
]>
<chapter id="chap-build-install"
xmlns="http://www.scons.org/dbxsd/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
<title>Building and Installing &SCons;</title>
<!--
Copyright (c) 2001 - 2019 The SCons Foundation
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 need to 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.
For Linux/Unix/MacOS/BSD type systems this looks like:
</para>
<screen>
$ <userinput>python -V</userinput>
Python 3.7.1
</screen>
<para>
In a cmd shell or PowerShell on a Windows system
(note PoweShell needs it spelled "python.exe" rather than "python"):
</para>
<screen>
C:\><userinput>python -V</userinput>
Python 3.7.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 and associated links to get started.
</para>
<para>
For Linux systems, Python is
almost certainly available as a supported package, possibly
installed by default; this is often preferred to installing
by other means, and is easier than installing from source code.
Many such systems have separate packages for
Python 2 and Python 3. Building from source may still be a
useful option if you need a version that is not offered by
the distribution you are using.
</para>
<para>
&SCons; will work with Python 2.7.x or with Python 3.5 or later.
If you need to install Python and have a choice,
we recommend using the most recent Python version available.
Newer Pythons have significant improvements
that help speed up the performance of &SCons;.
</para>
</section>
<section>
<title>Installing &SCons;</title>
<para>
The canonical way to install &SCons; is from the Python Package
Index (PyPi):
</para>
<screen>
% <userinput>python -m pip install scons</userinput>
</screen>
<para>
If you prefer not to install to the Python system location,
or do not have privileges to do so, you can add a flag to
install to a location specific to your own account:
</para>
<screen>
% <userinput>python -m pip install --user scons</userinput>
</screen>
<para>
&SCons; comes pre-packaged for installation on many Linux systems
Check your package installation system
to see if there is an &SCons; package available.
Many people prefer to install distribution-native packages if available,
as they provide a central point for management and updating.
Some distributions have two &SCons; packages available, one which
uses Python 2 and one which uses Python 3. If you need a specific
version of &SCons; that is different from the package available,
<filename>pip</filename> has a version option or you can follow
the instructions in the next section.
</para>
</section>
<section>
<title>Building and Installing &SCons; on Any System</title>
<para>
If a pre-built &SCons; package is not available for your system,
and installing using <filename>pip</filename> is not suitable,
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-&buildversion;.tar.gz</filename>
or <filename>scons-&buildversion;.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-&buildversion;</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-&buildversion;</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:\Python27\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:\Python27\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-&buildversion;</filename>
or
<filename>C:\Python27\scons-&buildversion;</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-&buildversion;</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>
-->
</chapter>
|