开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

source-code-analysis/python3.8.1

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
python3.8.1
/
Doc
/
distutils
/
configfile.rst
python3.8.1
/
Doc
/
distutils
/
configfile.rst
configfile.rst 5.92 KB
一键复制 编辑 原始数据 按行查看 历史
zhangweibo 提交于 2021年11月16日 09:46 +08:00 . git init

Writing the Setup Configuration File

Often, it's not possible to write down everything needed to build a distribution a priori: you may need to get some information from the user, or from the user's system, in order to proceed. As long as that information is fairly simple---a list of directories to search for C header files or libraries, for example---then providing a configuration file, :file:`setup.cfg`, for users to edit is a cheap and easy way to solicit it. Configuration files also let you provide default values for any command option, which the installer can then override either on the command-line or by editing the config file.

The setup configuration file is a useful middle-ground between the setup script---which, ideally, would be opaque to installers [1]---and the command-line to the setup script, which is outside of your control and entirely up to the installer. In fact, :file:`setup.cfg` (and any other Distutils configuration files present on the target system) are processed after the contents of the setup script, but before the command-line. This has several useful consequences:

The basic syntax of the configuration file is simple:

[command]
option=value
...

where command is one of the Distutils commands (e.g. :command:`build_py`, :command:`install`), and option is one of the options that command supports. Any number of options can be supplied for each command, and any number of command sections can be included in the file. Blank lines are ignored, as are comments, which run from a '#' character until the end of the line. Long option values can be split across multiple lines simply by indenting the continuation lines.

You can find out the list of options supported by a particular command with the universal :option:`!--help` option, e.g.

$ python setup.py --help build_ext
[...]
Options for 'build_ext' command:
 --build-lib (-b) directory for compiled extension modules
 --build-temp (-t) directory for temporary files (build by-products)
 --inplace (-i) ignore build-lib and put compiled extensions into the
 source directory alongside your pure Python modules
 --include-dirs (-I) list of directories to search for header files
 --define (-D) C preprocessor macros to define
 --undef (-U) C preprocessor macros to undefine
 --swig-opts list of SWIG command line options
[...]

Note that an option spelled :option:`!--foo-bar` on the command-line is spelled foo_bar in configuration files.

For example, say you want your extensions to be built "in-place"---that is, you have an extension :mod:`pkg.ext`, and you want the compiled extension file (:file:`ext.so` on Unix, say) to be put in the same source directory as your pure Python modules :mod:`pkg.mod1` and :mod:`pkg.mod2`. You can always use the :option:`!--inplace` option on the command-line to ensure this:

python setup.py build_ext --inplace

But this requires that you always specify the :command:`build_ext` command explicitly, and remember to provide :option:`!--inplace`. An easier way is to "set and forget" this option, by encoding it in :file:`setup.cfg`, the configuration file for this distribution:

[build_ext]
inplace=1

This will affect all builds of this module distribution, whether or not you explicitly specify :command:`build_ext`. If you include :file:`setup.cfg` in your source distribution, it will also affect end-user builds---which is probably a bad idea for this option, since always building extensions in-place would break installation of the module distribution. In certain peculiar cases, though, modules are built right in their installation directory, so this is conceivably a useful ability. (Distributing extensions that expect to be built in their installation directory is almost always a bad idea, though.)

Another example: certain commands take a lot of options that don't change from run to run; for example, :command:`bdist_rpm` needs to know everything required to generate a "spec" file for creating an RPM distribution. Some of this information comes from the setup script, and some is automatically generated by the Distutils (such as the list of files installed). But some of it has to be supplied as options to :command:`bdist_rpm`, which would be very tedious to do on the command-line for every run. Hence, here is a snippet from the Distutils' own :file:`setup.cfg`:

[bdist_rpm]
release = 1
packager = Greg Ward <gward@python.net>
doc_files = CHANGES.txt
 README.txt
 USAGE.txt
 doc/
 examples/

Note that the doc_files option is simply a whitespace-separated string split across multiple lines for readability.

.. seealso::

 :ref:`inst-config-syntax` in "Installing Python Modules"
 More information on the configuration files is available in the manual for
 system administrators.


Footnotes

[1] This ideal probably won't be achieved until auto-configuration is fully supported by the Distutils.
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/python_sourcecode/python3.8.1.git
git@gitee.com:python_sourcecode/python3.8.1.git
python_sourcecode
python3.8.1
python3.8.1
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /