Итак, вот как я это сделал:
from pkg_resources import DistributionNotFound, get_distribution
from setuptools import setup, find_packages
def get_dist(pkgname):
try:
return get_distribution(pkgname)
except DistributionNotFound:
return None
install_deps = ['numpy', 'tensorflow']
if get_dist('tensorflow') is None and get_dist('tensorflow-gpu') is not None:
install_deps.remove('tensorflow')
setup(..., install_requires=install_deps)