https://pulumi.com logo
Title
g

great-sunset-355

06/23/2021, 9:13 PM
Hi does anyone have an example of moderately complex project with packages and functions?
e

enough-leather-70274

06/23/2021, 11:14 PM
That's... really interesting. Now I know what you were referring to yesterday @billowy-army-68599. So you don't have any problems importing things from
src/ol-infrastructure/components/
and
src/ol-infrastructure/lib/
?
If you've the time, could you take a look and tell me what I'm doing wrong here then: https://github.com/followben/pulumi-example
AFAIK my setup is identical, yet I get errors when running pulumi if the project imports modules or packages from outside the project directory.
b

billowy-army-68599

06/24/2021, 7:21 AM
this isn't my setup, it's just a setup I'm familiar with from the community
b

brave-knife-93369

06/24/2021, 12:49 PM
I suspect the import works because the entire project is a module. So they
poetry install
the entire repo insto a virtualenv, then run
pulumi -C src/.../ up
from within the virtualenv, which means components are imported properly (via the installed package). That might actually be the solution to our woes as well.
e

enough-leather-70274

06/24/2021, 10:22 PM
Got it. Thanks @brave-knife-93369. We don't use poetry, but guess we could achieve the same with setup.py and pip, but I'd really rather avoid all of that given we don't actually need to package it.
g

great-sunset-355

06/25/2021, 4:04 AM
@enough-leather-70274 I wonder if modifying the site and using
.pth
file would help https://pymotw.com/3/site/index.html
But installing the "app" into the VENV is a common solution as well
e

enough-leather-70274

06/25/2021, 4:15 AM
Oh nice... at the moment we're just doing
sys.path.append(repo_dir)
before we import
I guess we could modify the site in our pulumi automation script, but the imports would still fail when using the CLI locally.
And I think the explicit append in the file is a more obvious workaround than either installing the app to venv or adding a sitecustomize.py + .pth file.
b

brave-knife-93369

06/25/2021, 6:22 AM
I think we'll throw a simple setup.py together and just
python setup.py install
it in our pipelines - should be pretty low effort yet "clean"