463 lines
33 KiB
HTML
463 lines
33 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>sysconfig —— 提供对 Python 配置信息的访问支持 — Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<script src="../_static/translations.js"></script>
|
||
|
||
<script src="../_static/sidebar.js"></script>
|
||
|
||
<link rel="search" type="application/opensearchdescription+xml"
|
||
title="在 Python 3.8.20 文档 中搜索"
|
||
href="../_static/opensearch.xml"/>
|
||
<link rel="author" title="关于这些文档" href="../about.html" />
|
||
<link rel="index" title="索引" href="../genindex.html" />
|
||
<link rel="search" title="搜索" href="../search.html" />
|
||
<link rel="copyright" title="版权所有" href="../copyright.html" />
|
||
<link rel="next" title="builtins --- 内建对象" href="builtins.html" />
|
||
<link rel="prev" title="sys --- 系统相关的形参和函数" href="sys.html" />
|
||
<link rel="canonical" href="https://docs.python.org/3/library/sysconfig.html" />
|
||
|
||
|
||
|
||
|
||
|
||
<style>
|
||
@media only screen {
|
||
table.full-width-table {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
|
||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||
|
||
</head>
|
||
<body>
|
||
<div class="mobile-nav">
|
||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
|
||
<label for="menuToggler" class="toggler__label">
|
||
<span></span>
|
||
</label>
|
||
<nav class="nav-content" role="navigation">
|
||
<a href="https://www.python.org/" class="nav-logo">
|
||
<img src="../_static/py.svg" alt="Logo"/>
|
||
</a>
|
||
<div class="version_switcher_placeholder"></div>
|
||
<form role="search" class="search" action="../search.html" method="get">
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||
<path fill-rule="nonzero"
|
||
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
|
||
</svg>
|
||
<input type="text" name="q" aria-label="快速搜索"/>
|
||
<input type="submit" value="转向"/>
|
||
</form>
|
||
</nav>
|
||
<div class="menu-wrapper">
|
||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> —— 提供对 Python 配置信息的访问支持</a><ul>
|
||
<li><a class="reference internal" href="#configuration-variables">配置变量</a></li>
|
||
<li><a class="reference internal" href="#installation-paths">安装路径</a></li>
|
||
<li><a class="reference internal" href="#other-functions">其他功能</a></li>
|
||
<li><a class="reference internal" href="#using-sysconfig-as-a-script">将 <code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> 作为脚本使用</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="sys.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> --- 系统相关的形参和函数</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="builtins.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code> --- 内建对象</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/sysconfig.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
|
||
这个文档所针对的是一个已不再受支持的 Python 旧版本。
|
||
你应当升级版本,并阅读
|
||
<a href="/3/library/sysconfig.html"> Python 当前稳定版本的文档</a>.
|
||
</div>
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
accesskey="I">索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="builtins.html" title="builtins --- 内建对象"
|
||
accesskey="N">下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="sys.html" title="sys --- 系统相关的形参和函数"
|
||
accesskey="P">上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="python.html" accesskey="U">Python 运行时服务</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-sysconfig">
|
||
<span id="sysconfig-provide-access-to-python-s-configuration-information"></span><h1><a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> —— 提供对 Python 配置信息的访问支持<a class="headerlink" href="#module-sysconfig" title="永久链接至标题">¶</a></h1>
|
||
<div class="versionadded">
|
||
<p><span class="versionmodified added">3.2 新版功能.</span></p>
|
||
</div>
|
||
<p><strong>源代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.8/Lib/sysconfig.py">Lib/sysconfig.py</a></p>
|
||
<hr class="docutils" id="index-0" />
|
||
<p><a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 模块提供了对 Python 配置信息的访问支持,比如安装路径列表和有关当前平台的配置变量。</p>
|
||
<section id="configuration-variables">
|
||
<h2>配置变量<a class="headerlink" href="#configuration-variables" title="永久链接至标题">¶</a></h2>
|
||
<p>Python 的发行版中包含一个 <code class="file docutils literal notranslate"><span class="pre">Makefile</span></code> 和一个 <code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code> 头文件,这是构建 Python 二进制文件本身和用 <a class="reference internal" href="distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 编译的第三方 C 语言扩展所必需的。</p>
|
||
<p><a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 将这些文件中的所有变量放在一个字典对象中,可用 <a class="reference internal" href="#sysconfig.get_config_vars" title="sysconfig.get_config_vars"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_config_vars()</span></code></a> 或 <a class="reference internal" href="#sysconfig.get_config_var" title="sysconfig.get_config_var"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_config_var()</span></code></a> 访问。</p>
|
||
<p>请注意在 Windows 上,这是一个小得多的集合。</p>
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_config_vars">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_config_vars</code><span class="sig-paren">(</span><em class="sig-param">*args</em><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_config_vars" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>不带参数时,返回一个与当前平台相关的所有配置变量的字典。</p>
|
||
<p>带参数时,返回一个由在配置变量字典中查找每个参数的结果的值组成的列表。</p>
|
||
<p>对于每个参数,如果未找到值,则返回 <code class="docutils literal notranslate"><span class="pre">None</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_config_var">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_config_var</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_config_var" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回单个变量 <em>name</em> 的值。 等价于 <code class="docutils literal notranslate"><span class="pre">get_config_vars().get(name)</span></code>。</p>
|
||
<p>如果未找到 <em>name</em>,则返回 <code class="docutils literal notranslate"><span class="pre">None</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<p>用法示例:</p>
|
||
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">sysconfig</span>
|
||
<span class="gp">>>> </span><span class="n">sysconfig</span><span class="o">.</span><span class="n">get_config_var</span><span class="p">(</span><span class="s1">'Py_ENABLE_SHARED'</span><span class="p">)</span>
|
||
<span class="go">0</span>
|
||
<span class="gp">>>> </span><span class="n">sysconfig</span><span class="o">.</span><span class="n">get_config_var</span><span class="p">(</span><span class="s1">'LIBDIR'</span><span class="p">)</span>
|
||
<span class="go">'/usr/local/lib'</span>
|
||
<span class="gp">>>> </span><span class="n">sysconfig</span><span class="o">.</span><span class="n">get_config_vars</span><span class="p">(</span><span class="s1">'AR'</span><span class="p">,</span> <span class="s1">'CXX'</span><span class="p">)</span>
|
||
<span class="go">['ar', 'g++']</span>
|
||
</pre></div>
|
||
</div>
|
||
</section>
|
||
<section id="installation-paths">
|
||
<h2>安装路径<a class="headerlink" href="#installation-paths" title="永久链接至标题">¶</a></h2>
|
||
<p>Python 会使用根据平台和安装选项区别处理的安装方案。 这些方案保存在 <a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 中基于 <a class="reference internal" href="os.html#os.name" title="os.name"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.name</span></code></a> 的返回值来确定的唯一标识符下。</p>
|
||
<p>每个使用 <a class="reference internal" href="distutils.html#module-distutils" title="distutils: Support for building and installing Python modules into an existing Python installation."><code class="xref py py-mod docutils literal notranslate"><span class="pre">distutils</span></code></a> 或基于 Distutils 的系统安装的新组件都将遵循同样的方案将其文件拷贝到正确的位置。</p>
|
||
<p>Python currently supports seven schemes:</p>
|
||
<ul class="simple">
|
||
<li><p><em>posix_prefix</em>: scheme for POSIX platforms like Linux or Mac OS X. This is
|
||
the default scheme used when Python or a component is installed.</p></li>
|
||
<li><p><em>posix_home</em>: 当在安装时使用了 <em>home</em> 选项时针对 POSIX 平台所使用的方案。 此方案会在通过 Distutils 附带指定的前缀安装组件时被使用。</p></li>
|
||
<li><p><em>posix_user</em>: 当通过 Distutils 安装组件并且使用了 <em>user</em> 选项时针对 POSIX 平台所使用的方案。 此方案会在用户家目录下定义路径位置。</p></li>
|
||
<li><p><em>nt</em>: 针对 NT 平台如 Windows 的方案。</p></li>
|
||
<li><p><em>nt_user</em>: 针对 NT 平台,当使用了 <em>user</em> 选项时的方案。</p></li>
|
||
</ul>
|
||
<p>每个方案本身由一系列路径组成并且每个路径都有唯一的标识符。 Python 目前使用了八个路径:</p>
|
||
<ul class="simple">
|
||
<li><p><em>stdlib</em>: 包含非平台专属的标准 Python 库文件的目录。</p></li>
|
||
<li><p><em>platstdlib</em>: 包含平台专属的标准 Python 库文件的目录。</p></li>
|
||
<li><p><em>platlib</em>: 用于站点专属、平台专属的文件的目录。</p></li>
|
||
<li><p><em>purelib</em>: 用于站点专属、非平台专属的文件的目录。</p></li>
|
||
<li><p><em>include</em>: 用于非平台专属的头文件的目录。</p></li>
|
||
<li><p><em>platinclude</em>: 用于平台专属的头文件的目录。</p></li>
|
||
<li><p><em>scripts</em>: 用于脚本文件的目录。</p></li>
|
||
<li><p><em>data</em>: 用于数据文件的目录。</p></li>
|
||
</ul>
|
||
<p><a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 提供了一些函数来确定这些路径。</p>
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_scheme_names">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_scheme_names</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_scheme_names" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个包含 <a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 目前支持的所有方案的元组。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_path_names">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_path_names</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_path_names" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个包含在 <a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 中目前支持的所有路径名称的元组。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_path">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_path</code><span class="sig-paren">(</span><em class="sig-param">name</em><span class="optional">[</span>, <em class="sig-param">scheme</em><span class="optional">[</span>, <em class="sig-param">vars</em><span class="optional">[</span>, <em class="sig-param">expand</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_path" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个对应于路径 <em>name</em>,来自名为 <em>scheme</em> 的安装方案的安装路径。</p>
|
||
<p><em>name</em> 必须是一个来自 <a class="reference internal" href="#sysconfig.get_path_names" title="sysconfig.get_path_names"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_path_names()</span></code></a> 所返回的列表的值。</p>
|
||
<p><a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 会针对每个平台保存与每个路径名称相对应的安装路径,并带有可扩展的变量。 例如针对 <em>nt</em> 方案的 <em>stdlib</em> 路径是: <code class="docutils literal notranslate"><span class="pre">{base}/Lib</span></code>。</p>
|
||
<p><a class="reference internal" href="#sysconfig.get_path" title="sysconfig.get_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_path()</span></code></a> 将使用 <a class="reference internal" href="#sysconfig.get_config_vars" title="sysconfig.get_config_vars"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_config_vars()</span></code></a> 所返回的变量来扩展路径。 所有变量对于每种平台都有相应的默认值因此使用者可以调用此函数来获取默认值。</p>
|
||
<p>如果提供了 <em>scheme</em>,则它必须是一个来自 <a class="reference internal" href="#sysconfig.get_scheme_names" title="sysconfig.get_scheme_names"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_scheme_names()</span></code></a> 所返回的列表的值。 在其他情况下,将会使用针对当前平台的默认方案。</p>
|
||
<p>如果提供了 <em>vars</em>,则它必须是一个将要更新 <a class="reference internal" href="#sysconfig.get_config_vars" title="sysconfig.get_config_vars"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_config_vars()</span></code></a> 所返回的字典的字典。</p>
|
||
<p>如果 <em>expand</em> 被设为 <code class="docutils literal notranslate"><span class="pre">False</span></code>,则将不使用这些变量来扩展路径。</p>
|
||
<p>如果未找到 <em>name</em>,则返回 <code class="docutils literal notranslate"><span class="pre">None</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_paths">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_paths</code><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param">scheme</em><span class="optional">[</span>, <em class="sig-param">vars</em><span class="optional">[</span>, <em class="sig-param">expand</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_paths" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个包含与特定安装方案对应的安装路径的字典。 请参阅 <a class="reference internal" href="#sysconfig.get_path" title="sysconfig.get_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_path()</span></code></a> 了解详情。</p>
|
||
<p>如果未提供 <em>scheme</em>,则将使用针对当前平台的默认方案。</p>
|
||
<p>如果提供了 <em>vars</em>,则它必须是一个将要更新用于扩展的字典的变量字典。</p>
|
||
<p>如果 <em>expand</em> 被设为假值,则路径将不会被扩展。</p>
|
||
<p>如果 <em>scheme</em> 不是一个现有的方案,则 <a class="reference internal" href="#sysconfig.get_paths" title="sysconfig.get_paths"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_paths()</span></code></a> 将引发 <a class="reference internal" href="exceptions.html#KeyError" title="KeyError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a>。</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="other-functions">
|
||
<h2>其他功能<a class="headerlink" href="#other-functions" title="永久链接至标题">¶</a></h2>
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_python_version">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_python_version</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_python_version" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>以字符串形式 <code class="docutils literal notranslate"><span class="pre">MAJOR.MINOR</span></code> 返回 Python 版本号。 类似于 <code class="docutils literal notranslate"><span class="pre">'%d.%d'</span> <span class="pre">%</span> <span class="pre">sys.version_info[:2]</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_platform">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_platform</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_platform" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回一个标识当前平台的字符串。</p>
|
||
<p>这主要被用来区分平台专属的构建目录和平台专属的构建分发版。 通常包括 OS 名称和版本以及架构(即 'os.uname()' 所提供的信息),但是实际包括的信息取决于具体 OS;例如,在 Linux 上,内核版本号并不是特别重要。</p>
|
||
<p>返回值的示例:</p>
|
||
<ul class="simple">
|
||
<li><p>linux-i586</p></li>
|
||
<li><p>linux-alpha (?)</p></li>
|
||
<li><p>solaris-2.6-sun4u</p></li>
|
||
</ul>
|
||
<p>Windows将返回以下之一:</p>
|
||
<ul class="simple">
|
||
<li><p>win-amd64 (在 AMD64, aka x86_64, Intel64, 和 EM64T上的64位 Windows )</p></li>
|
||
<li><p>win32(所有其他的 —— 确切地说,返回 sys.platform)</p></li>
|
||
</ul>
|
||
<p>Mac OS X 返回:</p>
|
||
<ul class="simple">
|
||
<li><p>macosx-10.6-ppc</p></li>
|
||
<li><p>macosx-10.4-ppc64</p></li>
|
||
<li><p>macosx-10.3-i386</p></li>
|
||
<li><p>macosx-10.4-fat</p></li>
|
||
</ul>
|
||
<p>对于其他非-POSIX 平台, 目前只是返回 <a class="reference internal" href="sys.html#sys.platform" title="sys.platform"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.platform</span></code></a> 。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.is_python_build">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">is_python_build</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.is_python_build" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>如果正在运行的 Python 解释器是使用源代码构建的并在其构建位置上运行,而不是在其他位置例如通过运行 <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">install</span></code> 或通过二进制机器码安装程序安装则返回 <code class="docutils literal notranslate"><span class="pre">True</span></code>。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.parse_config_h">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">parse_config_h</code><span class="sig-paren">(</span><em class="sig-param">fp</em><span class="optional">[</span>, <em class="sig-param">vars</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.parse_config_h" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>解析一个 <code class="file docutils literal notranslate"><span class="pre">config.h</span></code> 风格的文件。</p>
|
||
<p><em>fp</em> 是一个指向 <code class="file docutils literal notranslate"><span class="pre">config.h</span></code> 风格的文件的文件型对象。</p>
|
||
<p>返回一个包含名称/值对的字典。 如果传入一个可选的字典作为第二个参数,则将使用它而不是新的字典,并使用从文件中读取的值更新它。</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_config_h_filename">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_config_h_filename</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_config_h_filename" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回 <code class="file docutils literal notranslate"><span class="pre">pyconfig.h</span></code> 的目录</p>
|
||
</dd></dl>
|
||
|
||
<dl class="function">
|
||
<dt id="sysconfig.get_makefile_filename">
|
||
<code class="sig-prename descclassname">sysconfig.</code><code class="sig-name descname">get_makefile_filename</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#sysconfig.get_makefile_filename" title="永久链接至目标">¶</a></dt>
|
||
<dd><p>返回 <code class="file docutils literal notranslate"><span class="pre">Makefile</span></code> 的目录</p>
|
||
</dd></dl>
|
||
|
||
</section>
|
||
<section id="using-sysconfig-as-a-script">
|
||
<h2>将 <a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> 作为脚本使用<a class="headerlink" href="#using-sysconfig-as-a-script" title="永久链接至标题">¶</a></h2>
|
||
<p>You can use <a class="reference internal" href="#module-sysconfig" title="sysconfig: Python's configuration information"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code></a> as a script with Python's <em>-m</em> option:</p>
|
||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>python<span class="w"> </span>-m<span class="w"> </span>sysconfig
|
||
<span class="go">Platform: "macosx-10.4-i386"</span>
|
||
<span class="go">Python version: "3.2"</span>
|
||
<span class="go">Current installation scheme: "posix_prefix"</span>
|
||
|
||
<span class="go">Paths:</span>
|
||
<span class="go"> data = "/usr/local"</span>
|
||
<span class="go"> include = "/Users/tarek/Dev/svn.python.org/py3k/Include"</span>
|
||
<span class="go"> platinclude = "."</span>
|
||
<span class="go"> platlib = "/usr/local/lib/python3.2/site-packages"</span>
|
||
<span class="go"> platstdlib = "/usr/local/lib/python3.2"</span>
|
||
<span class="go"> purelib = "/usr/local/lib/python3.2/site-packages"</span>
|
||
<span class="go"> scripts = "/usr/local/bin"</span>
|
||
<span class="go"> stdlib = "/usr/local/lib/python3.2"</span>
|
||
|
||
<span class="go">Variables:</span>
|
||
<span class="go"> AC_APPLE_UNIVERSAL_BUILD = "0"</span>
|
||
<span class="go"> AIX_GENUINE_CPLUSPLUS = "0"</span>
|
||
<span class="go"> AR = "ar"</span>
|
||
<span class="go"> ARFLAGS = "rc"</span>
|
||
<span class="go"> ...</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>此调用将把 <a class="reference internal" href="#sysconfig.get_platform" title="sysconfig.get_platform"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_platform()</span></code></a>, <a class="reference internal" href="#sysconfig.get_python_version" title="sysconfig.get_python_version"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_python_version()</span></code></a>, <a class="reference internal" href="#sysconfig.get_path" title="sysconfig.get_path"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_path()</span></code></a> 和 <a class="reference internal" href="#sysconfig.get_config_vars" title="sysconfig.get_config_vars"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_config_vars()</span></code></a> 所返回的信息打印至标准输出。</p>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<h3><a href="../contents.html">目录</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> —— 提供对 Python 配置信息的访问支持</a><ul>
|
||
<li><a class="reference internal" href="#configuration-variables">配置变量</a></li>
|
||
<li><a class="reference internal" href="#installation-paths">安装路径</a></li>
|
||
<li><a class="reference internal" href="#other-functions">其他功能</a></li>
|
||
<li><a class="reference internal" href="#using-sysconfig-as-a-script">将 <code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> 作为脚本使用</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<h4>上一个主题</h4>
|
||
<p class="topless"><a href="sys.html"
|
||
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> --- 系统相关的形参和函数</a></p>
|
||
<h4>下一个主题</h4>
|
||
<p class="topless"><a href="builtins.html"
|
||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code> --- 内建对象</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<h3>本页</h3>
|
||
<ul class="this-page-menu">
|
||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||
<li>
|
||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/sysconfig.rst"
|
||
rel="nofollow">显示源代码
|
||
</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>导航</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="总目录"
|
||
>索引</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python 模块索引"
|
||
>模块</a> |</li>
|
||
<li class="right" >
|
||
<a href="builtins.html" title="builtins --- 内建对象"
|
||
>下一页</a> |</li>
|
||
<li class="right" >
|
||
<a href="sys.html" title="sys --- 系统相关的形参和函数"
|
||
>上一页</a> |</li>
|
||
|
||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||
<li class="switchers">
|
||
<div class="language_switcher_placeholder"></div>
|
||
<div class="version_switcher_placeholder"></div>
|
||
</li>
|
||
<li>
|
||
|
||
</li>
|
||
<li id="cpython-language-and-version">
|
||
<a href="../index.html">3.8.20 Documentation</a> »
|
||
</li>
|
||
|
||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="python.html" >Python 运行时服务</a> »</li>
|
||
<li class="right">
|
||
|
||
|
||
<div class="inline-search" role="search">
|
||
<form class="inline-search" action="../search.html" method="get">
|
||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||
<input type="submit" value="转向" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
<div class="footer">
|
||
© <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
|
||
<br />
|
||
This page is licensed under the Python Software Foundation License Version 2.
|
||
<br />
|
||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||
<br />
|
||
|
||
<br />
|
||
|
||
The Python Software Foundation is a non-profit corporation.
|
||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||
<br />
|
||
<br />
|
||
|
||
最后更新于 12月 09, 2024.
|
||
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
|
||
<br />
|
||
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
|
||
</div>
|
||
|
||
</body>
|
||
</html> |