1
votes

I have a python package (xyz) that was on python.pypi.org. I am trying to release a new version and I am using twine for upload. I fixed everything in the ~/.pypirc file as explained on tutorials. When I run the following command:

twine upload dist/*

I got the following output:

Uploading distributions to https://upload.pypi.org/legacy/

Uploading xyz-1.9.1.tar.gz

HTTPError: 400 Client Error: provides: Invalid requirement: 'xyz (1.9.1)' for url: https://upload.pypi.org/legacy/

I was not sure why this is happening but I am guessing it could be my setup.py file but here are the block in my setup() part.

setup(
name='xyz',
version=__version__,
author='xyz',
author_email='xyz',
description='xyz package for xyz',
long_description=long_description,
url='xyz',
packages=PACKAGES,
package_dir=PACKAGE_DIR,
package_data=PACKAGE_DATA,
ext_modules=EXTENSIONS,
license='MIT License',
keywords=('xyz'),
classifiers=[
             'Development Status :: 5 - Production/Stable',
             'Intended Audience :: Education',
             'Intended Audience :: Science/Research',
             'License :: OSI Approved :: MIT License',
             'Operating System :: MacOS',
             'Operating System :: Microsoft :: Windows',
             'Operating System :: POSIX',
             'Programming Language :: Python',
             'Programming Language :: Python :: 2',
             'Programming Language :: Python :: 3',
             'Topic :: Scientific/Engineering :: xyz',
             'Topic :: Scientific/Engineering :: xyz',
            ],
scripts=SCRIPTS,
requires=['NumPy (>=1.7)', ],
provides=['xyz'.format(__version__)]

)

Could anyone help me on this? Thanks.

Note: "xyz" is the replacement name for the package. There will be no duplicate packages.

1

1 Answers

1
votes

(I'm assuming that the provides=['xyz'.format(__version__)] line in your setup.py is actually provides=['xyz ({})'.format(__version__)], as otherwise this doesn't make any sense.)

First of all, the provides and requires arguments to setup() are deprecated and, as far as I am aware, were never actually used for anything. requires should now be spelled install_requires instead. There is no replacement for provides, as trying to give that field any formal meaning leads to problems that outweigh the minuscule benefit that such a field might bring. However, if you insist on using provides, it appears that PyPI for some reason requires the field's values to be valid requirement strings, which "xyz (1.9.1)" is not; a valid requirement would look like "xyz == 1.9.1" or "xyz (== 1.9.1)" instead, but, as indicated previously, none of those actually mean anything.

PS: I would suggest you read "Packaging and Distributing Projects" from the Python Packaging User Guide for modern, recommended Python packaging practices.