Skip to content

Instantly share code, notes, and snippets.

@michaelaye
Last active September 8, 2022 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelaye/6670f8604c7ada429e56210b15bdc4b7 to your computer and use it in GitHub Desktop.
Save michaelaye/6670f8604c7ada429e56210b15bdc4b7 to your computer and use it in GitHub Desktop.
Create environment.yml from nbdev settings.ini
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