hey guys :wave: wonder who is using pulumi with py...
# general
hey guys 👋 wonder who is using pulumi with python projects, how do you import packages from the main project for example if you need to use information from models/dataclasses
👍 1
yes, in this example
locates in the same folder as
in my case I’m trying to import package from level above typically you can do relative import like
from ..models import ModelItem
, but with pulumi it doesn’t work
the idea to share models between pulumi and application code
If it helps; the only workaround I found was to use the
Copy code
from path.to.whatever import *
I found through trial and error that this only works if you use
for the main Pulumi module, if you override it in config then it doesn’t work. It also only works with the
from x import y
form of import
I recall seeing a GH issue and a link to a sample repo as well, I don’t have the link to hand (oh, the example workaround is linked to the above GH issue, if you click through enough links! https://github.com/followben/pulumi-example/blob/master/src/infra/project2/__main__.py#L12)
I suggest upvoting https://github.com/pulumi/pulumi/issues/7360 as this is something that could really use improvement
thank you