Skip to content

_TF_REQ is not compatible with tensorflow-cpu requirements using pip #1847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tensorflow_serving/tools/pip_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
sys.argv.remove('--project_name')
sys.argv.pop(project_name_idx)

_TF_REQ = ['tensorflow'+_TF_VERSION_SANITIZED]
_TF_REQ = ["tensorflow"_TF_VERSION_SANITIZED]

# CPU only build
if 'tensorflow-serving-api-cpu' in project_name:
_TF_REQ = ['tensorflow-cpu'+_TF_VERSION_SANITIZED]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break for people who have tensorflow package installed:

https://pypi.org/project/tensorflow/

is there a way to specify a list of packages, where any one of them can be installed to satisfy the requirement?

Copy link
Author

@kimdwkimdw kimdwkimdw Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netfs

How about this?

f183188

import pkg_resources

pkg_released = set(["tensorflow", "tensorflow-cpu"])
pkg_installed = set(map(lambda pkg: pkg.project_name, pkg_resources.working_set))
tensorflow_installed = list(pkg_released & pkg_installed) + ["tensorflow"]

_TF_REQ = [tensorflow_installed[0]+_TF_VERSION_SANITIZED]

# GPU build (note: the only difference is we depend on tensorflow-gpu so
# pip doesn't overwrite it with the CPU build)
Expand Down