From 60bb8e9b21e69e5a8949d56a35cd0ef0e51c8925 Mon Sep 17 00:00:00 2001 From: Jeremy Howard Date: Sun, 2 Jun 2024 14:29:48 +1000 Subject: [PATCH] fixes #1415 --- nbdev/release.py | 6 +++--- nbs/api/18_release.ipynb | 8 ++++---- settings.ini | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/nbdev/release.py b/nbdev/release.py index 5d3132acf..cb3ba2eb0 100644 --- a/nbdev/release.py +++ b/nbdev/release.py @@ -240,11 +240,11 @@ def write_conda_meta(path='conda'): _write_yaml(path, *_get_conda_meta()) # %% ../nbs/api/18_release.ipynb 43 -# This function is used as a utility for creating HF spaces. -def write_requirements(directory=None): +@call_parse +def write_requirements(path:str=''): "Writes a `requirements.txt` file to `directory` based on settings.ini." cfg = get_config() - d = Path(directory) if directory else cfg.config_path + d = Path(path) if path else cfg.config_path req = '\n'.join([cfg.get(k, '').replace(' ', '\n') for k in ['requirements', 'pip_requirements']]) (d/'requirements.txt').mk_write(req) diff --git a/nbs/api/18_release.ipynb b/nbs/api/18_release.ipynb index 22be84a2d..f74264dd2 100644 --- a/nbs/api/18_release.ipynb +++ b/nbs/api/18_release.ipynb @@ -608,12 +608,12 @@ "metadata": {}, "outputs": [], "source": [ - "#|export\n", - "# This function is used as a utility for creating HF spaces.\n", - "def write_requirements(directory=None):\n", + "#| export\n", + "@call_parse\n", + "def write_requirements(path:str=''):\n", " \"Writes a `requirements.txt` file to `directory` based on settings.ini.\"\n", " cfg = get_config()\n", - " d = Path(directory) if directory else cfg.config_path\n", + " d = Path(path) if path else cfg.config_path\n", " req = '\\n'.join([cfg.get(k, '').replace(' ', '\\n') for k in ['requirements', 'pip_requirements']])\n", " (d/'requirements.txt').mk_write(req)" ] diff --git a/settings.ini b/settings.ini index 1f504693f..4573e8f2d 100644 --- a/settings.ini +++ b/settings.ini @@ -47,6 +47,7 @@ console_scripts = nbdev_create_config=nbdev.config:nbdev_create_config nbdev_conda=nbdev.release:release_conda nbdev_release_both=nbdev.release:release_both nbdev_bump_version=nbdev.release:nbdev_bump_version + nbdev_requirements=nbdev.release:write_requirements nbdev_proc_nbs=nbdev.quarto:nbdev_proc_nbs nbdev_help=nbdev.cli:chelp tst_flags = notest