https://pulumi.com logo
Title
m

many-salesmen-89069

05/26/2021, 10:04 AM
Hi, I’m having trouble setting up a Python project. The docs say that Pulumi supports modularized Python programs and setup.py files, but there isn’t any more info provided there and I can’t get it working with my project structure that looks like this:
my_dir/
  Pulumi.yaml 
  setup.py // calls `setup(packages=find_packages())`
  my_package/
    __init__.py
    __main__.py // does `from .pulumi import *`
    pulumi.py // contains AWS resource created with Pulumi
Now when I run
pulumi up
in
my_dir
, I get the following error:
ImportError: can't find '__main__' module in '.'
Which tells me that Pulumi tries to import
my_dir/__main__.py
and ignores
setup.py
. How can I fix this? Is there any documentation that I’m missing?
b

brave-planet-10645

05/26/2021, 10:11 AM
If the
__main__.py
is not in the root directory, there is a setting you can use in the Pulumi.yaml
let me just look it up
In your case, you'd want it to look something like:
main: my_dir
You'd still run pulumi up in the root folder
but you're now telling it where to start from
m

many-salesmen-89069

05/26/2021, 11:09 AM
thanks @brave-planet-10645 I missed that setting
b

brave-planet-10645

05/26/2021, 11:10 AM
No problem 🙂