I’m Felipe, from the OpenStack team, we have been asking ourselves the question of how to build reproducible charms with the Ops framework, and we haven’t been able to reach to an answer, and I’m reaching out for feedback
I was reading the charm_builder.py script, where the CharmBuilder._install_dependencies() suggests there is no option to pass a constraints file, or maybe generate (and use) a lock file from the installed dependencies.
I guess this kind of depends what you mean. The ops package itself only has two dependencies (PyYAML and python-websockets).
You could easily use pip freeze or similar to generate a requirements.txt with exact pinned versions, and the source code for libraries should be checked into your repo already.
What else do you need to pin within the charm itself other than the Python deps?
pip freeze would need to be run within the virtualenv created by charmcraft (within the lxd container), which it’s doable, but it certainly requires many steps to get it, here it’s an example:
I’m not sure I totally agree – the other way of looking at this is that you control the virtualenv being created in the LXD container by supplying a requirements.txt file with all of the dependency tree pinned.
The only difference that could occur is where the patch version of the Python runtime increments in the base that charmcraft uses, but that shouldn’t affect the virtual environment.
If you run charmcraft pack --verbose you’ll see the name of the container being used in the log output. You can also do lxc list --project charmcraft to see the various containers that have been created by charmcraft.