def _return_interrogation_script_json(package, filename=None):
    """Return script to interrogate deps for package inside env.
    Uses json.dump instead of pickle due to cryptic pickle/requests bug."""
    head = (
        '\nimport pip\nimport json\npkgs  = pip.get_installed_distributions()\n'
        )
    mid = "package = '{0}'".format(package.lower())
    if not filename:
        out = (
            'fn = "{0}_{1}_req.dat".format(p.key, p.version.replace(".","_"))')
    else:
        out = 'fn = "{0}"'.format(filename)
    conv = """
p = [x for x in pkgs if x.key == package][0]

req_dic = {'project_name': p.project_name,
               'version': p.version, 'requires': {}}

for r in p.requires():
    req_dic['requires'][r.key] = {}
    req_dic['requires'][r.key]['project_name'] = r.project_name
    req_dic['requires'][r.key]['key'] = r.key
    req_dic['requires'][r.key]['specs'] = r.specs

"""
    end = "json.dump(req_dic, open(fn, 'wb'))"
    nl = '\n'
    return head + nl + mid + nl + conv + nl + out + nl + end + nl
