python - 为纯 Python 包构建发行版的意义何在?

标签 python python-wheel python-packaging

可以将 Python 共享为 源码分发 ( .tar.gz 格式)或作为 内置分发 (轮子格式)。

据我了解,构建发行版的要点是:

  • 节省时间:编译可能非常耗时。我们可以在服务器上执行一次并为许多用户共享。
  • 降低要求:用户不必安装编译器

  • 但是, bdist 文件的这两个参数似乎不适用于纯 python 包。尽管如此,我还是看到了 natsort有 sdist 和 bdist。以 bdist 格式共享纯 python 包有什么好处吗?

    最佳答案

    来自 pythonwheels.com :

    Advantages of wheels

    1. Faster installation for pure Python and native C extension packages.
    2. Avoids arbitrary code execution for installation. (Avoids setup.py)
    3. Installation of a C extension does not require a compiler on Linux, Windows or macOS.
    4. Allows better caching for testing and continuous integration.
    5. Creates .pyc files as part of installation to ensure they match the Python interpreter used.
    6. More consistent installs across platforms and machines.

    所以对我来说,我认为第一点和第二点对于纯 Python 包最有意义。它更小、更快、也更安全。

    关于python - 为纯 Python 包构建发行版的意义何在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59619940/

    相关文章:

    python - Pip、wheel 和 console_scripts

    python - 多级相对导入

    python - 如何确定 PyPI 包中可用的模块

    python - 检测命名管道的关闭

    python - 如何在Django中调试,好方法?

    python - 总结 Pandas 数据框中的部分列

    python - 从requirements.txt中安装轮子

    python - time.time() 无法在 Cython 中运行 while 循环预定时间

    python - 如何使用 setup.py 安装 wheel-style 包

    python - Python 中的密封/非密封包