Good morning! Pulumi, `Python`, and Mono repo's, ...
# general
b
Good morning! Pulumi,
Python
, and Mono repo's, with
relative imports
from component folders... what a mouthful! It doesn't seem to work. There is some talk on github issues but it doesn't seem like this works.
Copy code
./src
|_./lib/__init__.py
|_./lib/autotag.py
|_./infra/__main__.py
and in infra:
from lib.autotag import register_auto_tags
we get an error with
cd infra;  pulumi up
ModuleNotFoundError: No module named 'lib'
This could be more of a python thing but as mono repos are one recommended repo structure, I thought someone might have insight here?
b
for that to work, wouldn’t lib need to be inside the
infra
folder?
Copy code
./src
|_./infra/__main__.py
|_./infra/lib/__init__.py
|_./infra/lib/autotag.py
It looks to me like that’s not the right import path
b
I'm pretty rusty with python, so you are probably right. However, that would defeat the intent as we are trying to have multiple infra folders. ie:
Copy code
./vpc/
./app1/
./app2/
./components/auto_scaling/...
./components/eventing/...
the first three being pulumi stacks, and they import from components.
I think this works with typescript, so maybe this structure is a python limitation?
b
i think you can just do from
../lib/autotag
in that case
or
Copy code
import sys
sys.path.append("..")
b
the second one works, the first one, I'm not getting the syntax right, quoting it doesn't seem to work.
I can run with the second option. Hopefully that's not too much of an anti pattern in the python world. I appreciate the quick response and help!