Skip to content
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

Add pip3_import to run pip with python 3. #82

Closed
wants to merge 6 commits into from

Conversation

uri-canva
Copy link

While it's possible to select which interpreter to run python rules with, pip will always be run with python from the system path.

This uses the interpreter names as described in PEP 394 to be able to run pip in both python 2 and python 3 as an interim solution until py_toolchain is finalised, since the values for the current mechanism in Bazel to configure the python interpreter at the invocation level (python_path, python_top) are not forwarded to the skylark context.

See discussion in #62.

siddharthab added a commit to grailbio-external/rules_python that referenced this pull request Apr 11, 2018
This is a stop gap change until bazelbuild#82 is landed.
python/pip.bzl Outdated
}

def _pip_import_impl(repository_ctx):
_shared_pip_import_impl("python2", repository_ctx)
Copy link

@darrengarvey darrengarvey Jul 4, 2018

Choose a reason for hiding this comment

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

The default pip_import() should just use the system python. ie. s/python2/python/. A pip2_import() could be added if needed that used python2, I suppose.

@c4urself
Copy link

This change is incredibly important to have any type of meaningful Python3 support. Let me know if I can help in any way to get this merged in, spent quite a few hours debugging an issue that arose from missing this.

@uri-canva
Copy link
Author

Sorry, completely forgot about this. Rebased and addressed the review.

@mishudark
Copy link

Is this PR still under review process?

@uri-canva
Copy link
Author

No idea, I've been using it since I put it up, I'm happy to rebase it again if necessary.

@davidstanke
Copy link
Contributor

@brandjon FYI

@codebreach
Copy link

We were facing a number of issues with native libraries like in ujson as the system python2 would be invoked and our code uses py3.

The pip3_import from this PR works wonderfully. Please get this merged.

@uri-canva
Copy link
Author

@darrengarvey
Copy link

👍 from me. But I'm just a random person who wants this too and reviewed the PR. :)

@c4urself ?

@lberki lberki assigned brandjon and unassigned lberki Nov 5, 2018
@c4urself
Copy link

c4urself commented Nov 5, 2018

yes, I still consider the best way to solve this until we get rid of this binary building mess (I like the approach in #81)

@michael-quinlan
Copy link

Bump ..
I would also like to see this submitted or some other alternative.

@duggelz
Copy link

duggelz commented Nov 6, 2018

I'm no longer with Google, and I'm taking a (long) break from programming, so it'll have to be someone else, sorry.

@brandjon
Copy link
Member

brandjon commented Nov 6, 2018

FYI anything that you'd send to Douglas you can send to me instead. I know it's been radio silence for a while in this repo, but I'll be taking some time in the next few days to merge some PRs and do some triaging.

@uri-canva
Copy link
Author

@brandjon Any updates here?

@mikest
Copy link

mikest commented Dec 28, 2018

+1 vote for getting this PR approved. have need for py3 support in bazel.

@@ -24,7 +24,8 @@ def _pip_import_impl(repository_ctx):

# To see the output, pass: quiet=False
result = repository_ctx.execute([
"python", repository_ctx.path(repository_ctx.attr._script),
python_interpreter, repository_ctx.path(repository_ctx.attr._script),
Copy link

Choose a reason for hiding this comment

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

How about make python_interpreter as a string attribute instead? I was happily using your branch, until I suddenly want to upgrade to python3.6/python3.7 and don't want to overwrite the system's python3 which is pointing to python3.5. I think this approach is better than adding extra pip36_import() and pip37_import(), etc. One original pip_import with python_interpreter attribute is enough.

Copy link
Author

Choose a reason for hiding this comment

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

That's a good idea. I won't have time to update this in the near future though, but if you send me a PR on top of this I'll merge it into this PR.

Copy link

Choose a reason for hiding this comment

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

Done. Please take a look at #158 . Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Nice! I like it, it's much simpler than this PR!

@uri-canva
Copy link
Author

Superseded by #158.

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.