AnswerDotAI / AnswerDotAI/nbdev
Direct invocation of setup.py deprecated when uploading package to PyPi
- Dominant language
- Jupyter Notebook
- Stars
- 5.3k
- Forks
- 513
- Avg merge
- 2d 30m
- Merged PRs (30d)
- 8
Description
When creating and uploading a package to the Python Package index with the `nbdev_pypi` I get a warning that direct invocation of setup.py is deprecated and should be avoided.
```
$ nbdev_pypi
...
/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.
********************************************************************************
!!
...
```
The culprit is in the `release_pypi()` function [here](https://github.com/fastai/nbdev/blob/master/nbdev/release.py#L313) 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](http://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/*')
```
It seems we can fix this with a single line of code. 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 I believe we can still build the package files with a setup.py file with the command `python -m build`.
To my understanding my proposed solution does require that the [build package](https://pypi.org/project/build/) is added as a dependency to nbdev.
Shall I try to create my first pull request?
This issue was also posted here: [https://forums.fast.ai/t/will-depreciation-of-setup-py-break-nbdev/109143](https://forums.fast.ai/t/will-depreciation-of-setup-py-break-nbdev/109143)
Contributor guide
Research direction
Start in nbdev/release.py at release_pypi() and inspect the first system() call that builds the package, rather than the later twine upload call. Check how nbdev declares dependencies before evaluating the proposed build-tool change. Done means nbdev_pypi builds and uploads the package without the direct setup.py deprecation warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, release
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100