install-source.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. -------------------------------------------------
  2. pysqlite installation guide - source distribution
  3. -------------------------------------------------
  4. \(c\) 2005 Gerhard Häring
  5. Note: For Windows users, it is recommended that you use the win32 binary
  6. distribution of pysqlite!
  7. Steps:
  8. - `Step 1: Satisfy the dependencies`_
  9. - `Step 2: Compile pysqlite`_
  10. - `Step 3: Install pysqlite`_
  11. - `Step 4: Test your pysqlite installation`_
  12. Step 1: Satisfy The Dependencies
  13. ================================
  14. pysqlite requires a valid combination of the dependencies in the list below.
  15. Detailed instructions on how to install each dependency are beyond the scope of
  16. this document; consult the dependency distributor for installation
  17. instructions.
  18. Dependencies:
  19. 1. Operating System and C Compiler - one of:
  20. * Linux/FreeBSD/NetBSD/OpenBSD and GCC
  21. * Other POSIX-compliant operating system and a C compiler
  22. 2. SQLite:
  23. * SQLite version 3.0.8 or later (as of pysqlite 2.2.0). This means we need
  24. the SQLite library installed - either statically or dynamically linked -
  25. and the SQLite header files. On Linux, the chances are very high that
  26. your distribution offers packages for SQLite 3. Be sure to verify the
  27. package is recent enough (version 3.0.8 or higher) and that you're
  28. installing the development package as well, which will be need for
  29. building pysqlite. On Debian and derivatives, the package to look for is
  30. called libsqlite3-dev.
  31. 3. Python:
  32. * Python 2.3 or later
  33. Step 2: Compile pysqlite
  34. ========================
  35. Once you have successfully installed the dependencies, you may proceed with the
  36. installation of pysqlite itself.
  37. pysqlite has full support for the distutils_, the standard facility for Python
  38. package distribution and installation. Full instructions for using the
  39. distutils are available in `this section of the Python documentation`_, but you
  40. can skip them unless you have an otherwise insoluble problem.
  41. Open a command prompt, change to the directory where you decompressed the
  42. pysqlite source distribution, and type::
  43. python setup.py build
  44. The installation script, setup.py, will attempt to automatically detect the
  45. information needed by the C compiler; then it will invoke the distutils to
  46. perform the actual compilation. If you installed automatic distributions of the
  47. dependencies that place themselves in standard locations (on UNIX-style
  48. operating systems), the compilation should proceed without incident.
  49. Otherwise you will have to customize the build process. That's what the file
  50. *setup.cfg* is meant for. It's contains a few lines that you can customize so
  51. your C compiler will find the library and header files and you can also do a
  52. few other tweaks, like build pysqlite in debug mode.
  53. After you've customized *setup.cfg* appropriately, try invoking ``python
  54. setup.py build`` again.
  55. If setup.py raises no errors and its output concludes with something like
  56. "Creating library...", then you are ready to proceed to the next step.
  57. If you receive an error message from the compiler, then try to look at the
  58. first error it reports. Other errors will most likely be aftereffects from the
  59. first error (like not finding the sqlite3.h header file).
  60. Step 3: Install pysqlite
  61. ========================
  62. During this step, the setup script moves the *pysqlite2* package (including the
  63. newly compiled C extension) to the standard package directory of your Python
  64. installation so that Python will be able to import pysqlite2.dbapi2 and
  65. pysqlite2.test.
  66. In addition to the Python code and shared library files actually used by the
  67. Python interpreter, the setup script typically installs some supporting files,
  68. such as documentation. Depending on your system configuration, these supporting
  69. files may be placed in the same directory or a different directory from the
  70. files used by the Python interpreter.
  71. Run the following command::
  72. python setup.py install
  73. The setup script will install pysqlite, listing each file it installs.
  74. Errors during this step are rare because compilation (the finicky part of this
  75. process) has already taken place; installation is really just a matter of
  76. copying files. However, there will be file system permission errors if the
  77. Python installation directory is not writable by the user running the setup
  78. script. If you encounter such an error, try one of the following:
  79. - Log in as a user who has the required file system permissions and repeat the
  80. installation step.
  81. - Manually copy the directory build/lib.platform-pyver/pysqlite2 (which
  82. contains the Python modules and compiled library files created during the
  83. compilation step) to a directory in your PYTHONPATH. This approach will not
  84. install the supporting files, but they are for the benefit of the programmer
  85. rather than the Python interpreter anyway.
  86. Step 4: Test Your pysqlite Installation
  87. =======================================
  88. Switch to a directory other than the temporary directory into which you
  89. decompressed the source distribution (to avoid conflict between the copy of
  90. pysqlite in that directory and the copy placed under the standard Python
  91. site-packages directory), then run the pysqlite test suite by starting a Python
  92. interpreter for the Python version you installed pysqlite for and entering the
  93. following::
  94. >>> from pysqlite2 import test
  95. >>> test.test()
  96. .....................................................................................................
  97. ----------------------------------------------------------------------
  98. Ran 101 tests in 0.182s
  99. If the test suite runs without any errors, you are finished.
  100. You should not encounter any errors at this stage since you have already
  101. completed the compilation and installation steps successfully. If you do,
  102. please report them to the `pysqlite bug tracker`_ or the `pysqlite mailing
  103. list`_.
  104. .. _distutils: http://www.python.org/sigs/distutils-sig/
  105. .. _this section of the Python documentation: http://www.python.org/doc/current/inst/inst.html
  106. .. _pysqlite bug tracker: http://pysqlite.org/
  107. .. _pysqlite mailing list: http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite