Installing nbdev with conda on windows does not provide executable scripts

When pip installing nbdev on Windows 10, the “scripts” folder contains executables for the nbdev scripts for building, testing etc.

When installing via conda, however, these executables are not generated. Is this a bug or is some additional configuration needed on Windows?

Thank you very much!

2 Likes

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?

image

1 Like

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 @willsa14, nbdev2 was released a few months ago. I haven’t tested this problem in the latest version.

Just in case, you want to find out more about the latest release. :slight_smile:

1 Like

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.

fastcore’s script docs explain that setuptools creates these .exe files:

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).

See also: Entry Points - setuptools 65.5.1.post20221106 documentation (pypa.io)

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.

1 Like

It works for conda too on Mac and Linux - just not on Windows.

2 Likes