Rules_docker: python/legacy_pip_import is not a package

Created on 5 Nov 2020  路  4Comments  路  Source: bazelbuild/rules_docker

Hi!

I'm trying to update to rules_docker v0.15.0. The pull request opened by Renovate fails with:

ERROR: error loading package '': in /home/runner/.cache/bazel/_bazel_runner/28c87e939b2d262a4865f773e9888c7e/external/io_bazel_rules_docker/repositories/deps.bzl: in /home/runner/.cache/bazel/_bazel_runner/28c87e939b2d262a4865f773e9888c7e/external/io_bazel_rules_docker/repositories/py_repositories.bzl: Label '@rules_python//python/legacy_pip_import:pip.bzl' is invalid because 'python/legacy_pip_import' is not a package; perhaps you meant to put the colon here: '@rules_python//python:legacy_pip_import/pip.bzl'?

Any help would be greatly appreciated.

Thanks

Most helpful comment

This is not a rules_docker issue, but more of a bazel rules ecosystem issue. Basically a bunch of rules use "@rules_python" to refer to python rules, and have "ifndef rules_python ..." code within their codebases, and if rules_python does not exist - they include whatever rules_python version they want.

So for example if you include rules_proto, it checks if rules_python exists, and if not downloads a super old version of rules_python. Which means that when you run initialization of rules_docker, rules_docker just skips downloading python rules completely and uses whatever rules_proto loaded for you.

Solutions for now are either:

  • making sure that whatever needs the latest python rules is loaded first, or
  • populating @rules_python yourself before loading anything that needs python rules and managing the version.

All 4 comments

I can speak to this taking place on a new repository as well and is not reproduced by rolling back to v0.14.4

Updating/adding rules_python to my WORKSPACE solved this problem for me. See: https://github.com/bazelbuild/rules_python/releases/tag/0.1.0

Note that I did not apply the workaround patch they suggested (as it caused problems when I did).

This is not a rules_docker issue, but more of a bazel rules ecosystem issue. Basically a bunch of rules use "@rules_python" to refer to python rules, and have "ifndef rules_python ..." code within their codebases, and if rules_python does not exist - they include whatever rules_python version they want.

So for example if you include rules_proto, it checks if rules_python exists, and if not downloads a super old version of rules_python. Which means that when you run initialization of rules_docker, rules_docker just skips downloading python rules completely and uses whatever rules_proto loaded for you.

Solutions for now are either:

  • making sure that whatever needs the latest python rules is loaded first, or
  • populating @rules_python yourself before loading anything that needs python rules and managing the version.

As both @ajbouh and @Ignas have suggested, I've manually added rules_python v0.1.0 in my WORKSPACE. The rules_python repository rules had to be loaded, and the rules_docker pip_deps rule had to be removed.

See https://github.com/uhthomas/kipp/pull/107/files for a full example of upgrading to rules_docker v0.15.0.

Thanks all

Was this page helpful?
0 / 5 - 0 ratings