fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.88k stars 488 forks source link

conda package nbdev 2.3.7 does not install the correct CLI executables for use from terminal, on Windows #1149

Open jmp75 opened 1 year ago

jmp75 commented 1 year ago

I am following up on issue #1120 which was too broad. I had a better look at nbdev on Windows (native) and captured the trial process in a blog post. TL;DR version it seems to work well if installed with pip, but not if installed as conda packages.

Observations

Installing with mamba install -n bm -c fastai -c conda-forge nbdev leads to startup scripts such as C:\Users\abcdef\Miniconda3\envs\bm\Scripts\nbdev_clean containing:

#!C:/Users/abcdef/Miniconda3/envs/bm/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from nbdev.clean import nbdev_clean
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(nbdev_clean())

if nbdev is installed from pip, we have executables such as C:\Users\abcdef\Miniconda3\envs\bm\Scripts\nbdev_clean.exe and they appear to work as expected.

Note that this seems to be the case for the dependency packages ghapi and nbexec as well.

Environment

jmp75 commented 1 year ago

A note to self as I came across a couple of things while exploring.

The fastconda repository uses setuptools-conda, which produces a tarball with shell scripts under the /bin directory after setuptools-conda build . in the nbdev source folder. But it is not clear that nbdev is built this way anyway (it seems a dependency in the build actions of the fastconda repo). The portion of meta.yaml produced by setuptools-conda does look as per the conda specifications for python entry points though, so why would it not end up with Windows installs that do not work.

Or, if nbdev is indeed built with nbdev, see nbdev_conda which seems to be the python function def release_conda function. I've not tested yet.