Reputation: 2358
At work I received an old shiny application bundle. In there there is both a manifest.json
file. Coming from python, the file looks like it could rebuild the original dependecies. The question is, how do install it in my current setup? I would like to have the equivalent of a poetry install
or pip install -r requirements.txt
Upvotes: 0
Views: 363
Reputation: 2358
Thanks to the comment, I made my own solution that worked well.
First create a requirements.txt
with a python script.
"""
Read a manifest.json and output a requirements.txt file
"""
import json
file = 'manifest.json'
out = 'requirements.txt'
with open(file) as json_file:
data = json.load(json_file)
with open(out, 'w') as f:
for pkg_name in data['packages'].keys():
pkg_version = data['packages'][pkg_name]['description']['Version']
res = f'{pkg_name} {pkg_version} \n'
f.write(res)
Then install all the old dependencies with this bash
script
while IFS=" " read -r package version;
do
Rscript -e "devtools::install_version('"$package"', version='"$version"')";
done < "requirements.txt"
Upvotes: 1