Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct invocation of setup.py deprecated when uploading package to PyPi #1416

Open
fligt opened this issue Jun 3, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@fligt
Copy link

fligt commented Jun 3, 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.

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

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

@fligt fligt added the bug Something isn't working label Jun 3, 2024
@fligt 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant