gpt4 book ai didi

python - 轮子有什么用,为什么它们对安装包有帮助?

转载 作者:行者123 更新时间:2023-12-05 06:42:06 27 4
gpt4 key购买 nike

我只是想了解 python wheels 如何融入 Python 开发的大局。这是一个非常笼统的问题,但我无法通过在线搜索获取此信息。如果有人可以建议任何链接,那也很好。

最佳答案

来自伟大的书"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.

关于python - 轮子有什么用,为什么它们对安装包有帮助?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38547651/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com