python.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-Python" role="wrap">
  8. <?dbhtml filename="Python.html"?>
  9. <sect1info condition="script">
  10. <productname>Python</productname>
  11. <productnumber>&python-version;</productnumber>
  12. <address>&python-url;</address>
  13. </sect1info>
  14. <title>Python-&python-version;</title>
  15. <indexterm zone="ch-system-Python">
  16. <primary sortas="a-python">python</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>Python 3 软件包包含 Python 开发环境。它被用于面向对象编程、
  21. 编写脚本、为大型程序建立原型或开发完整的应用。</para>
  22. <!--para>The Python 3 package contains the Python development environment. It
  23. is useful for object-oriented programming, writing scripts, prototyping
  24. large programs or developing entire applications.</para-->
  25. <segmentedlist>
  26. <segtitle>&buildtime;</segtitle>
  27. <segtitle>&diskspace;</segtitle>
  28. <seglistitem>
  29. <seg>&python-ch6-sbu;</seg>
  30. <seg>&python-ch6-du;</seg>
  31. </seglistitem>
  32. </segmentedlist>
  33. </sect2>
  34. <sect2 role="installation">
  35. <title>安装 Python 3</title>
  36. <para>准备安装 Python:</para>
  37. <screen><userinput remap="configure">./configure --prefix=/usr \
  38. --enable-shared \
  39. --with-system-expat \
  40. --with-system-ffi \
  41. --with-ensurepip=yes</userinput></screen>
  42. <variablelist>
  43. <title>配置选项的含义:</title>
  44. <varlistentry>
  45. <term><parameter>--with-system-expat</parameter></term>
  46. <listitem>
  47. <para>该选项允许链接到系统已经安装的
  48. <application>Expat</application>。</para>
  49. </listitem>
  50. </varlistentry>
  51. <varlistentry>
  52. <term><parameter>--with-system-ffi</parameter></term>
  53. <listitem>
  54. <para>该选项允许链接到系统已经安装的
  55. <application>libffi</application>。</para>
  56. </listitem>
  57. </varlistentry>
  58. <varlistentry>
  59. <term><parameter>--with-ensurepip=yes</parameter></term>
  60. <listitem>
  61. <para>该选项启用 <command>pip</command> 和
  62. <command>setuptools</command> 包管理程序的构建。</para>
  63. </listitem>
  64. </varlistentry>
  65. </variablelist>
  66. <para>编译该软件包:</para>
  67. <screen><userinput remap="make">make</userinput></screen>
  68. <para>测试套件需要 Tk 和 X 窗口会话的支持,
  69. 必须在 BLFS 中重新安装 Python 3 后才能运行。</para>
  70. <para>安装该软件包:</para>
  71. <screen><userinput remap="install">make install
  72. chmod -v 755 /usr/lib/libpython&python-minor;m.so
  73. chmod -v 755 /usr/lib/libpython3.so
  74. ln -sfv pip3.7 /usr/bin/pip3</userinput></screen>
  75. <variablelist>
  76. <title>安装命令的含义:</title>
  77. <varlistentry>
  78. <term><command>chmod -v 755 /usr/lib/libpython3.{7m.,}so</command></term>
  79. <listitem>
  80. <para>修正库文件访问权限,使之和其他库文件一致。</para>
  81. </listitem>
  82. </varlistentry>
  83. </variablelist>
  84. <para>如果需要的话,安装预先格式化的文档:</para>
  85. <screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
  86. tar --strip-components=1 \
  87. --no-same-owner \
  88. --no-same-permissions \
  89. -C /usr/share/doc/python-&python-version;/html \
  90. -xvf ../python-&python-version;-docs-html.tar.bz2</userinput></screen>
  91. <variablelist>
  92. <title>文档安装命令的含义:</title>
  93. <varlistentry>
  94. <term><option>--no-same-owner</option> 和
  95. <option>--no-same-permissions</option></term>
  96. <listitem>
  97. <para>保证安装的文件拥有正确的所有者和权限码。
  98. 在没有这些选项的时候,<application>tar</application>
  99. 会以上游开发者使用的用户和权限码安装文件。
  100. </para>
  101. </listitem>
  102. </varlistentry>
  103. </variablelist>
  104. </sect2>
  105. <sect2 id="contents-python" role="content">
  106. <title>Python 3 的内容</title>
  107. <segmentedlist>
  108. <segtitle>安装的程序</segtitle>
  109. <segtitle>安装的库</segtitle>
  110. <segtitle>安装的目录</segtitle>
  111. <seglistitem>
  112. <seg>
  113. 2to3, idle3, pip3, pydoc3, python3, python3-config, 以及 pyvenv
  114. </seg>
  115. <seg>
  116. libpython&python-minor;m.so 和 libpython3.so
  117. </seg>
  118. <seg>
  119. /usr/include/python&python-minor;m, /usr/lib/python3 以及
  120. /usr/share/doc/python-&python-version;
  121. </seg>
  122. </seglistitem>
  123. </segmentedlist>
  124. <variablelist>
  125. <bridgehead renderas="sect3">简要描述</bridgehead>
  126. <?dbfo list-presentation="list"?>
  127. <?dbhtml list-presentation="table"?>
  128. <varlistentry id="python-2to3">
  129. <term><command>2to3</command></term>
  130. <listitem>
  131. <para>
  132. 是一个 <application>Python</application> 程序,读取
  133. <application>Python 2.x</application>
  134. 源代码并对它进行一系列修正,转换成合法的
  135. <application>Python 3.x</application> 源代码。
  136. </para>
  137. <indexterm zone="ch-system-Python">
  138. <primary sortas="b-2to3">2to3</primary>
  139. </indexterm>
  140. </listitem>
  141. </varlistentry>
  142. <varlistentry id="idle3">
  143. <term><command>idle3</command></term>
  144. <listitem>
  145. <para>
  146. 一个封装脚本,启动支持 <application>Python</application>
  147. 语法的 GUI 文本编辑器。要运行这个脚本,必须在 Python 之前安装
  148. <application>Tk</application> ,从而构建 Tkinter Python 模块。
  149. </para>
  150. <indexterm zone="ch-system-Python">
  151. <primary sortas="b-idle3">idle3</primary>
  152. </indexterm>
  153. </listitem>
  154. </varlistentry>
  155. <varlistentry id="pip3">
  156. <term><command>pip3</command></term>
  157. <listitem>
  158. <para>
  159. Python 包安装器。
  160. 您可以使用 pip 安装来自 Python 软件包目录或其他目录的包。
  161. </para>
  162. <indexterm zone="ch-system-Python">
  163. <primary sortas="b-pip3">pip3</primary>
  164. </indexterm>
  165. </listitem>
  166. </varlistentry>
  167. <varlistentry id="pydoc3">
  168. <term><command>pydoc3</command></term>
  169. <listitem>
  170. <para>
  171. 是 <application>Python</application> 文档工具。
  172. </para>
  173. <indexterm zone="ch-system-Python">
  174. <primary sortas="b-pydoc3">pydoc3</primary>
  175. </indexterm>
  176. </listitem>
  177. </varlistentry>
  178. <varlistentry id="python3">
  179. <term><command>python3</command></term>
  180. <listitem>
  181. <para>
  182. 是一个解释性、交互性、面向对象的程序设计语言
  183. </para>
  184. <indexterm zone="ch-system-Python">
  185. <primary sortas="b-python3">python3</primary>
  186. </indexterm>
  187. </listitem>
  188. </varlistentry>
  189. <varlistentry id="pyvenv">
  190. <term><command>pyvenv</command></term>
  191. <listitem>
  192. <para>
  193. 在一个或多个目标目录创建 <application>Python</application>
  194. 虚拟环境
  195. </para>
  196. <indexterm zone="ch-system-Python">
  197. <primary sortas="b-pyvenv">pyvenv</primary>
  198. </indexterm>
  199. </listitem>
  200. </varlistentry>
  201. </variablelist>
  202. </sect2>
  203. </sect1>