1. <i id='aSIlp'><tr id='aSIlp'><dt id='aSIlp'><q id='aSIlp'><span id='aSIlp'><b id='aSIlp'><form id='aSIlp'><ins id='aSIlp'></ins><ul id='aSIlp'></ul><sub id='aSIlp'></sub></form><legend id='aSIlp'></legend><bdo id='aSIlp'><pre id='aSIlp'><center id='aSIlp'></center></pre></bdo></b><th id='aSIlp'></th></span></q></dt></tr></i><div id='aSIlp'><tfoot id='aSIlp'></tfoot><dl id='aSIlp'><fieldset id='aSIlp'></fieldset></dl></div>

        <bdo id='aSIlp'></bdo><ul id='aSIlp'></ul>
    2. <legend id='aSIlp'><style id='aSIlp'><dir id='aSIlp'><q id='aSIlp'></q></dir></style></legend>

      <small id='aSIlp'></small><noframes id='aSIlp'>

      <tfoot id='aSIlp'></tfoot>

      如何使用 setuptools 和 setup.py 从包中排除单个文件

      时间:2023-09-13

      • <legend id='8MuiF'><style id='8MuiF'><dir id='8MuiF'><q id='8MuiF'></q></dir></style></legend>

          <i id='8MuiF'><tr id='8MuiF'><dt id='8MuiF'><q id='8MuiF'><span id='8MuiF'><b id='8MuiF'><form id='8MuiF'><ins id='8MuiF'></ins><ul id='8MuiF'></ul><sub id='8MuiF'></sub></form><legend id='8MuiF'></legend><bdo id='8MuiF'><pre id='8MuiF'><center id='8MuiF'></center></pre></bdo></b><th id='8MuiF'></th></span></q></dt></tr></i><div id='8MuiF'><tfoot id='8MuiF'></tfoot><dl id='8MuiF'><fieldset id='8MuiF'></fieldset></dl></div>
              <bdo id='8MuiF'></bdo><ul id='8MuiF'></ul>

              <small id='8MuiF'></small><noframes id='8MuiF'>

                <tfoot id='8MuiF'></tfoot>
                  <tbody id='8MuiF'></tbody>
                本文介绍了如何使用 setuptools 和 setup.py 从包中排除单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在研究 blowdrycss.存储库在这里.

                I am working on blowdrycss. The repository is here.

                我希望将 blowdrycss_settings.py 的设置文件从 pypi 的最终包中排除.目的是动态构建一个自定义设置文件,该文件将放置在用户 virtualenv/项目文件夹中.

                I want the settings file for blowdrycss_settings.py to be excluded from the final package on pypi. The intention is to dynamically build a custom settings file that will be placed in the users virtualenv / project folder.

                setup.py 中,我有以下内容:

                In setup.py, I have the following:

                packages=find_packages(exclude=['blowdrycss_settings.py', ]),
                

                我也试过 exclude_package_data:

                exclude_package_data={
                    '': ['blowdrycss_settings.py'],
                    '': ['blowdrycss/blowdrycss_settings.py'],
                    'blowdrycss': ['blowdrycss_settings.py'],
                },
                

                然后我运行 python setup.py sdist bdist.

                但是,当我查看构建文件夹时,我仍然看到 blowdrycss_settings.py:

                However, when I look in the build folder I still see blowdrycss_settings.py:

                - build 
                    - lib
                        - blowdrycss_settings.py
                

                似乎只排除一个文件应该很简单.

                It seems like it should be simple to just exclude a file.

                如何从分布式包中排除blowdrycss_settings.py?

                How do I exclude blowdrycss_settings.py from the distributed package?

                推荐答案

                这是我的解决方案.

                blowdrycss 下,我创建了一个名为 settings 的新模块,因此目录结构现在如下所示:

                Underneath of blowdrycss, I created a new module called settings so the directory structure now looks like this:

                blowdrycss
                    blowdrycss
                        settings
                            blowdrycss_settings.py
                

                基于此参考,在setup.py 我有以下内容:

                Based on this reference, inside of setup.py I have the following:

                packages=find_packages(exclude=['*.settings', ]),   
                

                构建发行版:

                1. 删除 builddist.egg-info 文件夹.
                2. 运行python setup.py sdist bdist
                1. Delete the build, dist, and .egg-info folders.
                2. Run python setup.py sdist bdist

                回想起来,我无法做我最初尝试的事情是件好事.新结构感觉更干净,更模块化.

                In retrospect, it is good that I was unable to do what I was originally attempting. The new structure feels cleaner and is more modular.

                这篇关于如何使用 setuptools 和 setup.py 从包中排除单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:“需要 Python 版本 2.7,但在注册表中找不到&quo 下一篇:如何检查模块/库/包是否是 python 标准库的一部分

                相关文章

                最新文章

                  <bdo id='Q0Iz5'></bdo><ul id='Q0Iz5'></ul>

                <legend id='Q0Iz5'><style id='Q0Iz5'><dir id='Q0Iz5'><q id='Q0Iz5'></q></dir></style></legend>

                <small id='Q0Iz5'></small><noframes id='Q0Iz5'>

              • <tfoot id='Q0Iz5'></tfoot>
                <i id='Q0Iz5'><tr id='Q0Iz5'><dt id='Q0Iz5'><q id='Q0Iz5'><span id='Q0Iz5'><b id='Q0Iz5'><form id='Q0Iz5'><ins id='Q0Iz5'></ins><ul id='Q0Iz5'></ul><sub id='Q0Iz5'></sub></form><legend id='Q0Iz5'></legend><bdo id='Q0Iz5'><pre id='Q0Iz5'><center id='Q0Iz5'></center></pre></bdo></b><th id='Q0Iz5'></th></span></q></dt></tr></i><div id='Q0Iz5'><tfoot id='Q0Iz5'></tfoot><dl id='Q0Iz5'><fieldset id='Q0Iz5'></fieldset></dl></div>