soniaai / rules_poetry

Bazel rules that use Poetry for Python package management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does rules_poetry understand target platforms / cross-compilation?

njlr opened this issue · comments

commented

I was wondering how rules_poetry might handle this scenario:

  1. Host machine is macOS
  2. A py_binary called //:app with dependencies from rules_poetry
  3. And a Docker image called //:app_image constructed using container_image (from rules_docker) that is based on Linux AMD64 that contains the py_binary

Now, when doing bazel run //:app, Poetry should install for the host machine (in this case macOS)

But when doing bazel build //:app_image , Poetry should install for Linux AMD64, since this is the base of the Docker image

Is there a way to configure rules_poetry for this?

Perhaps with two calls in the WORKSPACE?

poetry(
  name = "poetry_host",
  lockfile = "//:poetry.lock",
  pyproject = "//:pyproject.toml",
)

poetry(
  name = "poetry_linux_amd64",
  lockfile = "//:poetry.lock",
  pyproject = "//:pyproject.toml",
  target = [ "linux_x64" ],
)

Is this possible or even required?

I haven't check into this. If there are binary wheels available for the target platform it should be possible to make this work with transitions, though other language rules have been running into issues with rules_docker's transitions support. it would be a great feature though.