python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

Wire the Container while running from a project.scripts entry point

Open santiago-henao-12 opened this issue 4 months ago • 1 comments

Hi, I basically picked up this library today and while trying ot set up a working example I ran into this:

Basically if I try to run a entry point registered in the project.scripts table of the pyproject.toml file the wiring doesn't happen. This obviously happens because the code that wires the module is inside a if name == "main" conditional. I thought that maybe I could just wire the container in the code of the module that holds the function I run as entrypoint but started wondering if this would affect the tests given that I read that for tests the recommended approach is to create a container fixture. So I'm a bit lost on what to do.

santiago-henao-12 avatar Aug 04 '25 03:08 santiago-henao-12