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 a pip3_import target for Python 3 compatibility. #85

Closed
wants to merge 3 commits into from

Conversation

jkinkead
Copy link
Contributor

@jkinkead jkinkead commented Apr 6, 2018

Fix / workaround for #33 .

Much thanks to @joshclimacell for doing essentially this.

Copy link

@joshclimacell joshclimacell left a comment

Choose a reason for hiding this comment

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

:)

python/pip.bzl Outdated
@@ -34,6 +34,14 @@ def _pip_import_impl(repository_ctx):
if result.return_code:
fail("pip_import failed: %s (%s)" % (result.stdout, result.stderr))

def _pip2_import_impl(repository_ctx):

Choose a reason for hiding this comment

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

Not sure, but maybe there should be three options? pip_import which uses system python, pip2_import which explicitly uses python2, and pip3_import which explicitly uses python3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can tell, the explicit Python 2 binaries always include a minor version (e.g. python2.7). I think I'll update the commend and name to reflect that it's the system version.

A pip27 or similar could be added if needed...

@@ -13,7 +13,7 @@
# limitations under the License.

Choose a reason for hiding this comment

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

Would probably be nice to add documentation of this functionality to a README.md?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Docs updated.

Copy link

@uri-canva uri-canva left a comment

Choose a reason for hiding this comment

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

You also want to forward the configured binary to whl: https://github.com/bazelbuild/rules_python/pull/82/files#diff-fecf9113b31102d557ae0e414f90d6e0

Otherwise you end up calling pip with python3 and whl with python. This can cause build failures in certain libraries, though other libraries seem to be fine with it (in my case lxml worked but PyYAML failed).

"--name", repository_ctx.attr.name,
"--input", repository_ctx.path(repository_ctx.attr.requirements),
"--output", repository_ctx.path("requirements.bzl"),
"--directory", repository_ctx.path(""),
])
], quiet=False)
Copy link

Choose a reason for hiding this comment

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

I think you want to return it to quiet.

@variantf
Copy link

any timeline for this pr? really need this feature bring in!!!

@apt-itude
Copy link

I could really use this. Any updates?

@joshclimacell
Copy link

Not that I know of... I've been using this alternative Python packaging mechanism lately, which I like a lot: https://github.com/TriggerMail/rules_pyz

@lberki lberki assigned brandjon and unassigned davidstanke and lberki Jun 24, 2018
@marczych
Copy link

+1. I cherry-picked this and it works like a charm!

@akashgangil
Copy link

Can we please get this in?

@uri-canva
Copy link

@brandjon who is looking at PRs now?

@brandjon
Copy link
Member

I should have some time for PR reviews after the cut for Bazel 0.25, which is April 1st. There's a lot of backlog in rules_python I'd like to work down starting then. We've been prioritizing cleanups to the native rules but this issue is certainly highly requested.

@prestonvanloon
Copy link

Any update on this?

This was referenced Nov 7, 2019
@brandjon
Copy link
Member

Update: We're using an approach based on #158, rebased and merged as #252. See #256 for the pip3_import macro.

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.

None yet