# Python extension 2.0 - include own sub-modules

**URL:** <https://community.dynatrace.com/t/python-extension-2-0-include-own-sub-modules/52546>\
**Category:** Open Q&A\
**Tags:** extension-sdk, extensions\
**Created:** [July 18, 2025, 11:08am UTC](https://community.dynatrace.com/t/python-extension-2-0-include-own-sub-modules/52546 "2025-07-18T11:08:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [July 18, 2025, 11:08am UTC](https://community.dynatrace.com/t/python-extension-2-0-include-own-sub-modules/52546/1 "2025-07-18T11:08:25Z")

</div>

Hello extension devs,

I have a strange behavior when building a python 2.0 extension. I structure my code/modules like this:

```markup
extension
  extension.yaml
  actiavtionSchema.json
my_extension
- mymodule1
    - submodule
        sub.py
- mymodule2
    module.py
  __main__.py
setup.py

```

When I run the extension locally with the simulator everything works great. But when I build the extension only some/not all module subdirectories are included in the build and such I’m getting missing module errors.  
Including the module directories in setup.py doesn’t make sense as they would be treated as PyPi packeages, shouldn’t the build include those without anything else?

---

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [July 19, 2025, 6:31pm UTC](https://community.dynatrace.com/t/python-extension-2-0-include-own-sub-modules/52546/2 "2025-07-19T18:31:32Z")

</div>

Answering to my own dumbness:  
Of course you need to include a \_\_init\_\_.py (can be empty) in every sub directory as well so that the setuptools used when building the extension will include those directories!

---

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [July 21, 2025, 7:54am UTC](https://community.dynatrace.com/t/python-extension-2-0-include-own-sub-modules/52546/3 "2025-07-21T07:54:25Z")

</div>

Also if you want to include non \*.py files in your extension, you might want to add this in the setup.py code:  
e.g. to also package some json template files with the extension:

```markup
setup(
    ...
    extras_require={"dev": ["dt-extensions-sdk[cli]"]},
    package_data={
        "my_ext_module_name": ["templates/*.json"],
    },
)

```
