# Python Extension 2.0 - read from JSON config file

**URL:** <https://community.dynatrace.com/t/python-extension-2-0-read-from-json-config-file/46891>\
**Category:** Extensions\
**Tags:** json, python, extensions\
**Created:** [July 30, 2024, 12:42pm UTC](https://community.dynatrace.com/t/python-extension-2-0-read-from-json-config-file/46891 "2024-07-30T12:42:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_VanBelle](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jan_vanbelle/32/34174_2.png) [@Jan\_VanBelle](https://community.dynatrace.com/u/Jan_VanBelle)\
**Post date:** [July 30, 2024, 12:42pm UTC](https://community.dynatrace.com/t/python-extension-2-0-read-from-json-config-file/46891/1 "2024-07-30T12:42:04Z")

</div>

Hello,

Our custom python plugins (EF1) often have JSON files included which contain a huge part of config settings

- urls to check
- folders to check
- team configurations
- …

I just wonder how to import/migrate those files into the EF2 equivalent of the plugins.  
I noticed they are never included in the compiled packages and thus give an error when trying to access them.

 ![Jan_VanBelle_0-1722343305458.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/6/66c4d403659cd0f06cf39fa8484ab1596d1f8897.png)

Now testing with various settings in the ‘setup.py’, but no results so far

Thanks for the ideas/feedback

Jan

---

<div class="post-metadata">

**Author:** ![Tom\_sSeroteRoos](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@Tom\_sSeroteRoos](https://community.dynatrace.com/u/Tom_sSeroteRoos)\
**Post date:** [August 2, 2024, 6:52am UTC](https://community.dynatrace.com/t/python-extension-2-0-read-from-json-config-file/46891/2 "2024-08-02T06:52:32Z")

</div>

You will have to include package\_data in your setup.py file, as illustrated in [the setuptools docs.](https://setuptools.pypa.io/en/latest/userguide/datafiles.html#package-data)

So if your directory structure looks like this:

- extension\_folder/
  - setup.py
  - extension/
    - extension.yaml

  - servicebus\_plugin/
    - \_\_init\_\_.py
    - \_\_main\_\_.py
    - config/
      - my\_file.json
      - another\_file.json

You would want to have something like this in your setup.py file:

```python
setup(name="servicebus_plugin",
      version=find_version(),
      description="Demo plugin for community",
      author="You :)",
      packages=find_packages(),
      package_data={"servicebus_plugin": [
          "config/*.json"
      ]},
      python_requires=">=3.10",
      include_package_data=True,
      install_requires=["dt-extensions-sdk"],
      extras_require={"dev": ["dt-extensions-sdk[cli]"]},
      )

```

---

<div class="post-metadata">

**Author:** ![Jan\_VanBelle](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jan_vanbelle/32/34174_2.png) [@Jan\_VanBelle](https://community.dynatrace.com/u/Jan_VanBelle)\
**Post date:** [August 12, 2024, 8:11am UTC](https://community.dynatrace.com/t/python-extension-2-0-read-from-json-config-file/46891/3 "2024-08-12T08:11:07Z")

</div>

Hello, sorry for the delay  
Indeed, that’s something that seems to work!  
except the wildcard (config/\*.json) was not accepted, so I added all the config files 1 by 1.

Thanks,

Jan
