Is PyPI case sensitive?
Asked Answered
A

3

77

How does PyPI handle case sensitivity?

For example, this SO question documents PyPI refusing a new package foobar if FooBar already exists.

Running pip against pypi.python.org seems to convert to the canonical case for a package:

$ pip install django
Downloading/unpacking django
  Downloading Django-1.7.tar.gz (7.5MB): 7.5MB downloaded

Alternatively:

$ pip install Django
Downloading/unpacking Django
  Downloading Django-1.7.tar.gz (7.5MB): 7.5MB downloaded

However, only some files seem to be in the canonical case in my virtualenv:

$ ls ~/pyenvs/test_venv/lib/python2.7/site-packages/ | grep -i django
django/
Django-1.7-py2.7.egg-info/

What does the XML-RPC API expect? Can I always assume that http://pypi.python.org/simple/foo and http://pypi.python.org/simple/FoO will both return HTTP 200?

Is PyPI's position on case-sensitivity documented anywhere?

Aniseed answered 22/10, 2014 at 8:45 Comment(1)
Imho, the "canonical" you observe case is not in the responsibility of pypi, but rather of the django developers': Their package consists of a lower-case "django" folder (in agreement with the python styleguide on package names), while they named the pypi package "Django".Jard
L
91

No, pip is case insensitive.

All comparisons of distribution names MUST be case insensitive, and MUST consider hyphens and underscores to be equivalent.

from PEP 426

Legitimist answered 23/7, 2015 at 11:2 Comment(0)
N
4

Name of your project determines how your project is listed on PyPI. Per PEP 508, valid project names must:

  • Consist only of ASCII letters, digits, underscores (_), hyphens (-), and/or periods (.), and
  • Start & end with an ASCII letter or digit.

Comparison of project names is case insensitive and treats arbitrarily-long runs of underscores, hyphens, and/or periods as equal. For example, if you register a project named cool-stuff, users will be able to download it or declare a dependency on it using any of the following spellings:

Cool-Stuff
cool.stuff
COOL_STUFF
CoOl__-.-__sTuFF

See official docs for details.

Naashom answered 9/1, 2023 at 9:21 Comment(0)
P
2

https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization

e.g., the following names are all equivalent:

friendly-bard (normalized form)

Friendly-Bard

FRIENDLY-BARD

friendly.bard

friendly_bard

friendly--bard

FrIeNdLy-._.-bArD (a terrible way to write a name, but it is valid)

Pantalets answered 28/6, 2023 at 8:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.