当我运行 python setup.py test
时,setup.py 中 tests_require
中列出的依赖项会下载到当前目录。当我运行 python setup.py install
时,requires
中列出的依赖项被安装到 site-packages
。
我怎样才能将那些 tests_require
依赖项安装在 site-packages
中?
最佳答案
您无法指定测试要求的安装位置。 tests_require 参数的全部意义在于指定安装包不需要但仅用于运行测试的依赖项(正如您可以想象的那样,许多消费者可能想要安装包但不运行测试)。如果您希望在安装过程中包含测试要求,我会将它们包含在 install_requires 参数中。例如:
test_requirements = ['pytest>=2.1', 'dingus']
setup(
# ...
tests_require = test_requirements,
install_requires = [
# ... (your usual install requirements)
] + test_requirements,
)
据我所知,在不更改设置脚本的情况下,您无法传递任何参数来强制执行此行为。
关于python - 指定安装分发/设置工具包的 'tests_require' 依赖项的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4734292/