install.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. .. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. .. For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. .. _install:
  4. ============
  5. Installation
  6. ============
  7. .. :history: 20100725T225600, new for 3.4.
  8. .. :history: 20100820T151500, updated for 3.4b1.
  9. .. :history: 20100906T134800, updated for 3.4b2.
  10. .. :history: 20110604T213400, updated for 3.5b1.
  11. .. :history: 20110629T082400, updated for 3.5.
  12. .. :history: 20110923T081900, updated for 3.5.1.
  13. .. :history: 20120429T162500, updated for 3.5.2b1.
  14. .. :history: 20120503T234000, updated for 3.5.2.
  15. .. :history: 20120929T093600, updated for 3.5.3.
  16. .. :history: 20121117T095000, Now setuptools is a pre-req.
  17. .. :history: 20121128T203000, updated for 3.6b1.
  18. .. :history: 20121223T180800, updated for 3.6b2.
  19. .. :history: 20121229T112400, updated for 3.6b3.
  20. .. :history: 20130105T174400, updated for 3.6.
  21. .. :history: 20131005T210600, updated for 3.7.
  22. .. :history: 20131212T213500, updated for 3.7.1.
  23. .. :history: 20140927T102700, updated for 4.0a1.
  24. .. highlight:: console
  25. .. _coverage_pypi: http://pypi.python.org/pypi/coverage
  26. .. _setuptools: http://pypi.python.org/pypi/setuptools
  27. .. _Distribute: http://packages.python.org/distribute/
  28. Installing coverage.py is done in the usual ways. The simplest way is with
  29. pip::
  30. $ pip install coverage
  31. .. ifconfig:: prerelease
  32. To install a pre-release version, you will need to specify ``--pre``::
  33. $ pip install --pre coverage
  34. The alternate old-school technique is:
  35. #. Install (or already have installed) `setuptools`_ or `Distribute`_.
  36. #. Download the appropriate kit from the
  37. `coverage.py page on the Python Package Index`__.
  38. #. Run ``python setup.py install``.
  39. .. __: coverage_pypi_
  40. .. _install_extension:
  41. C Extension
  42. -----------
  43. Coverage.py includes a C extension for speed. It is strongly recommended to use
  44. this extension: it is much faster, and is needed to support a number of
  45. coverage.py features. Most of the time, the C extension will be installed
  46. without any special action on your part.
  47. If you are installing on Linux, you may need to install the python-dev and gcc
  48. support files before installing coverage via pip. The exact commands depend on
  49. which package manager you use, which Python version you are using, and the
  50. names of the packages for your distribution. For example::
  51. $ sudo apt-get install python-dev gcc
  52. $ sudo yum install python-devel gcc
  53. $ sudo apt-get install python3-dev gcc
  54. $ sudo yum install python3-devel gcc
  55. You can determine if you are using the extension by looking at the output of
  56. ``coverage --version``::
  57. $ coverage --version
  58. Coverage.py, version |release| with C extension
  59. Documentation at https://coverage.readthedocs.io
  60. The first line will either say "with C extension," or "without C extension."
  61. A few features of coverage.py aren't supported without the C extension, such
  62. as concurrency and plugins.
  63. Installing on Windows
  64. ---------------------
  65. For Windows, kits are provided on the `PyPI page`__ for different versions of
  66. Python and different CPU architectures. These kits require that `setuptools`_
  67. be installed as a pre-requisite, but otherwise are self-contained. They have
  68. the C extension pre-compiled so there's no need to worry about compilers.
  69. .. __: coverage_pypi_
  70. Checking the installation
  71. -------------------------
  72. If all went well, you should be able to open a command prompt, and see
  73. coverage.py installed properly:
  74. .. ifconfig:: not prerelease
  75. .. parsed-literal::
  76. $ coverage --version
  77. Coverage.py, version |release| with C extension
  78. Documentation at https://coverage.readthedocs.io
  79. .. ifconfig:: prerelease
  80. .. parsed-literal::
  81. $ coverage --version
  82. Coverage.py, version |release| with C extension
  83. Documentation at https://coverage.readthedocs.io/en/coverage-|release|
  84. You can also invoke coverage.py as a module:
  85. .. ifconfig:: not prerelease
  86. .. parsed-literal::
  87. $ python -m coverage --version
  88. Coverage.py, version |release| with C extension
  89. Documentation at https://coverage.readthedocs.io
  90. .. ifconfig:: prerelease
  91. .. parsed-literal::
  92. $ python -m coverage --version
  93. Coverage.py, version |release| with C extension
  94. Documentation at https://coverage.readthedocs.io/en/coverage-|release|