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

Conversation

kimdwkimdw
Copy link

@kimdwkimdw kimdwkimdw commented Apr 23, 2021

When tensorflow-cpu is already installed, tensorflow-serving-api package cannot detect tensorflow installation.

https://pypi.org/project/tensorflow-serving-api/ should follow tensorflow-cpu

https://pypi.org/project/tensorflow-serving-api-gpu/ is now folloing tensorflow-gpu requirement.

When `tensorflow-cpu` is already installed, `tensorflow-serving-api` package cannot detect tesnroflow installation.


`https://pypi.org/project/tensorflow-serving-api/` should follow `tensorflow-cpu`

`https://pypi.org/project/tensorflow-serving-api-gpu/` is now folloing `tensorflow-gpu` requirement.
@google-cla
Copy link

google-cla bot commented Apr 23, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Apr 23, 2021
@kimdwkimdw
Copy link
Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 23, 2021
@kimdwkimdw kimdwkimdw changed the title _TF_REQ is not compatible tensorflow-cpu requirements using pip _TF_REQ is not compatible with tensorflow-cpu requirements using pip Apr 26, 2021
johnperez416
johnperez416 previously approved these changes Jun 22, 2021
@@ -44,7 +44,7 @@
sys.argv.remove('--project_name')
sys.argv.pop(project_name_idx)

_TF_REQ = ['tensorflow'+_TF_VERSION_SANITIZED]
_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]

@@ -44,7 +45,11 @@
sys.argv.remove('--project_name')
sys.argv.pop(project_name_idx)

_TF_REQ = ['tensorflow'+_TF_VERSION_SANITIZED]
pkg_released = set(["tensorflow", "tensorflow-cpu"])
pkg_installed = set(map(lambda pkg: pkg.project_name, pkg_resources.working_set))
Copy link
Collaborator

Choose a reason for hiding this comment

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

for my understanding, is pkg_resources.working_set from the machine where this package is going to be installed OR is this from the machine where the package is being built? we obviously want the former (list packages installed on the target).

Copy link
Author

@kimdwkimdw kimdwkimdw Jul 22, 2021

Choose a reason for hiding this comment

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

It was my misunderstanding. That is for the latter, not the former one.

I think there is no solution for conditional requirements.

Creating new package is another solution with tensorflow-serving-api-cpu
And then add tensorflow-cpu to _TF_REQ when package name is tensorflow-serving-api-cpu
ex) https://pypi.org/project/tensorflow-serving-api-cpu/

Same as tensorflow package, https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/pip_package/setup.py

@kimdwkimdw kimdwkimdw requested a review from netfs July 22, 2021 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants