Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Python Packaging User Guide
Python Packaging User Guide
Back to top

Names and normalization

This specification defines the format that names for packages and extras arerequired to follow. It also describes how to normalize them, which should bedone before lookups and comparisons.

Name format

A valid name consists only of ASCII letters and numbers, period,underscore and hyphen. It must start and end with a letter or number.This means that valid project names are limited to those which match thefollowing regex (run withre.IGNORECASE):

^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])\Z

Name normalization

The name should be lowercased with all runs of the characters.,-, or_ replaced with a single- character. This can be implemented in Pythonwith the re module:

importredefnormalize(name):returnre.sub(r"[-_.]+","-",name).lower()

This means that the following names are all equivalent:

  • friendly-bard (normalized form)

  • Friendly-Bard

  • FRIENDLY-BARD

  • friendly.bard

  • friendly_bard

  • friendly--bard

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

History

  • September 2015: The specification of name normalized was approved through503.

  • November 2015: The specification of valid names was approved through508.

  • August 2025: The suggested name validation regex was fixed to match the fieldspecification (it previously finished with$ instead of\Z,incorrectly permitting trailing newlines)

On this page

[8]ページ先頭

©2009-2025 Movatter.jp