wheels的用途是什么?为什么它们在安装软件包时很有用?

2024-04-24 08:19:15 发布

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

我只想了解python轮子如何适应python开发的大局。这是一个非常笼统的问题,但我很难从网上搜索到这些信息。如果有人能提供任何链接,那也不错。你知道吗


Tags: 信息链接轮子笼统大局
1条回答
网友
1楼 · 发布于 2024-04-24 08:19:15

来自伟大的书"Serious Python"

For most of Python’s existence, there’s been no official standard distribution format. While different distribution tools generally use some common archive format—even the Egg format introduced by setuptools is just a zip file with a different extension—their metadata and package structures are incompatible with each other. This problem was compounded when an official installation standard was finally defined in PEP 376 that was also incompatible with existing formats.

To solve these problems, PEP 427 was written to define a new standard for Python distribution packages called Wheel. The reference implementation of this format is available as a tool, also called Wheel.

Wheel is supported by pip starting with version 1.4. If you’re using setuptools and have the Wheel package installed, it automatically integrates itself as a setuptools command named bdist_wheel. If you don’t have Wheel installed, you can install it using the command pip install wheel

要创建控制盘,请运行以下命令:

$ python setup.py bdist_wheel

The bdist_wheel command creates a .whl file in the dist directory. As with the Egg format, a Wheel archive is just a zip file with a different extension. However, Wheel archives do not require installation—you can load and run your code just by adding a slash followed by the name of your module:

$ python wheel-0.21.0-py2.py3-none-any.whl/wheel -h

One of the advantages of Wheel is that its naming conventions allow you to specify whether your distribution is intended for a specific architecture and/or Python implementation (CPython, PyPy, Jython, and so on). This is particularly useful if you need to distribute modules written in C.

Wheel is a great format for distributing ready-to-install libraries and applications, so you are encouraged to build and upload them to PyPI as well.

相关问题 更多 >