python.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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</userinput></screen>
  74. <variablelist>
  75. <title>安装命令的含义:</title>
  76. <varlistentry>
  77. <term><command>chmod -v 755 /usr/lib/libpython3.{7m.,}so</command></term>
  78. <listitem>
  79. <para>修正库文件访问权限,使之和其他库文件一致。</para>
  80. </listitem>
  81. </varlistentry>
  82. </variablelist>
  83. <para>如果需要的话,安装预先格式化的文档:</para>
  84. <screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
  85. tar --strip-components=1 \
  86. --no-same-owner \
  87. --no-same-permissions \
  88. -C /usr/share/doc/python-&python-version;/html \
  89. -xvf ../python-&python-version;-docs-html.tar.bz2</userinput></screen>
  90. <variablelist>
  91. <title>文档安装命令的含义:</title>
  92. <varlistentry>
  93. <term><option>--no-same-owner</option> 和
  94. <option>--no-same-permissions</option></term>
  95. <listitem>
  96. <para>保证安装的文件拥有正确的所有者和权限码。
  97. 在没有这些选项的时候,<application>tar</application>
  98. 会以上游开发者使用的用户和权限码安装文件。
  99. </para>
  100. </listitem>
  101. </varlistentry>
  102. </variablelist>
  103. </sect2>
  104. <sect2 id="contents-python" role="content">
  105. <title>Python 3 的内容</title>
  106. <segmentedlist>
  107. <segtitle>安装的程序</segtitle>
  108. <segtitle>安装的库</segtitle>
  109. <segtitle>安装的目录</segtitle>
  110. <seglistitem>
  111. <seg>
  112. 2to3, idle3, pydoc3, python3, python3-config, pyvenv
  113. </seg>
  114. <seg>
  115. libpython&python-minor;m.so 和 libpython3.so
  116. </seg>
  117. <seg>
  118. /usr/include/python&python-minor;m, /usr/lib/python3 以及
  119. /usr/share/doc/python-&python-version;
  120. </seg>
  121. </seglistitem>
  122. </segmentedlist>
  123. <variablelist>
  124. <bridgehead renderas="sect3">简要描述</bridgehead>
  125. <?dbfo list-presentation="list"?>
  126. <?dbhtml list-presentation="table"?>
  127. <varlistentry id="python-2to3">
  128. <term><command>2to3</command></term>
  129. <listitem>
  130. <para>
  131. 是一个 <application>Python</application> 程序,读取
  132. <application>Python 2.x</application>
  133. 源代码并对它进行一系列修正,转换成合法的
  134. <application>Python 3.x</application> 源代码。
  135. </para>
  136. <indexterm zone="ch-system-Python">
  137. <primary sortas="b-2to3">2to3</primary>
  138. </indexterm>
  139. </listitem>
  140. </varlistentry>
  141. <varlistentry id="idle3">
  142. <term><command>idle3</command></term>
  143. <listitem>
  144. <para>
  145. 一个封装脚本,启动支持 <application>Python</application>
  146. 语法的 GUI 文本编辑器。要运行这个脚本,必须在 Python 之前安装
  147. <application>Tk</application> ,从而构建 Tkinter Python 模块。
  148. </para>
  149. <indexterm zone="ch-system-Python">
  150. <primary sortas="b-idle3">idle3</primary>
  151. </indexterm>
  152. </listitem>
  153. </varlistentry>
  154. <varlistentry id="pydoc3">
  155. <term><command>pydoc3</command></term>
  156. <listitem>
  157. <para>
  158. 是 <application>Python</application> 文档工具。
  159. </para>
  160. <indexterm zone="ch-system-Python">
  161. <primary sortas="b-pydoc3">pydoc3</primary>
  162. </indexterm>
  163. </listitem>
  164. </varlistentry>
  165. <varlistentry id="python3">
  166. <term><command>python3</command></term>
  167. <listitem>
  168. <para>
  169. 是一个解释性、交互性、面向对象的程序设计语言
  170. </para>
  171. <indexterm zone="ch-system-Python">
  172. <primary sortas="b-python3">python3</primary>
  173. </indexterm>
  174. </listitem>
  175. </varlistentry>
  176. <varlistentry id="pyvenv">
  177. <term><command>pyvenv</command></term>
  178. <listitem>
  179. <para>
  180. 在一个或多个目标目录创建 <application>Python</application>
  181. 虚拟环境
  182. </para>
  183. <indexterm zone="ch-system-Python">
  184. <primary sortas="b-pyvenv">pyvenv</primary>
  185. </indexterm>
  186. </listitem>
  187. </varlistentry>
  188. </variablelist>
  189. </sect2>
  190. </sect1>