Adding Python packages to a Docker image

115 views
Skip to first unread message

Charlie White

unread,
Mar 29, 2018, 11:50:49 AM3/29/18
to Bazel/Python Special Interest Group
Apologies for this is a somewhat duplicate post.  I thought that a better subject may get it the visibility that the other didn't.

With that being said, I have an existing Docker image that I want to simply add some Python packages to.  I have gone down
the path of using the Python rules and the pip_import described in it.  That exposes the packages I need to the BUILD, but it
does not put the packages into the image.  
When I did this with Docker and Dockerfile, I simply ran pip install command.  I understand that this is not something supported by
Bazel, and the reasons for not doing it.  There has to be a way to do this that I am simply not finding.

Thanks,

Charlie

Evan Jones

unread,
Mar 30, 2018, 10:30:45 AM3/30/18
to Charlie White, Bazel/Python Special Interest Group
If you are using the pip_import rules, be warned that they are somewhat incomplete and have some parts that don't work correctly. That said, the following is supposed to work:

* Use pip_import to make the pip packages available to bazel
* Write a py_binary target that depends on those pip packages.
* Use rules_docker to package this py_binary into a Docker image: https://github.com/bazelbuild/rules_docker

There are bugs in all these tools, so this may need a bit of hacking to get it to work, but this is supposed to work. Hope that helps,

Evan



--
You received this message because you are subscribed to the Google Groups "Bazel/Python Special Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-sig-python+unsubscribe@googlegroups.com.
To post to this group, send email to bazel-sig-python@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-sig-python/1110c3ae-3c38-487c-a574-9ad02f417230%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages