Skip to content

pip import results in python3 incompatible libraries #220

Closed

Description

@sha1n

pip_import is using 'python' hardcoded, which in many cases (urllib2, psutil and several others) results in Python 2 libraries that are not compatible with Python 3.

I replaced "python" with "python3" in the following line and everything works perfectly on my environment.
https://github.com/bazelbuild/rules_python/blob/4b84ad270387a7c439ebdccfd530e2339601ef27/python/pip.bzl#L27

Since this is blocking my team, I created a local copy of pip.bzl and patched it just for now. I'm not sure what is the appropriate way to approach this. If there is a way to get the PY/3 interpreter path from Bazel, a fair solution can be to add a python_version parameter to the import rule.

Seems like an essential feature for Python 3 support and I will be happy to contribute a PR if we can decide on a solution. WDYT?

Activity

  1. aaliddell commented on Aug 6, 2019

    @aaliddell
    Contributor

    There's a few open PRs about this issue, with varying solutions:

    There's also rules_pip, which offers a python_interpreter attribute to solve this on its pip_repository rule. This is the solution I have had to use until there's support in rules_python, although rules_pip actually subjectively has a nicer interface for using the fetched packages.

  2. sha1n commented on Aug 7, 2019

    @sha1n
    ContributorAuthor

    Thanks @aaliddell! I was unaware of rules_pip and will definitely take a look.
    Seems like #42 and #119 are also related to the same core issue, but I haven't seen any progress on either of them for a very long time.

    I'll keep following.

  3. ali5h commented on Sep 21, 2019

    @ali5h
  4. lshamis commented on Oct 29, 2019

    @lshamis

    Python 2 will be officially past EOL come 2020: https://pythonclock.org/
    This is an important issue to resolve before teams can start switching to Python 3.

  5. brandjon commented on Nov 12, 2019

    @brandjon
    Contributor

    This should be resolved imminently. Dedupping this issue to #249.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions