如何向PyPi发送包?

2024-04-25 11:59:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我写了一个小模块,我想知道打包它的基本步骤是什么,以便将它发送到pypi

  • 什么是文件层次结构?在
  • 我应该如何命名文件?在
  • 我应该使用distutils创建PKG-INFO吗?在
  • 我应该把我的文件(用狮身人面像制作的)放在哪里?在

Tags: 模块文件infopypi层次结构步骤pkg命名
3条回答

也许{a1}对你有帮助。从那里开始:

Submitting Packages to the Package Index

If you have some Python modules or packages that you would like to share with the Python community, we'd love to have them included in the Python Package Index! First, if you haven't done so, you will want to get your project organized. You might follow the guidelines at ProjectFileAndDirectoryLayout. After that, you'll want to read the Python documentation regarding creating distributions: http://docs.python.org/distutils/index.html.

您还可以查看Tarek的《Python编程专家》(expertpython Programming)中的Writing a Package in Python by Tarek Ziadé,其中详细介绍了有关开发和分发的问题

举个例子总是最好的办法:

http://packages.python.org/an_example_pypi_project/

我建议阅读The Hitchhiker's Guide to Packaging。具体来说,您应该看看Quick Start section,它描述了如何:

  1. Lay out your project
  2. Describe your project
  3. Create your first release
  4. Register your package with the Python Package Index (PyPI)
  5. Upload your release, then grab your towel and save the Universe!

您还应该查看Introduction to Packaging section中的Current State of Packaging,因为这有助于解开围绕setuptools、distutils、distutils2和distribute的一些混乱。在

更新主题:如何命名文件

下面的摘录来自PEP8,它回答了您关于如何命名文件的问题:

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

Since module names are mapped to file names, and some file systems are case insensitive and truncate long names, it is important that module names be chosen to be fairly short -- this won't be a problem on Unix, but it may be a problem when the code is transported to older Mac or Windows versions, or DOS.

相关问题 更多 >