python – How to install the dependencies of the submodule using poetry?

I have a project my-project that uses a submodule my-submodule. The submodule has dependencies different from my-project in poetry.lock & pyproject.toml files.

I have installed the dependencies required for my-project using poetry add. These deps are installed and poetry.lock & pyproject.toml files are created in the root folder of my-project.

Now, I would also like to install the dependencies of the submodule. Assuming that the path of the submodule is path/to/submodule/from/root, how can I install the dependencies of the submodule and make those deps reflect in the poetry.lock & pyproject.toml files of the root?

A similar question has been asked here: Manage dependencies of git submodules with poetry, but there isn’t a solution provided there.

Any help is appreciated. Thanks.