我在extras_require
中有setup.cfg
依赖关系,列为:
[extras_require]
tensorflow = tensorflow
tensorflow_gpu = tensorflow-gpu
这样,如果我的软件包与pip install pkg[tensorflow_gpu]
一起安装,它会安装一个版本的软件包,而pip install pkg[tensorflow]
会安装另一个版本。
这类似于Edward Package包(跟随此git issue)。
但是,当我运行python setup.py test
时,它会在执行单元测试之前安装tensorflow
和tensorflow-gpu
包。一旦我在任何单元测试中使用import tensorflow
,这可能会有问题,并且与硬件有关。
有没有办法在运行extras_require
时有选择地安装某个python setup.py test
包?
或者有没有办法安装没有extras_require
包?因为那时我可以在运行test命令之前安装tensorflow
。
(注意:我知道我可以独立运行pip和pytest,但我正在寻找使用setuptools
的解决方案)
看来这不是setuptools
问题,而是我使用的工具pyscaffold
的潜在问题。我在他们的github上打开了一个question issue。
当我使用以下python setup.py test
运行setup.cfg
时,它工作正常,因为它没有拉入张量流。
[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