# VTK 8.90 and modules.json

**URL:** <https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213>\
**Category:** Development\
**Created:** [February 5, 2019, 12:40am UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213 "2019-02-05T00:40:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [February 5, 2019, 12:40am UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213/1 "2019-02-05T00:40:35Z")

</div>

There is a very nice JSON file generated called `modules.json`, in the top-level build directory of VTK. It gives a lot of information about modules selected and their dependencies etc., here is a little Python script I put together in about 5 minutes to display this information:

```python
#!/usr/bin/env python

import json

def get_program_parameters():
    import argparse
    description = 'Parse the VTK JSON file.'
    epilogue = '''

'''
    parser = argparse.ArgumentParser(description=description, epilog=epilogue,
                                     formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('file_name', help='The path to the VTK JSON file, modules.json.')
    args = parser.parse_args()
    return args.file_name

def disp_dependencies(data):
    # This is just a dictionary e.g
    for k, v in data['modules'].items():
        print(k)
        if v['depends']:
            print(' Dependencies :', ' '.join(v['depends']))
        if v['optional_depends']:
            print(' Optional dependencies:', ' '.join(v['optional_depends']))
        if v['private_depends']:
            print(' Private dependencies :', ' '.join(v['private_depends']))

def main():
    fn = get_program_parameters()
    with open(fn) as data_file:
        json_data = json.load(data_file)
    disp_dependencies(json_data)

if __name__ == ' __main__':
    main()

```

@ben.boeckel thanks for providing `modules.json`, it is really useful.  
@lorensen You may find this script useful.

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [February 5, 2019, 5:03pm UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213/2 "2019-02-05T17:03:30Z")

</div>

This may be very useful, thank you. Can you add here an example output?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [February 5, 2019, 6:05pm UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213/3 "2019-02-05T18:05:34Z")

</div>

I noticed that some fields are empty in the file that shouldn’t be. Needs some debugging…

---

<div class="post-metadata">

**Author:** ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)\
**Post date:** [February 14, 2019, 7:27am UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213/4 "2019-02-14T07:27:47Z")

</div>

Is the JSON parsing OK?  
On thing that I’m thinking about ( **modules.json** looks really useful for this) is using this to determine what modules to link to in a vtk application. Maybe an alternative version of **WhatModulesVTK.py**.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [February 14, 2019, 2:36pm UTC](https://discourse.vtk.org/t/vtk-8-90-and-modules-json/213/5 "2019-02-14T14:36:50Z")

</div>

The JSON file doesn’t contain header information. WhatModulesVTK.py builds this up itself by scanning a source tree. Adding the list of headers in modules to the file could certainly be done though.
