Last active
September 8, 2022 15:17
-
-
Save michaelaye/6670f8604c7ada429e56210b15bdc4b7 to your computer and use it in GitHub Desktop.
Create environment.yml from nbdev settings.ini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from configparser import ConfigParser | |
import subprocess | |
config = ConfigParser(delimiters=["="]) | |
config.read("settings.ini") | |
cfg = config["DEFAULT"] | |
requirements = cfg.get("requirements", "").split() | |
with open("environment.yml", "w") as f: | |
f.write("name: testenv\n") | |
f.write("channels:\n - conda-forge\n") | |
f.write("dependencies:\n") | |
f.writelines([f" - {r}\n" for r in requirements]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment