You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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/*')
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 is added as a dependency to nbdev.
fligt
changed the title
Direct invocation of setup.py depreciated when uploading package to PyPi
Direct invocation of setup.py deprecated when uploading package to PyPi
Jun 4, 2024
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.The culprit is in the
release_pypi()
function here in the firstsystem()
call in which the package is created. So actually not in the secondsystem()
call where we upload to pypi.org using twine.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 commandpython -m build
.To my understanding my proposed solution does require that the build package 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
The text was updated successfully, but these errors were encountered: