Python Extension 2.0 - read from JSON config file

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.

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

Thanks for the ideas/feedback

Jan

You will have to include package_data in your setup.py file, as illustrated in the setuptools docs.

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:

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]"]},
      )

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