Search code examples
pythonpackagingpypitwine

PyPI: The name is too similar to an existing project


When uploading to PyPI there is an error:

$ twine upload -r test dist/examplepkg-1.0.tar.gz           
Uploading distributions to https://test.pypi.org/legacy/
Uploading examplepkg-1.0.tar.gz
Error during upload. Retry with the --verbose option for more details.
HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
The name 'examplepkg' is too similar to an existing project. See https://test.pypi.org/help/#project-name for more information.

Which existing project? How do you find out what existing project is it talking about?


Solution

  • There is no direct way of knowing which exact package causes the name conflict, but here are some tips that may help you further in your search.

    First of all, you can find the source code of pypi (called warehouse) at https://github.com/pypa/warehouse/. Using the error message you gave, you can find that the failing check is caused by a database function called ultranormalize_name. Now, searching for that name in the codebase leads you to this migration script where the function seems to be created, which performs the following steps to check if the name is already reserved:

    1. Both cases of o (lower and upper case, o and O) gets replaced with 0 (irrelevant for your case, as there are no os in your package name)
    2. Both cases of L and I are replaced with 1 (e.g., example is same as examp1e and exampie)
    3. All ., _, and - characters are removed (e.g., e-x-a-m-p-l-e is same as example)
    4. The result is then lowercased and compared to the already existing names

    As I cannot see a direct match for your given package name, are you sure examplepkg is the name that is also in your pyproject.toml or setup.py file metadata? If yes, there is probably some variant of that name whose non-normalized form matches to yours after the transformations mentioned above.