1This is Python version 2.7.2
2============================
3
4Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
5Python Software Foundation.  All rights reserved.
6
7Copyright (c) 2000 BeOpen.com.
8All rights reserved.
9
10Copyright (c) 1995-2001 Corporation for National Research Initiatives.
11All rights reserved.
12
13Copyright (c) 1991-1995 Stichting Mathematisch Centrum.
14All rights reserved.
15
16
17License information
18-------------------
19
20See the file "LICENSE" for information on the history of this
21software, terms & conditions for usage, and a DISCLAIMER OF ALL
22WARRANTIES.
23
24This Python distribution contains no GNU General Public Licensed
25(GPLed) code so it may be used in proprietary projects just like prior
26Python distributions.  There are interfaces to some GNU code but these
27are entirely optional.
28
29All trademarks referenced herein are property of their respective
30holders.
31
32
33What's new in this release?
34---------------------------
35
36See the file "Misc/NEWS".
37
38
39If you don't read instructions
40------------------------------
41
42Congratulations on getting this far. :-)
43
44To start building right away (on UNIX): type "./configure" in the
45current directory and when it finishes, type "make".  This creates an
46executable "./python"; to install in /usr/local, first do "su root"
47and then "make install".
48
49The section `Build instructions' below is still recommended reading.
50
51
52What is Python anyway?
53----------------------
54
55Python is an interpreted, interactive object-oriented programming
56language suitable (amongst other uses) for distributed application
57development, scripting, numeric computing and system testing.  Python
58is often compared to Tcl, Perl, Java, JavaScript, Visual Basic or
59Scheme.  To find out more about what Python can do for you, point your
60browser to http://www.python.org/.
61
62
63How do I learn Python?
64----------------------
65
66The official tutorial is still a good place to start; see
67http://docs.python.org/ for online and downloadable versions, as well
68as a list of other introductions, and reference documentation.
69
70There's a quickly growing set of books on Python.  See
71http://wiki.python.org/moin/PythonBooks for a list.
72
73
74Documentation
75-------------
76
77All documentation is provided online in a variety of formats.  In
78order of importance for new users: Tutorial, Library Reference,
79Language Reference, Extending & Embedding, and the Python/C API.  The
80Library Reference is especially of immense value since much of
81Python's power is described there, including the built-in data types
82and functions!
83
84All documentation is also available online at the Python web site
85(http://docs.python.org/, see below).  It is available online for occasional
86reference, or can be downloaded in many formats for faster access.  The
87documentation is downloadable in HTML, PostScript, PDF, LaTeX, and
88reStructuredText (2.6+) formats; the LaTeX and reStructuredText versions are
89primarily for documentation authors, translators, and people with special
90formatting requirements.
91
92
93Web sites
94---------
95
96New Python releases and related technologies are published at
97http://www.python.org/.  Come visit us!
98
99
100Newsgroups and Mailing Lists
101----------------------------
102
103Read comp.lang.python, a high-volume discussion newsgroup about
104Python, or comp.lang.python.announce, a low-volume moderated newsgroup
105for Python-related announcements.  These are also accessible as
106mailing lists: see http://www.python.org/community/lists/ for an
107overview of these and many other Python-related mailing lists.
108
109Archives are accessible via the Google Groups Usenet archive; see
110http://groups.google.com/.  The mailing lists are also archived, see
111http://www.python.org/community/lists/ for details.
112
113
114Bug reports
115-----------
116
117To report or search for bugs, please use the Python Bug
118Tracker at http://bugs.python.org/.
119
120
121Patches and contributions
122-------------------------
123
124To submit a patch or other contribution, please use the Python Patch
125Manager at http://bugs.python.org/.  Guidelines
126for patch submission may be found at http://www.python.org/dev/patches/.
127
128If you have a proposal to change Python, you may want to send an email to the
129comp.lang.python or python-ideas mailing lists for inital feedback. A Python
130Enhancement Proposal (PEP) may be submitted if your idea gains ground. All
131current PEPs, as well as guidelines for submitting a new PEP, are listed at
132http://www.python.org/dev/peps/.
133
134
135Questions
136---------
137
138For help, if you can't find it in the manuals or on the web site, it's
139best to post to the comp.lang.python or the Python mailing list (see
140above).  If you specifically don't want to involve the newsgroup or
141mailing list, send questions to [email protected] (a group of volunteers
142who answer questions as they can).  The newsgroup is the most
143efficient way to ask public questions.
144
145
146Build instructions
147==================
148
149Before you can build Python, you must first configure it.
150Fortunately, the configuration and build process has been automated
151for Unix and Linux installations, so all you usually have to do is
152type a few commands and sit back.  There are some platforms where
153things are not quite as smooth; see the platform specific notes below.
154If you want to build for multiple platforms sharing the same source
155tree, see the section on VPATH below.
156
157Start by running the script "./configure", which determines your
158system configuration and creates the Makefile.  (It takes a minute or
159two -- please be patient!)  You may want to pass options to the
160configure script -- see the section below on configuration options and
161variables.  When it's done, you are ready to run make.
162
163To build Python, you normally type "make" in the toplevel directory.
164If you have changed the configuration, the Makefile may have to be
165rebuilt.  In this case, you may have to run make again to correctly
166build your desired target.  The interpreter executable is built in the
167top level directory.
168
169Once you have built a Python interpreter, see the subsections below on
170testing and installation.  If you run into trouble, see the next
171section.
172
173Previous versions of Python used a manual configuration process that
174involved editing the file Modules/Setup.  While this file still exists
175and manual configuration is still supported, it is rarely needed any
176more: almost all modules are automatically built as appropriate under
177guidance of the setup.py script, which is run by Make after the
178interpreter has been built.
179
180
181Troubleshooting
182---------------
183
184See also the platform specific notes in the next section.
185
186If you run into other trouble, see the FAQ
187(http://www.python.org/doc/faq/) for hints on what can go wrong, and
188how to fix it.
189
190If you rerun the configure script with different options, remove all
191object files by running "make clean" before rebuilding.  Believe it or
192not, "make clean" sometimes helps to clean up other inexplicable
193problems as well.  Try it before sending in a bug report!
194
195If the configure script fails or doesn't seem to find things that
196should be there, inspect the config.log file.
197
198If you get a warning for every file about the -Olimit option being no
199longer supported, you can ignore it.  There's no foolproof way to know
200whether this option is needed; all we can do is test whether it is
201accepted without error.  On some systems, e.g. older SGI compilers, it
202is essential for performance (specifically when compiling ceval.c,
203which has more basic blocks than the default limit of 1000).  If the
204warning bothers you, edit the Makefile to remove "-Olimit 1500" from
205the OPT variable.
206
207If you get failures in test_long, or sys.maxint gets set to -1, you
208are probably experiencing compiler bugs, usually related to
209optimization.  This is a common problem with some versions of gcc, and
210some vendor-supplied compilers, which can sometimes be worked around
211by turning off optimization.  Consider switching to stable versions
212(gcc 2.95.2, gcc 3.x, or contact your vendor.)
213
214From Python 2.0 onward, all Python C code is ANSI C.  Compiling using
215old K&R-C-only compilers is no longer possible.  ANSI C compilers are
216available for all modern systems, either in the form of updated
217compilers from the vendor, or one of the free compilers (gcc).
218
219If "make install" fails mysteriously during the "compiling the library"
220step, make sure that you don't have any of the PYTHONPATH or PYTHONHOME
221environment variables set, as they may interfere with the newly built
222executable which is compiling the library.
223
224Unsupported systems
225-------------------
226
227A number of systems are not supported in Python 2.7 anymore. Some
228support code is still present, but will be removed in later versions.
229If you still need to use current Python versions on these systems,
230please send a message to [email protected] indicating that you
231volunteer to support this system. For a more detailed discussion
232regarding no-longer-supported and resupporting platforms, as well
233as a list of platforms that became or will be unsupported, see PEP 11.
234
235More specifically, the following systems are not supported any
236longer:
237- SunOS 4
238- DYNIX
239- dgux
240- Minix
241- NeXT
242- Irix 4 and --with-sgi-dl
243- Linux 1
244- Systems defining __d6_pthread_create (configure.in)
245- Systems defining PY_PTHREAD_D4, PY_PTHREAD_D6,
246  or PY_PTHREAD_D7 in thread_pthread.h
247- Systems using --with-dl-dld
248- Systems using --without-universal-newlines
249- MacOS 9
250- Systems using --with-wctype-functions
251- Win9x, WinME
252
253
254Platform specific notes
255-----------------------
256
257(Some of these may no longer apply.  If you find you can build Python
258on these platforms without the special directions mentioned here,
259submit a documentation bug report to SourceForge (see Bug Reports
260above) so we can remove them!)
261
262Unix platforms: If your vendor still ships (and you still use) Berkeley DB
263        1.85 you will need to edit Modules/Setup to build the bsddb185
264        module and add a line to sitecustomize.py which makes it the
265        default.  In Modules/Setup a line like
266
267            bsddb185 bsddbmodule.c
268
269        should work.  (You may need to add -I, -L or -l flags to direct the
270        compiler and linker to your include files and libraries.)
271
272XXX I think this next bit is out of date:
273
27464-bit platforms: The modules audioop, and imageop don't work.
275        The setup.py script disables them on 64-bit installations.
276        Don't try to enable them in the Modules/Setup file.  They
277        contain code that is quite wordsize sensitive.  (If you have a
278        fix, let us know!)
279
280Solaris: When using Sun's C compiler with threads, at least on Solaris
281        2.5.1, you need to add the "-mt" compiler option (the simplest
282        way is probably to specify the compiler with this option as
283        the "CC" environment variable when running the configure
284        script).
285
286        When using GCC on Solaris, beware of binutils 2.13 or GCC
287        versions built using it.  This mistakenly enables the
288        -zcombreloc option which creates broken shared libraries on
289        Solaris.  binutils 2.12 works, and the binutils maintainers
290        are aware of the problem.  Binutils 2.13.1 only partially
291        fixed things.  It appears that 2.13.2 solves the problem
292        completely.  This problem is known to occur with Solaris 2.7
293        and 2.8, but may also affect earlier and later versions of the
294        OS.
295
296        When the dynamic loader complains about errors finding shared
297        libraries, such as
298
299        ld.so.1: ./python: fatal: libstdc++.so.5: open failed:
300        No such file or directory
301
302        you need to first make sure that the library is available on
303        your system. Then, you need to instruct the dynamic loader how
304        to find it. You can choose any of the following strategies:
305
306        1. When compiling Python, set LD_RUN_PATH to the directories
307           containing missing libraries.
308        2. When running Python, set LD_LIBRARY_PATH to these directories.
309        3. Use crle(8) to extend the search path of the loader.
310        4. Modify the installed GCC specs file, adding -R options into the
311           *link: section.
312
313        The complex object fails to compile on Solaris 10 with gcc 3.4 (at
314        least up to 3.4.3).  To work around it, define Py_HUGE_VAL as
315        HUGE_VAL(), e.g.:
316
317          make CPPFLAGS='-D"Py_HUGE_VAL=HUGE_VAL()" -I. -I$(srcdir)/Include'
318          ./python setup.py CPPFLAGS='-D"Py_HUGE_VAL=HUGE_VAL()"'
319
320Linux:  A problem with threads and fork() was tracked down to a bug in
321        the pthreads code in glibc version 2.0.5; glibc version 2.0.7
322        solves the problem.  This causes the popen2 test to fail;
323        problem and solution reported by Pablo Bleyer.
324
325Red Hat Linux: Red Hat 9 built Python2.2 in UCS-4 mode and hacked
326        Tcl to support it. To compile Python2.3 with Tkinter, you will
327        need to pass --enable-unicode=ucs4 flag to ./configure.
328
329        There's an executable /usr/bin/python which is Python
330        1.5.2 on most older Red Hat installations; several key Red Hat tools
331        require this version.  Python 2.1.x may be installed as
332        /usr/bin/python2.  The Makefile installs Python as
333        /usr/local/bin/python, which may or may not take precedence
334        over /usr/bin/python, depending on how you have set up $PATH.
335
336FreeBSD 3.x and probably platforms with NCurses that use libmytinfo or
337        similar: When using cursesmodule, the linking is not done in
338        the correct order with the defaults.  Remove "-ltermcap" from
339        the readline entry in Setup, and use as curses entry: "curses
340        cursesmodule.c -lmytinfo -lncurses -ltermcap" - "mytinfo" (so
341        called on FreeBSD) should be the name of the auxiliary library
342        required on your platform.  Normally, it would be linked
343        automatically, but not necessarily in the correct order.
344
345BSDI:   BSDI versions before 4.1 have known problems with threads,
346        which can cause strange errors in a number of modules (for
347        instance, the 'test_signal' test script will hang forever.)
348        Turning off threads (with --with-threads=no) or upgrading to
349        BSDI 4.1 solves this problem.
350
351DEC Unix: Run configure with --with-dec-threads, or with
352        --with-threads=no if no threads are desired (threads are on by
353        default).  When using GCC, it is possible to get an internal
354        compiler error if optimization is used.  This was reported for
355        GCC 2.7.2.3 on selectmodule.c.  Manually compile the affected
356        file without optimization to solve the problem.
357
358DEC Ultrix: compile with GCC to avoid bugs in the native compiler,
359        and pass SHELL=/bin/sh5 to Make when installing.
360
361AIX:    A complete overhaul of the shared library support is now in
362        place.  See Misc/AIX-NOTES for some notes on how it's done.
363        (The optimizer bug reported at this place in previous releases
364        has been worked around by a minimal code change.) If you get
365        errors about pthread_* functions, during compile or during
366        testing, try setting CC to a thread-safe (reentrant) compiler,
367        like "cc_r".  For full C++ module support, set CC="xlC_r" (or
368        CC="xlC" without thread support).
369
370AIX 5.3: To build a 64-bit version with IBM's compiler, I used the
371        following:
372
373        export PATH=/usr/bin:/usr/vacpp/bin
374        ./configure --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" \
375                    --disable-ipv6 AR="ar -X64"
376        make
377
378HP-UX:  When using threading, you may have to add -D_REENTRANT to the
379        OPT variable in the top-level Makefile; reported by Pat Knight,
380        this seems to make a difference (at least for HP-UX 10.20)
381        even though pyconfig.h defines it. This seems unnecessary when
382        using HP/UX 11 and later - threading seems to work "out of the
383        box".
384
385HP-UX ia64: When building on the ia64 (Itanium) platform using HP's
386        compiler, some experience has shown that the compiler's
387        optimiser produces a completely broken version of python
388        (see http://bugs.python.org/814976). To work around this,
389        edit the Makefile and remove -O from the OPT line.
390
391        To build a 64-bit executable on an Itanium 2 system using HP's
392        compiler, use these environment variables:
393
394                CC=cc
395                CXX=aCC
396                BASECFLAGS="+DD64"
397                LDFLAGS="+DD64 -lxnet"
398
399        and call configure as:
400
401                ./configure --without-gcc
402
403        then *unset* the environment variables again before running
404        make.  (At least one of these flags causes the build to fail
405        if it remains set.)  You still have to edit the Makefile and
406        remove -O from the OPT line.
407
408HP PA-RISC 2.0: A recent bug report (http://bugs.python.org/546117)
409        suggests that the C compiler in this 64-bit system has bugs
410        in the optimizer that break Python.  Compiling without
411        optimization solves the problems.
412
413SCO:    The following apply to SCO 3 only; Python builds out of the box
414        on SCO 5 (or so we've heard).
415
416        1) Everything works much better if you add -U__STDC__ to the
417        defs.  This is because all the SCO header files are broken.
418        Anything that isn't mentioned in the C standard is
419        conditionally excluded when __STDC__ is defined.
420
421        2) Due to the U.S. export restrictions, SCO broke the crypt
422        stuff out into a separate library, libcrypt_i.a so the LIBS
423        needed be set to:
424
425                LIBS=' -lsocket -lcrypt_i'
426
427UnixWare: There are known bugs in the math library of the system, as well as
428        problems in the handling of threads (calling fork in one
429        thread may interrupt system calls in others). Therefore, test_math and
430        tests involving threads will fail until those problems are fixed.
431
432QNX:    Chris Herborth ([email protected]) writes:
433        configure works best if you use GNU bash; a port is available on
434        ftp.qnx.com in /usr/free.  I used the following process to build,
435        test and install Python 1.5.x under QNX:
436
437        1) CONFIG_SHELL=/usr/local/bin/bash CC=cc RANLIB=: \
438            ./configure --verbose --without-gcc --with-libm=""
439
440        2) edit Modules/Setup to activate everything that makes sense for
441           your system... tested here at QNX with the following modules:
442
443                array, audioop, binascii, cPickle, cStringIO, cmath,
444                crypt, curses, errno, fcntl, gdbm, grp, imageop,
445                _locale, math, md5, new, operator, parser, pcre,
446                posix, pwd, readline, regex, reop,
447                select, signal, socket, soundex, strop, struct,
448                syslog, termios, time, timing, zlib, audioop, imageop
449
450        3) make SHELL=/usr/local/bin/bash
451
452           or, if you feel the need for speed:
453
454           make SHELL=/usr/local/bin/bash OPT="-5 -Oil+nrt"
455
456        4) make SHELL=/usr/local/bin/bash test
457
458           Using GNU readline 2.2 seems to behave strangely, but I
459           think that's a problem with my readline 2.2 port.  :-\
460
461        5) make SHELL=/usr/local/bin/bash install
462
463        If you get SIGSEGVs while running Python (I haven't yet, but
464        I've only run small programs and the test cases), you're
465        probably running out of stack; the default 32k could be a
466        little tight.  To increase the stack size, edit the Makefile
467        to read: LDFLAGS = -N 48k
468
469BeOS:   See Misc/BeOS-NOTES for notes about compiling/installing
470        Python on BeOS R3 or later.  Note that only the PowerPC
471        platform is supported for R3; both PowerPC and x86 are
472        supported for R4.
473
474Cray T3E: Mark Hadfield ([email protected]) writes:
475        Python can be built satisfactorily on a Cray T3E but based on
476        my experience with the NIWA T3E (2002-05-22, version 2.2.1)
477        there are a few bugs and gotchas. For more information see a
478        thread on comp.lang.python in May 2002 entitled "Building
479        Python on Cray T3E".
480
481        1) Use Cray's cc and not gcc. The latter was reported not to
482           work by Konrad Hinsen. It may work now, but it may not.
483
484        2) To set sys.platform to something sensible, pass the
485           following environment variable to the configure script:
486
487             MACHDEP=unicosmk
488
489        2) Run configure with option "--enable-unicode=ucs4".
490
491        3) The Cray T3E does not support dynamic linking, so extension
492           modules have to be built by adding (or uncommenting) lines
493           in Modules/Setup. The minimum set of modules is
494
495             posix, new, _sre, unicodedata
496
497           On NIWA's vanilla T3E system the following have also been
498           included successfully:
499
500             _codecs, _locale, _socket, _symtable, _testcapi, _weakref
501             array, binascii, cmath, cPickle, crypt, cStringIO, dbm
502             errno, fcntl, grp, math, md5, operator, parser, pcre, pwd
503             regex, rotor, select, struct, strop, syslog, termios
504             time, timing, xreadlines
505
506        4) Once the python executable and library have been built, make
507           will execute setup.py, which will attempt to build remaining
508           extensions and link them dynamically. Each of these attempts
509           will fail but should not halt the make process. This is
510           normal.
511
512        5) Running "make test" uses a lot of resources and causes
513           problems on our system. You might want to try running tests
514           singly or in small groups.
515
516SGI:    SGI's standard "make" utility (/bin/make or /usr/bin/make)
517        does not check whether a command actually changed the file it
518        is supposed to build.  This means that whenever you say "make"
519        it will redo the link step.  The remedy is to use SGI's much
520        smarter "smake" utility (/usr/sbin/smake), or GNU make.  If
521        you set the first line of the Makefile to #!/usr/sbin/smake
522        smake will be invoked by make (likewise for GNU make).
523
524        WARNING: There are bugs in the optimizer of some versions of
525        SGI's compilers that can cause bus errors or other strange
526        behavior, especially on numerical operations.  To avoid this,
527        try building with "make OPT=".
528
529OS/2:   If you are running Warp3 or Warp4 and have IBM's VisualAge C/C++
530        compiler installed, just change into the pc\os2vacpp directory
531        and type NMAKE.  Threading and sockets are supported by default
532        in the resulting binaries of PYTHON15.DLL and PYTHON.EXE.
533
534Reliant UNIX: The thread support does not compile on Reliant UNIX, and
535        there is a (minor) problem in the configure script for that
536        platform as well.  This should be resolved in time for a
537        future release.
538
539MacOSX: The tests will crash on both 10.1 and 10.2 with SEGV in
540        test_re and test_sre due to the small default stack size.  If
541        you set the stack size to 2048 before doing a "make test" the
542        failure can be avoided.  If you're using the tcsh or csh shells,
543        use "limit stacksize 2048" and for the bash shell (the default
544        as of OSX 10.3), use "ulimit -s 2048".
545
546        On naked Darwin you may want to add the configure option
547        "--disable-toolbox-glue" to disable the glue code for the Carbon
548        interface modules. The modules themselves are currently only built
549        if you add the --enable-framework option, see below.
550
551        On a clean OSX /usr/local does not exist. Do a
552        "sudo mkdir -m 775 /usr/local"
553        before you do a make install. It is probably not a good idea to
554        do "sudo make install" which installs everything as superuser,
555        as this may later cause problems when installing distutils-based
556        additions.
557
558        Some people have reported problems building Python after using "fink"
559        to install additional unix software. Disabling fink (remove all
560        references to /sw from your .profile or .login) should solve this.
561
562        You may want to try the configure option "--enable-framework"
563        which installs Python as a framework. The location can be set
564        as argument to the --enable-framework option (default
565        /Library/Frameworks). A framework install is probably needed if you
566        want to use any Aqua-based GUI toolkit (whether Tkinter, wxPython,
567        Carbon, Cocoa or anything else).
568
569        You may also want to try the configure option "--enable-universalsdk"
570        which builds Python as a universal binary with support for the
571        i386 and PPC architetures. This requires Xcode 2.1 or later to build.
572
573        See Mac/README for more information on framework and
574        universal builds.
575
576Cygwin: With recent (relative to the time of writing, 2001-12-19)
577        Cygwin installations, there are problems with the interaction
578        of dynamic linking and fork().  This manifests itself in build
579        failures during the execution of setup.py.
580
581        There are two workarounds that both enable Python (albeit
582        without threading support) to build and pass all tests on
583        NT/2000 (and most likely XP as well, though reports of testing
584        on XP would be appreciated).
585
586        The workarounds:
587
588        (a) the band-aid fix is to link the _socket module statically
589        rather than dynamically (which is the default).
590
591        To do this, run "./configure --with-threads=no" including any
592        other options you need (--prefix, etc.).  Then in Modules/Setup
593        uncomment the lines:
594
595        #SSL=/usr/local/ssl
596        #_socket socketmodule.c \
597        #       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
598        #       -L$(SSL)/lib -lssl -lcrypto
599
600        and remove "local/" from the SSL variable.  Finally, just run
601        "make"!
602
603        (b) The "proper" fix is to rebase the Cygwin DLLs to prevent
604        base address conflicts.  Details on how to do this can be
605        found in the following mail:
606
607           http://sources.redhat.com/ml/cygwin/2001-12/msg00894.html
608
609        It is hoped that a version of this solution will be
610        incorporated into the Cygwin distribution fairly soon.
611
612        Two additional problems:
613
614        (1) Threading support should still be disabled due to a known
615        bug in Cygwin pthreads that causes test_threadedtempfile to
616        hang.
617
618        (2) The _curses module does not build.  This is a known
619        Cygwin ncurses problem that should be resolved the next time
620        that this package is released.
621
622        On older versions of Cygwin, test_poll may hang and test_strftime
623        may fail.
624
625        The situation on 9X/Me is not accurately known at present.
626        Some time ago, there were reports that the following
627        regression tests failed:
628
629            test_pwd
630            test_select (hang)
631            test_socket
632
633        Due to the test_select hang on 9X/Me, one should run the
634        regression test using the following:
635
636            make TESTOPTS='-l -x test_select' test
637
638        News regarding these platforms with more recent Cygwin
639        versions would be appreciated!
640
641Windows: When executing Python scripts on the command line using file type
642        associations (i.e. starting "script.py" instead of "python script.py"),
643        redirects may not work unless you set a specific registry key.  See
644        the Knowledge Base article <http://support.microsoft.com/kb/321788>.
645
646
647Configuring the bsddb and dbm modules
648-------------------------------------
649
650Beginning with Python version 2.3, the PyBsddb package
651<http://pybsddb.sf.net/> was adopted into Python as the bsddb package,
652exposing a set of package-level functions which provide
653backwards-compatible behavior.  Only versions 3.3 through 4.4 of
654Sleepycat's libraries provide the necessary API, so older versions
655aren't supported through this interface.  The old bsddb module has
656been retained as bsddb185, though it is not built by default.  Users
657wishing to use it will have to tweak Modules/Setup to build it.  The
658dbm module will still be built against the Sleepycat libraries if
659other preferred alternatives (ndbm, gdbm) are not found.
660
661Building the sqlite3 module
662---------------------------
663
664To build the sqlite3 module, you'll need the sqlite3 or libsqlite3
665packages installed, including the header files. Many modern operating
666systems distribute the headers in a separate package to the library -
667often it will be the same name as the main package, but with a -dev or
668-devel suffix.
669
670The version of pysqlite2 that's including in Python needs sqlite3 3.0.8
671or later. setup.py attempts to check that it can find a correct version.
672
673Configuring threads
674-------------------
675
676As of Python 2.0, threads are enabled by default.  If you wish to
677compile without threads, or if your thread support is broken, pass the
678--with-threads=no switch to configure.  Unfortunately, on some
679platforms, additional compiler and/or linker options are required for
680threads to work properly.  Below is a table of those options,
681collected by Bill Janssen.  We would love to automate this process
682more, but the information below is not enough to write a patch for the
683configure.in file, so manual intervention is required.  If you patch
684the configure.in file and are confident that the patch works, please
685send in the patch.  (Don't bother patching the configure script itself
686-- it is regenerated each time the configure.in file changes.)
687
688Compiler switches for threads
689.............................
690
691The definition of _REENTRANT should be configured automatically, if
692that does not work on your system, or if _REENTRANT is defined
693incorrectly, please report that as a bug.
694
695    OS/Compiler/threads                     Switches for use with threads
696    (POSIX is draft 10, DCE is draft 4)     compile & link
697
698    SunOS 5.{1-5}/{gcc,SunPro cc}/solaris   -mt
699    SunOS 5.5/{gcc,SunPro cc}/POSIX         (nothing)
700    DEC OSF/1 3.x/cc/DCE                    -threads
701            ([email protected])
702    Digital UNIX 4.x/cc/DCE                 -threads
703            ([email protected])
704    Digital UNIX 4.x/cc/POSIX               -pthread
705            ([email protected])
706    AIX 4.1.4/cc_r/d7                       (nothing)
707            ([email protected])
708    AIX 4.1.4/cc_r4/DCE                     (nothing)
709            ([email protected])
710    IRIX 6.2/cc/POSIX                       (nothing)
711            ([email protected])
712
713
714Linker (ld) libraries and flags for threads
715...........................................
716
717    OS/threads                          Libraries/switches for use with threads
718
719    SunOS 5.{1-5}/solaris               -lthread
720    SunOS 5.5/POSIX                     -lpthread
721    DEC OSF/1 3.x/DCE                   -lpthreads -lmach -lc_r -lc
722            ([email protected])
723    Digital UNIX 4.x/DCE                -lpthreads -lpthread -lmach -lexc -lc
724            ([email protected])
725    Digital UNIX 4.x/POSIX              -lpthread -lmach -lexc -lc
726            ([email protected])
727    AIX 4.1.4/{draft7,DCE}              (nothing)
728            ([email protected])
729    IRIX 6.2/POSIX                      -lpthread
730            ([email protected])
731
732
733Building a shared libpython
734---------------------------
735
736Starting with Python 2.3, the majority of the interpreter can be built
737into a shared library, which can then be used by the interpreter
738executable, and by applications embedding Python. To enable this feature,
739configure with --enable-shared.
740
741If you enable this feature, the same object files will be used to create
742a static library.  In particular, the static library will contain object
743files using position-independent code (PIC) on platforms where PIC flags
744are needed for the shared library.
745
746
747Configuring additional built-in modules
748---------------------------------------
749
750Starting with Python 2.1, the setup.py script at the top of the source
751distribution attempts to detect which modules can be built and
752automatically compiles them.  Autodetection doesn't always work, so
753you can still customize the configuration by editing the Modules/Setup
754file; but this should be considered a last resort.  The rest of this
755section only applies if you decide to edit the Modules/Setup file.
756You also need this to enable static linking of certain modules (which
757is needed to enable profiling on some systems).
758
759This file is initially copied from Setup.dist by the configure script;
760if it does not exist yet, create it by copying Modules/Setup.dist
761yourself (configure will never overwrite it).  Never edit Setup.dist
762-- always edit Setup or Setup.local (see below).  Read the comments in
763the file for information on what kind of edits are allowed.  When you
764have edited Setup in the Modules directory, the interpreter will
765automatically be rebuilt the next time you run make (in the toplevel
766directory).
767
768Many useful modules can be built on any Unix system, but some optional
769modules can't be reliably autodetected.  Often the quickest way to
770determine whether a particular module works or not is to see if it
771will build: enable it in Setup, then if you get compilation or link
772errors, disable it -- you're either missing support or need to adjust
773the compilation and linking parameters for that module.
774
775On SGI IRIX, there are modules that interface to many SGI specific
776system libraries, e.g. the GL library and the audio hardware.  These
777modules will not be built by the setup.py script.
778
779In addition to the file Setup, you can also edit the file Setup.local.
780(the makesetup script processes both).  You may find it more
781convenient to edit Setup.local and leave Setup alone.  Then, when
782installing a new Python version, you can copy your old Setup.local
783file.
784
785
786Setting the optimization/debugging options
787------------------------------------------
788
789If you want or need to change the optimization/debugging options for
790the C compiler, assign to the OPT variable on the toplevel make
791command; e.g. "make OPT=-g" will build a debugging version of Python
792on most platforms.  The default is OPT=-O; a value for OPT in the
793environment when the configure script is run overrides this default
794(likewise for CC; and the initial value for LIBS is used as the base
795set of libraries to link with).
796
797When compiling with GCC, the default value of OPT will also include
798the -Wall and -Wstrict-prototypes options.
799
800Additional debugging code to help debug memory management problems can
801be enabled by using the --with-pydebug option to the configure script.
802
803For flags that change binary compatibility, use the EXTRA_CFLAGS
804variable.
805
806
807Profiling
808---------
809
810If you want C profiling turned on, the easiest way is to run configure
811with the CC environment variable to the necessary compiler
812invocation.  For example, on Linux, this works for profiling using
813gprof(1):
814
815    CC="gcc -pg" ./configure
816
817Note that on Linux, gprof apparently does not work for shared
818libraries.  The Makefile/Setup mechanism can be used to compile and
819link most extension modules statically.
820
821
822Coverage checking
823-----------------
824
825For C coverage checking using gcov, run "make coverage".  This will
826build a Python binary with profiling activated, and a ".gcno" and
827".gcda" file for every source file compiled with that option.  With
828the built binary, now run the code whose coverage you want to check.
829Then, you can see coverage statistics for each individual source file
830by running gcov, e.g.
831
832    gcov -o Modules zlibmodule
833
834This will create a "zlibmodule.c.gcov" file in the current directory
835containing coverage info for that source file.
836
837This works only for source files statically compiled into the
838executable; use the Makefile/Setup mechanism to compile and link
839extension modules you want to coverage-check statically.
840
841
842Testing
843-------
844
845To test the interpreter, type "make test" in the top-level directory.
846This runs the test set twice (once with no compiled files, once with
847the compiled files left by the previous test run).  The test set
848produces some output.  You can generally ignore the messages about
849skipped tests due to optional features which can't be imported.
850If a message is printed about a failed test or a traceback or core
851dump is produced, something is wrong.  On some Linux systems (those
852that are not yet using glibc 6), test_strftime fails due to a
853non-standard implementation of strftime() in the C library. Please
854ignore this, or upgrade to glibc version 6.
855
856By default, tests are prevented from overusing resources like disk space and
857memory.  To enable these tests, run "make testall".
858
859IMPORTANT: If the tests fail and you decide to mail a bug report,
860*don't* include the output of "make test".  It is useless.  Run the
861failing test manually, as follows:
862
863        ./python Lib/test/regrtest.py -v test_whatever
864
865(substituting the top of the source tree for '.' if you built in a
866different directory).  This runs the test in verbose mode.
867
868
869Installing
870----------
871
872To install the Python binary, library modules, shared library modules
873(see below), include files, configuration files, and the manual page,
874just type
875
876        make install
877
878This will install all platform-independent files in subdirectories of
879the directory given with the --prefix option to configure or to the
880`prefix' Make variable (default /usr/local).  All binary and other
881platform-specific files will be installed in subdirectories if the
882directory given by --exec-prefix or the `exec_prefix' Make variable
883(defaults to the --prefix directory) is given.
884
885If DESTDIR is set, it will be taken as the root directory of the
886installation, and files will be installed into $(DESTDIR)$(prefix),
887$(DESTDIR)$(exec_prefix), etc.
888
889All subdirectories created will have Python's version number in their
890name, e.g. the library modules are installed in
891"/usr/local/lib/python<version>/" by default, where <version> is the
892<major>.<minor> release number (e.g. "2.1").  The Python binary is
893installed as "python<version>" and a hard link named "python" is
894created.  The only file not installed with a version number in its
895name is the manual page, installed as "/usr/local/man/man1/python.1"
896by default.
897
898If you want to install multiple versions of Python see the section below
899entitled "Installing multiple versions".
900
901The only thing you may have to install manually is the Python mode for
902Emacs found in Misc/python-mode.el.  (But then again, more recent
903versions of Emacs may already have it.)  Follow the instructions that
904came with Emacs for installation of site-specific files.
905
906On Mac OS X, if you have configured Python with --enable-framework, you
907should use "make frameworkinstall" to do the installation. Note that this
908installs the Python executable in a place that is not normally on your
909PATH, you may want to set up a symlink in /usr/local/bin.
910
911
912Installing multiple versions
913----------------------------
914
915On Unix and Mac systems if you intend to install multiple versions of Python
916using the same installation prefix (--prefix argument to the configure
917script) you must take care that your primary python executable is not
918overwritten by the installation of a different version.  All files and
919directories installed using "make altinstall" contain the major and minor
920version and can thus live side-by-side.  "make install" also creates
921${prefix}/bin/python which refers to ${prefix}/bin/pythonX.Y.  If you intend
922to install multiple versions using the same prefix you must decide which
923version (if any) is your "primary" version.  Install that version using
924"make install".  Install all other versions using "make altinstall".
925
926For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being
927the primary version, you would execute "make install" in your 2.6 build
928directory and "make altinstall" in the others.
929
930
931Configuration options and variables
932-----------------------------------
933
934Some special cases are handled by passing options to the configure
935script.
936
937WARNING: if you rerun the configure script with different options, you
938must run "make clean" before rebuilding.  Exceptions to this rule:
939after changing --prefix or --exec-prefix, all you need to do is remove
940Modules/getpath.o.
941
942--with(out)-gcc: The configure script uses gcc (the GNU C compiler) if
943        it finds it.  If you don't want this, or if this compiler is
944        installed but broken on your platform, pass the option
945        --without-gcc.  You can also pass "CC=cc" (or whatever the
946        name of the proper C compiler is) in the environment, but the
947        advantage of using --without-gcc is that this option is
948        remembered by the config.status script for its --recheck
949        option.
950
951--prefix, --exec-prefix: If you want to install the binaries and the
952        Python library somewhere else than in /usr/local/{bin,lib},
953        you can pass the option --prefix=DIRECTORY; the interpreter
954        binary will be installed as DIRECTORY/bin/python and the
955        library files as DIRECTORY/lib/python/*.  If you pass
956        --exec-prefix=DIRECTORY (as well) this overrides the
957        installation prefix for architecture-dependent files (like the
958        interpreter binary).  Note that --prefix=DIRECTORY also
959        affects the default module search path (sys.path), when
960        Modules/config.c is compiled.  Passing make the option
961        prefix=DIRECTORY (and/or exec_prefix=DIRECTORY) overrides the
962        prefix set at configuration time; this may be more convenient
963        than re-running the configure script if you change your mind
964        about the install prefix.
965
966--with-readline: This option is no longer supported.  GNU
967        readline is automatically enabled by setup.py when present.
968
969--with-threads: On most Unix systems, you can now use multiple
970        threads, and support for this is enabled by default.  To
971        disable this, pass --with-threads=no.  If the library required
972        for threads lives in a peculiar place, you can use
973        --with-thread=DIRECTORY.  IMPORTANT: run "make clean" after
974        changing (either enabling or disabling) this option, or you
975        will get link errors!  Note: for DEC Unix use
976        --with-dec-threads instead.
977
978--with-sgi-dl: On SGI IRIX 4, dynamic loading of extension modules is
979        supported by the "dl" library by Jack Jansen, which is
980        ftp'able from ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z.
981        This is enabled (after you've ftp'ed and compiled the dl
982        library) by passing --with-sgi-dl=DIRECTORY where DIRECTORY
983        is the absolute pathname of the dl library.  (Don't bother on
984        IRIX 5, it already has dynamic linking using SunOS style
985        shared libraries.)  THIS OPTION IS UNSUPPORTED.
986
987--with-dl-dld: Dynamic loading of modules is rumored to be supported
988        on some other systems: VAX (Ultrix), Sun3 (SunOS 3.4), Sequent
989        Symmetry (Dynix), and Atari ST.  This is done using a
990        combination of the GNU dynamic loading package
991        (ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z) and an
992        emulation of the SGI dl library mentioned above (the emulation
993        can be found at
994        ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z).  To
995        enable this, ftp and compile both libraries, then call
996        configure, passing it the option
997        --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY where DL_DIRECTORY is
998        the absolute pathname of the dl emulation library and
999        DLD_DIRECTORY is the absolute pathname of the GNU dld library.
1000        (Don't bother on SunOS 4 or 5, they already have dynamic
1001        linking using shared libraries.)  THIS OPTION IS UNSUPPORTED.
1002
1003--with-libm, --with-libc: It is possible to specify alternative
1004        versions for the Math library (default -lm) and the C library
1005        (default the empty string) using the options
1006        --with-libm=STRING and --with-libc=STRING, respectively.  For
1007        example, if your system requires that you pass -lc_s to the C
1008        compiler to use the shared C library, you can pass
1009        --with-libc=-lc_s. These libraries are passed after all other
1010        libraries, the C library last.
1011
1012--with-libs='libs': Add 'libs' to the LIBS that the python interpreter
1013        is linked against.
1014
1015--with-cxx-main=<compiler>: If you plan to use C++ extension modules,
1016        then -- on some platforms -- you need to compile python's main()
1017        function with the C++ compiler. With this option, make will use
1018        <compiler> to compile main() *and* to link the python executable.
1019        It is likely that the resulting executable depends on the C++
1020        runtime library of <compiler>. (The default is --without-cxx-main.)
1021
1022        There are platforms that do not require you to build Python
1023        with a C++ compiler in order to use C++ extension modules.
1024        E.g., x86 Linux with ELF shared binaries and GCC 3.x, 4.x is such
1025        a platform. We recommend that you configure Python
1026        --without-cxx-main on those platforms because a mismatch
1027        between the C++ compiler version used to build Python and to
1028        build a C++ extension module is likely to cause a crash at
1029        runtime.
1030
1031        The Python installation also stores the variable CXX that
1032        determines, e.g., the C++ compiler distutils calls by default
1033        to build C++ extensions. If you set CXX on the configure command
1034        line to any string of non-zero length, then configure won't
1035        change CXX. If you do not preset CXX but pass
1036        --with-cxx-main=<compiler>, then configure sets CXX=<compiler>.
1037        In all other cases, configure looks for a C++ compiler by
1038        some common names (c++, g++, gcc, CC, cxx, cc++, cl) and sets
1039        CXX to the first compiler it finds. If it does not find any
1040        C++ compiler, then it sets CXX="".
1041
1042        Similarly, if you want to change the command used to link the
1043        python executable, then set LINKCC on the configure command line.
1044
1045
1046--with-pydebug:  Enable additional debugging code to help track down
1047        memory management problems.  This allows printing a list of all
1048        live objects when the interpreter terminates.
1049
1050--with(out)-universal-newlines: enable reading of text files with
1051        foreign newline convention (default: enabled). In other words,
1052        any of \r, \n or \r\n is acceptable as end-of-line character.
1053        If enabled import and execfile will automatically accept any newline
1054        in files. Python code can open a file with open(file, 'U') to
1055        read it in universal newline mode. THIS OPTION IS UNSUPPORTED.
1056
1057--with-tsc: Profile using the Pentium timestamping counter (TSC).
1058
1059--with-system-ffi:  Build the _ctypes extension module using an ffi
1060        library installed on the system.
1061
1062--with-dbmliborder=db1:db2:...:  Specify the order that backends for the
1063	dbm extension are checked. Valid value is a colon separated string
1064	with the backend names `ndbm', `gdbm' and `bdb'.
1065
1066Building for multiple architectures (using the VPATH feature)
1067-------------------------------------------------------------
1068
1069If your file system is shared between multiple architectures, it
1070usually is not necessary to make copies of the sources for each
1071architecture you want to support.  If the make program supports the
1072VPATH feature, you can create an empty build directory for each
1073architecture, and in each directory run the configure script (on the
1074appropriate machine with the appropriate options).  This creates the
1075necessary subdirectories and the Makefiles therein.  The Makefiles
1076contain a line VPATH=... which points to a directory containing the
1077actual sources.  (On SGI systems, use "smake -J1" instead of "make" if
1078you use VPATH -- don't try gnumake.)
1079
1080For example, the following is all you need to build a minimal Python
1081in /usr/tmp/python (assuming ~guido/src/python is the toplevel
1082directory and you want to build in /usr/tmp/python):
1083
1084        $ mkdir /usr/tmp/python
1085        $ cd /usr/tmp/python
1086        $ ~guido/src/python/configure
1087        [...]
1088        $ make
1089        [...]
1090        $
1091
1092Note that configure copies the original Setup file to the build
1093directory if it finds no Setup file there.  This means that you can
1094edit the Setup file for each architecture independently.  For this
1095reason, subsequent changes to the original Setup file are not tracked
1096automatically, as they might overwrite local changes.  To force a copy
1097of a changed original Setup file, delete the target Setup file.  (The
1098makesetup script supports multiple input files, so if you want to be
1099fancy you can change the rules to create an empty Setup.local if it
1100doesn't exist and run it with arguments $(srcdir)/Setup Setup.local;
1101however this assumes that you only need to add modules.)
1102
1103Also note that you can't use a workspace for VPATH and non VPATH builds. The
1104object files left behind by one version confuses the other.
1105
1106
1107Building on non-UNIX systems
1108----------------------------
1109
1110For Windows (2000/NT/ME/98/95), assuming you have MS VC++ 7.1, the
1111project files are in PCbuild, the workspace is pcbuild.dsw.  See
1112PCbuild\readme.txt for detailed instructions.
1113
1114For other non-Unix Windows compilers, in particular MS VC++ 6.0 and
1115for OS/2, enter the directory "PC" and read the file "readme.txt".
1116
1117For the Mac, a separate source distribution will be made available,
1118for use with the CodeWarrior compiler.  If you are interested in Mac
1119development, join the PythonMac Special Interest Group
1120(http://www.python.org/sigs/pythonmac-sig/, or send email to
1121[email protected]).
1122
1123Of course, there are also binary distributions available for these
1124platforms -- see http://www.python.org/.
1125
1126To port Python to a new non-UNIX system, you will have to fake the
1127effect of running the configure script manually (for Mac and PC, this
1128has already been done for you).  A good start is to copy the file
1129pyconfig.h.in to pyconfig.h and edit the latter to reflect the actual
1130configuration of your system.  Most symbols must simply be defined as
11311 only if the corresponding feature is present and can be left alone
1132otherwise; however the *_t type symbols must be defined as some
1133variant of int if they need to be defined at all.
1134
1135For all platforms, it's important that the build arrange to define the
1136preprocessor symbol NDEBUG on the compiler command line in a release
1137build of Python (else assert() calls remain in the code, hurting
1138release-build performance).  The Unix, Windows and Mac builds already
1139do this.
1140
1141
1142Miscellaneous issues
1143====================
1144
1145Emacs mode
1146----------
1147
1148There's an excellent Emacs editing mode for Python code; see the file
1149Misc/python-mode.el.  Originally written by the famous Tim Peters, it is now
1150maintained by the equally famous Barry Warsaw.  The latest version, along with
1151various other contributed Python-related Emacs goodies, is online at
1152http://launchpad.net/python-mode/.
1153
1154
1155Tkinter
1156-------
1157
1158The setup.py script automatically configures this when it detects a
1159usable Tcl/Tk installation.  This requires Tcl/Tk version 8.0 or
1160higher.
1161
1162For more Tkinter information, see the Tkinter Resource page:
1163http://www.python.org/topics/tkinter/
1164
1165There are demos in the Demo/tkinter directory.
1166
1167Note that there's a Python module called "Tkinter" (capital T) which
1168lives in Lib/lib-tk/Tkinter.py, and a C module called "_tkinter"
1169(lower case t and leading underscore) which lives in
1170Modules/_tkinter.c.  Demos and normal Tk applications import only the
1171Python Tkinter module -- only the latter imports the C _tkinter
1172module.  In order to find the C _tkinter module, it must be compiled
1173and linked into the Python interpreter -- the setup.py script does
1174this.  In order to find the Python Tkinter module, sys.path must be
1175set correctly -- normal installation takes care of this.
1176
1177
1178Distribution structure
1179----------------------
1180
1181Most subdirectories have their own README files.  Most files have
1182comments.
1183
1184Demo/           Demonstration scripts, modules and programs
1185Doc/            Documentation sources (reStructuredText)
1186Grammar/        Input for the parser generator
1187Include/        Public header files
1188LICENSE         Licensing information
1189Lib/            Python library modules
1190Mac/            Macintosh specific resources
1191Makefile.pre.in Source from which config.status creates the Makefile.pre
1192Misc/           Miscellaneous useful files
1193Modules/        Implementation of most built-in modules
1194Objects/        Implementation of most built-in object types
1195PC/             Files specific to PC ports (DOS, Windows, OS/2)
1196PCbuild/        Build directory for Microsoft Visual C++
1197Parser/         The parser and tokenizer and their input handling
1198Python/         The byte-compiler and interpreter
1199README          The file you're reading now
1200RISCOS/         Files specific to RISC OS port
1201Tools/          Some useful programs written in Python
1202pyconfig.h.in   Source from which pyconfig.h is created (GNU autoheader output)
1203configure       Configuration shell script (GNU autoconf output)
1204configure.in    Configuration specification (input for GNU autoconf)
1205install-sh      Shell script used to install files
1206setup.py        Python script used to build extension modules
1207
1208The following files will (may) be created in the toplevel directory by
1209the configuration and build processes:
1210
1211Makefile        Build rules
1212Makefile.pre    Build rules before running Modules/makesetup
1213buildno         Keeps track of the build number
1214config.cache    Cache of configuration variables
1215pyconfig.h      Configuration header
1216config.log      Log from last configure run
1217config.status   Status from last run of the configure script
1218getbuildinfo.o  Object file from Modules/getbuildinfo.c
1219libpython<version>.a    The library archive
1220python          The executable interpreter
1221reflog.txt      Output from running the regression suite with the -R flag
1222tags, TAGS      Tags files for vi and Emacs
1223
1224
1225That's all, folks!
1226------------------
1227
1228
1229--Guido van Rossum (home page: http://www.python.org/~guido/)
1230