Will depreciation of setup.py break nbdev?

I love working with Jupyter notebooks and nbdev has been my entry to building python packages with beautiful documentation. Today I depend 100% on nbdev for all my python package development. Thanks for all the efforts creating this tool! However there is some pain as well. I somehow survived the recent upgrade from nbdev 1 to 2 after several weeks of bug fixing. But the experience made me wonder if I should stick to nbdev.

Today I uploaded a new version of one of my packages to PyPi using nbdev_pypi and was alarmed by a depreciation warning for setup.py install:

/home/frank/anaconda3/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.

        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.


To my understanding setup.py is at the heart of the nbdev system. Will the full depreciation of setup.py break nbdev in the near future?


I agree, would be good to know!

1 Like

I circumvented this issue by using pypi recommendation to upload. By using twine directly with build folder. I am not sure if I got the exact same error, just sharing my workflow.


I was uploading another nbdev python package to the Python Package index today and was reminded about this issue again. Also had another read at the article by Paul Ganssle, but I must admit that I can not fully comprehend the proposed PEP517 compliant alternative.

@hamelsmu, can you perhaps shed some light on this issue?

After some further research I believe I found the cause of the setup.py warning that was triggered by running the nbdev_pypi terminal command. No need to be alarmed. It seems we can fix this with a single line of code.

The culprit is here in the first system() call in which the package is created. So actually not in the second system() call where we upload to pypi.org using twine.

def release_pypi(
    repository:str="pypi" # Respository to upload to (defined in ~/.pypirc)
    "Create and upload Python package to PyPI"
    _dir = get_config().lib_path.parent
    system(f'cd {_dir}  && rm -rf dist build && python setup.py sdist bdist_wheel') 
    system(f'twine upload --repository {repository} {_dir}/dist/*')

The depreciation warning does not say that we can not use a setup.py file! We just should not invoke it directly from the command line like so: python -m setup.py. Instead we can still build the package files with a setup.py file with the command python -m build.

This does require that the build package is (pip) installed on your system.

I will also post this issue on the nbdev github repo.

1 Like