I also failed to run nbdev_install_git_hooks (see Appendix 1) and nbdev_build_lib (see Appendix 2) when installing nbdev in Windows 10 using conda.
Appendix 1
#!/bin/sh
'''exec' C:/Users/{name}/Anaconda3/envs/{repo_name}/bin/python "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from nbdev.cli import nbdev_install_git_hooks
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(nbdev_install_git_hooks())
Appendix 2
#!/bin/sh
'''exec' C:/Users/{user}/Anaconda3/envs/{repo_name}/bin/python "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from nbdev.cli import nbdev_build_lib
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(nbdev_build_lib())
There is no bin path for Python in Windows (only Scripts). Also, both file names are without extension (not .exe). Anyone can use nbdev in Windows? How to change the scripts/path to fix this?
Thanks @Moody and @MichaelR , this was quite helpful to learn that the nb_dev commands work under Windows if it’s installed via pip (but not via conda). I first installed it using conda, and running the commands would just pop up a .sh script for each command.
Hi @Moody, thanks for the tip about v2. I am using nbdev 2.3.8. My observation seems to be the same as yours back in 2021 with v1:
If I install nbev via conda on Windows native, then commands such as nbdev_prepare pop up a .sh file in my text editor
If I install nbdev via pip on Windows native, then nbdev_prepare uses an .exe and runs as expected
I was using Windows native because I wanted to access data on a network location and didn’t easily figure out how to get to it on Windows Subsystem for Linux (WSL). Now I’ve decided to develop my library using a test dataset and I’ve switched to WSL, where things just work so far.
There’s a really nice feature of pip/setuptools that lets you create commandline scripts directly from functions, makes them available in the PATH , and even makes your scripts cross-platform (e.g. in Windows it creates an exe).
So why does this work for pip but not for conda? I can see that nbdev’s setup.py includes the necessary section to create console_scripts. I also see nbdev/release.ipynb that release_pypi runs setup.py, while release_conda calls conda build. It’s over my head to know how the conda build process works, though! I wonder if there is a simple way to also call setup.py just to create the console_scripts entry points.
I’m just cross-referencing nbdev github issue 1149. I was at the same point as @willsa14 in reverse engineering the conda build process. I’ve authored a couple of conda packages but not with command line scripts, so unsure how to tackle and on the backburner for now.