python - 我如何说服 setuptools 为来自 setup_require 或 tests_require 的 require 包使用一个临时目录?

标签 python setuptools distutils setup.py

setup.py 里面我有这样的东西:

setup_requires=['nose>=1.0'],
tests_require=[],

问题是,当我运行 ./setup.py test 时,它会下载这些模块并将其解压缩到 setup.py 目录中。

我怎样才能说服它为此使用一个临时目录,我不想用这些污染源代码控制系统,我也不想开始添加很多很多排除模式。

最佳答案

如果问题出在您的项目的源代码树上,您可能应该编写一个脚本来删除在安装测试结束时由 distutils 创建的所有“dist”和“build”目录。 下载的包通常是源代码树中的 *.egg 文件夹。

您没有污染您的发行版。

来自 setuptools 文档:

setup_requires will NOT be automatically installed on the system where the setup script is being run. They are simply downloaded to the setup directory if they’re not locally available already. If you want them to be installed, as well as being available when the setup script is run, you should add them to install_requires and setup_requires.)

tests_require If your project’s tests need one or more additional packages besides those needed to install it, you can use this option to specify them. It should be a string or list of strings specifying what other distributions need to be present for the package’s tests to run. When you run the test command, setuptools will attempt to obtain these (even going so far as to download them using EasyInstall). Note that these required projects will not be installed on the system where the tests are run, but only downloaded to the project’s setup directory if they’re not already installed locally.

http://packages.python.org/distribute/setuptools.html

如果你已经安装了一些包并且你需要删除它, 只需在 python 发行版的子文件夹“site-packages”中找到你的包 并将其删除。最后删除 easy-install.pth 文件中的包引用 它通常位于相同的“站点包”目录中。

关于python - 我如何说服 setuptools 为来自 setup_require 或 tests_require 的 require 包使用一个临时目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703601/

相关文章:

python - 如何使用通用的ListView

python - distutils.core 与带有 C++ 扩展的 setuptools

python - 如何在 Python setuptools 中包含本地化消息?

python - 分发、distutils、setuptools 和 distutils2 之间的区别?

python - 将一个列表中的特定行附加到另一个列表

Python:通过循环最小化函数

Python 列表扩展和变量赋值

python - 如何删除构建产品

python - setup.py 将文件复制到特定位置

python - setup.py 安装中的哈希检查需要