To detail the issue, let's say I have the following couple of pyproject.toml for my package that is to be used in another project (described later on below), one with different name than the root directory name:
[tool.poetry]
name = "my-module-one"
version = "0.0.1"
description = ""
authors = []
packages = [
{ include = "some_module" }
]
[tool.poetry]
name = "my-module-two"
version = "0.0.1"
description = ""
authors = []
packages = [
{ include = "some_module" }
]
The project's directory structure is something like this (all managed using Poetry)
my-project/
|- my-module-one/
| |- pyproject.toml
| |- some_module/
| |- something.py
|- my-module-two/
| |- pyproject.toml
| |- some_module/
| |- something.py
|- app/
|- main.py
|- pyproject.toml
Now normally, we would install and import from either one using Poetry like so:
app$ poetry add ../my-module-one
And import it like so
# File: app/main.py
from some_module import something
This becomes a problem when importing both modules are installed because they export a directory with the same name in this case (and that I'm in no power to change this). So I would like to be able to import like so:
# Import some_module from my-module-one
from some_module_one import something as something_one
# Import some_module from my-module-two
from some_module_two import something as something_two
Is it possible to achieve this? If so, how can we do it?
P.S.: I kind of wanted to somehow alias the export from either one of the modules so my-module-one
's something
becomes something_one
, but can't figure out a way.