Skip to content

Managing dependencies

Chad Weider edited this page Sep 14, 2023 · 3 revisions

We use Poetry as our Python package manager instead of pip. It's pretty good, but nobody is used to it yet. It has very good docs you should use for everyday stuff, but the one thing to know about it is that to use it you need to shell into the docker image.

So, once the docker image is running, do something like this:

docker exec -it --user root cl-django bash

Then you can do things as described below.

Adding a new dependency

Once you're inside the image, you'll then be able to do:

poetry add some-new-package

That will do two things. First, it will add the dependency while you're using the container. That's cool, but will go away if you restart docker or the container. The second thing it does is update pyproject.toml and poetry.lock. With that done, you can make new docker images as described by the README's in the docker folders.

Updating a dependency

If you want to update a dependency, you might try using poetry update some-package, but that will update other things as well. Instead, what you should do is:

poetry add some-package@latest

That'll just update the one you want.

Updating all transitive dependencies

These are the dependencies of our dependencies. To update these, there are two tricks. This one will give you a list of our transitive dependencies:

join -o 1.1 -v 1 <(poetry show -o) <(poetry show --top-level)

And this will install them:

join -o 1.1 -v 1 <(poetry show -o) <(poetry show --top-level) | xargs -r poetry update --