简体   繁体   English

如何在不安装“ extras_require”依赖项的情况下运行“ python setup.py test”?

[英]How to run “python setup.py test” without installing “extras_require” dependencies?

I have extras_require dependencies in a setup.cfg listed as: 我有extras_require的依赖setup.cfg所列:

[extras_require]
tensorflow = tensorflow
tensorflow_gpu = tensorflow-gpu

That way if my package is installed with pip install pkg[tensorflow_gpu] , it installs one version of the package, vs pip install pkg[tensorflow] which installs the other. 这样,如果我的软件包是使用pip install pkg[tensorflow_gpu]安装的,它将安装软件包的一个版本,而pip install pkg[tensorflow]则安装另一个版本。

This is similar to how the Edward Package packages (following this git issue ). 这类似于Edward Package的打包方式(此git问题之后 )。

However, when I run python setup.py test , it installs both tensorflow and tensorflow-gpu packages before executing my unit tests. 然而,当我运行python setup.py test ,它同时安装tensorflowtensorflow-gpu执行我的单元测试之前包。 That can be problematic once I import tensorflow in any unit tests, and is hardware-dependent. 一旦在任何单元测试中import tensorflow ,并且与硬件相关,这可能会出现问题。

Is there a way to selectively install a certain extras_require package when running python setup.py test ? 运行python setup.py test时,有没有办法选择性地安装某些extras_require软件包?

Alternately is there a way to install no extras_require packages? 或者,有没有办法不安装extras_require软件包? Because then I can install tensorflow before running the test command. 因为这样我可以在运行测试命令之前安装tensorflow

(Note: I understand I can run pip and pytest independently, but I'm looking for a solution that uses setuptools ) (注意:我了解我可以独立运行pip和pytest,但我正在寻找使用setuptools的解决方案)

It appears this is not a setuptools issue, but rather a potential issue with the tool I am using called pyscaffold . 看来这不是setuptools问题,而是我正在使用的工具pyscaffold的潜在问题。 I opened a question issue on their github. 我在他们的github上打开了一个问题

When I run python setup.py test with the following setup.cfg , it works fine, as in it does not pull in tensorflow. 当我使用以下setup.cfg运行python setup.py test时,它工作正常,因为它不会拉入tensorflow。

[metadata]
name = simple

[options]
package_dir = 
    =src
setup_requires = pytest-runner
install_requires = 
tests_require = pytest

[options.extras_require]
tf = tensorflow

[aliases]
test = pytest

[tool:pytest]
addopts = --verbose
testpaths = tests

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM