Typo
[linux_from_scratch_hints.git] / OLD / python.txt
blob4b7e1c52accf1dd5e578f5a4a3e510eb1ee8f49d
1 TITLE:          Python
2 VERSION:        any
3 AUTHOR:         Righard Lightman <richard@reika.demon.co.uk>
5 SYNOPSIS:
6         How to install python.
8 HINT:
9 Why install python
10 ------------------
12 Cribbed from the python html docs:
14   Python is an easy to learn, powerful programming language. It has
15   efficient high-level data structures and a simple but effective
16   approach to object-oriented programming. Python's elegant syntax and
17   dynamic typing, together with its interpreted nature, make it an
18   ideal language for scripting and rapid application development in
19   many areas on most platforms.
22 I have done some simple python programs, and I find it fast, and
23 much easier to use than my every day languages (C/assembler). It
24 is also far more powerful than my 'I could not be bothered to do
25 this properly' language (bash it with sed and mawk). And so far
26 I have used it instead of trying out perl. Anyone know when perl
27 is a better choice than python?
30 Where get it
31 ------------
33 ftp://ftp.python.org/pub/python/src/python-2.0.tar.gz
34 ???html-1.5.2p2
36 You may also want:
37   an html browser
38   to get you sound card working
39   readline: ftp://ftp.gnu.org/pub/gnu/readline
40   zlib:     ftp://ftp.uu.net/graphics/png/src
41   lots of graphics libraries: See Sergey Ostrovsky's X hint
42   gmp:      ftp://ftp.gnu.org/pub/gnu/gmp
43   bc:       ftp://ftp.gnu.org/pub/gnu/bc
44   openssl:  ftp://ftp.openssl.org/source
45   gdbm:     ftp://ftp.gnu.org/pub/gnu/gdbm
46   to add python support to gnome
48 I know python can do something useful with tcl/tk, and there
49 is also a 'stackless python' that is much better at running
50 multi-threaded. I have not tried these, and leave them as an
51 exercise for the reader.
54 Installing the instructions
55 ---------------------------
57 mkdir /usr/share/doc/python
58 cd /usr/share/doc/python
59 gzip -cd ??? | tar -x
61 Now put add link so this is easy to read with your favourate browser.
63 Mine is lynx, so in /home/richard/.bash_profile i have:
64   export WWW_HOME=/home/richard/html/links.html
65 /home/richard/html/links.html contains this link:
66   <a href="/usr/share/doc/index.html" class=link>System documentation</a><br>
67 and /usr/share/doc/index.html contains this link:
68   <a href="python/index.html" class=link>Python documents</a><br>
71 Configuring Python
72 ==================
74 Unpack the source and change to its directory:
76 cd Modules
77 less setup.in
79 Take a look at all the things you can access from python. This
80 is a good time to install the ones you want. A copy of this file
81 should be edited with your preferences, and stored as 'setup' in
82 this directory.
84 I am too lazy to edit anything myself, so I have sed do it for
85 me:
87 sed -e 's!#\*shared\*!\*shared\*!'\
88     -e 's!#_curses.*!_curses _cursesmodule.c -lncurses!'\
89     -e 's!#crypt.*!crypt cryptmodule.c  -lcrypt!'\
90     -e 's!#timing!timing!'\
91     -e 's!#syslog!syslog!'\
92     < Setup.in > Setup
94 This was a bit minimal, so if you have any of the following
95 installed, add the appropriate substitutions:
98 sound
99 -----
100     -e 's!#linuxaudiodev!linuxaudiodev!'\
101     -e 's!#audioop!audioop!'\
103 I am using the alsa drivers, but this probably works with
104 the kernel drivers too. If you run 'make test' below,
105 expect the spannish inquistion
108 readline
109 --------
110     -e 's!#readline.*!readline readline.c -lreadline -lncurses!'\
112 This library gives you the look and feel of editing in bash shell
113 when using python (and lots of other things) interactively. It
114 installs without much trouble:
116 ./configure --prefix=/usr --with-curses
117 make
118 make shared
119 make install
120 cd shlib
121 make install
124 zlib
125 ----
126     -e 's!#zlib!zlib!'\
128 Take a look at Sergey Ostrovsky's X hint to see how it is installed.
131 libpng, libjpeg, libungiff...
132 -----------------------------
133     -e 's!#imageop!imageop!'\
135 I am not sure how many libraries this uses. I have all the ones
136 from Sergey Ostrovsky's excellent X hint, and a few extras.
141     -e 's!#GMP=.*!GMP=/usr!'\
142     -e 's!#mpz.*!mpz mpzmodule.c -I$(GMP)/include $(GMP)/lib/libgmp.so!'\
144 Precise maths library. Last time I checked this had difficulty with
145 pentium pro's, but is has no problems with my athlon or pentium 2.
146 The configure script does some excellent auto detection. If its does
147 not work, try: info -f ./gmp.info
148 CFLAGS=""
149 ./configure --disable-static --prefix=/usr --sysconfdir=/etc\
150   --infodir=/usr/share/info --mandir=/usr/share/man"
151 make
152 make check
153 make install
159 Unlimited precission calculator used by openssl. I usually
160 install this after gmp, so I do not know if there is a dependancy.
162 ./configure --prefix=/usr --sysconfdir=/etc\
163   --infodir=/usr/share/info --mandir=/usr/share/man
164 make
165 make install
168 openssl
169 -------
170     -e 's!#_socket!_socket!'\
171     -e 's!#SSL=.*!SSL=/usr!'\
172     -e 's!#.*-DUSE_SSL! -DUSE_SSL!'\
173     -e 's!#.*-L$(SSL)/lib!  -L$(SSL)/lib!'\
175 I think that bc is only needed for make test, but as it was so easy
176 to install, I did not try compiling withoutit.
178 ./Configure linux-elf --prefix=/usr --openssldir=/etc/ssl
179 make
180 make test
181 make install
184 gdbm
185 ----
186     -e 's!#gdbm.*!gdbm gdbmmodule.c -I/usr/include -L/usr/lib -lgdbm!'\
188 Yet another data base library. When configure scripts cannot find dbopen
189 in BerkleyDB, sleepy cat's port of BerkleyDB (db) and the new glibc-2.2,
190 they will not find it here either.
192 ./configure --disable-static --prefix=/usr --sysconfdir=/etc
193   --infodir=/usr/share/info --mandir=/usr/share/man
195 Well that was wishful thinking. Now let's correct all the things
196 configure did wrong. I configure, make and make test as a user
197 called build, then install as a user called install who is in
198 group bin. If you are doing everything as root, forget the
199 lines with 'BINOWN', 'BINGRP' and 'chown'
201 sed -e "s?/local??" -e "s?= bin?= root?"\
202     -e 's@^\(manprefix = \).*@\1/usr/share@'\
203     -e 's@^\(man3dir = \).*@\1\$(manprefix)/man/man3@'\
204     -e 's@^\(infodir = \).*@\1/usr/share/info@'\
205     -e "s@^\(BINOWN = \).*@\1install@"\
206     -e 's@^\(BINGRP = \).*@\1bin@'\
207     Makefile > Makefile~
208 mv Makefile~ Makefile
210 make
211 chown -R $install.bin .
212 make install
216 make, test and install
217 ======================
219 ./configure --with-threads --prefix=/usr --sysconfdir=/etc
220   --infodir=/usr/share/info --mandir=/usr/share/man
222 You can put what you like in --man-dir - it will not do any good.
223 I do not have the link from /usr/man to /usr/share/man so I need:
224 sed -e 's@^\(MANDIR=[[:space:]]*\).*@\1/usr/share/man@'\
225   Makefile >Makefile~
226 mv Makefile~ Makefile
228 make
229 make test
230 make install
232 Try it out put this in a file:
234 #!/usr/bin/python
235 for n in range(2, 10):
236   for x in range(2, n):
237     if n % x == 0:
238       print n, 'equals', x, '*', n/x
239       break
240     else:
241       print n, 'is a prime number'
243 make the file executable, and run it twice - it will be faster
244 the second time because a compiled version will be it python's cache.