当我使用pip install软件包时,“ Building wheel for xxx”是什么意思?

时间:2019-05-25 22:34:07

标签: python python-3.x python-2.7

当我运行命令pip install allennlp时,输出如下。 Building wheel for xxx是什么意思? Building wheel for xxx背后的动作是什么?

Building wheel for jsonnet (setup.py) ... done
  Stored in directory: /Users/xu/Library/Caches/pip/wheels/f0/47/51/a178b15274ed0db775a1ae9c799ce31e511609c3ab75a7dec5
  Building wheel for nltk (setup.py) ... done
  Stored in directory: /Users/xu/Library/Caches/pip/wheels/97/8a/10/d646015f33c525688e91986c4544c68019b19a473cb33d3b55
  Building wheel for parsimonious (setup.py) ... done

我已经进行了一些搜索,看来wheel是一种有助于pip设置程序包的文件,但我仍然不清楚。我知道这个问题可能是一个愚蠢的问题,尽管知道答案还是很好的。

1 个答案:

答案 0 :(得分:0)

我假设您已经掌握了以下文档:

pip install allennlp-vvv一起运行可提供与您的特定问题有关的更多见解:

Created temporary directory: /private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-install-leyfrduz

...

Created temporary directory: /private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-wheel-s1uhiijv
Building wheel for jsonnet (setup.py) ...   Destination directory: /private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-wheel-s1uhiijv
Running command /Users/subhashb/.pyenv/versions/3.7.2/envs/test-env-dev/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-install-leyfrduz/jsonnet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-wheel-s1uhiijv --python-tag cp37
running bdist_wheel
running build
running build_ext
c++ -c -g -O3 -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC -Iinclude -Ithird_party/md5 -Ithird_party/json core/desugarer.cpp -o core/desugarer.o
core/desugarer.cpp:406:67: warning: unused parameter 'obj_level' [-Wunused-parameter]
    AST* makeArrayComprehension(ArrayComprehension *ast, unsigned obj_level) {

...

writing manifest file 'jsonnet.egg-info/SOURCES.txt'
Copying jsonnet.egg-info to build/bdist.macosx-10.14-x86_64/wheel/jsonnet-0.12.1-py3.7.egg-info
running install_scripts
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.macosx-10.14-x86_64/wheel/jsonnet-0.12.1.dist-info/WHEEL
creating '/private/var/folders/kh/1cpkyp_535jg856yrdnql0rw0000gn/T/pip-wheel-s1uhiijv/jsonnet-0.12.1-cp37-cp37m-macosx_10_14_x86_64.whl' and adding 'build/bdist.macosx-10.14-x86_64/wheel' to it
adding '_jsonnet.cpython-37m-darwin.so'
adding 'jsonnet-0.12.1.dist-info/LICENSE'
adding 'jsonnet-0.12.1.dist-info/METADATA'
adding 'jsonnet-0.12.1.dist-info/WHEEL'
adding 'jsonnet-0.12.1.dist-info/top_level.txt'
adding 'jsonnet-0.12.1.dist-info/RECORD'
removing build/bdist.macosx-10.14-x86_64/wheel
done

使这个漂亮的过程运行的pip软件包代码位于github。最终,它调用了jsonnet的{​​{3}}以“构建”轮子

简而言之,以运行jsonnet的{​​{1}}为例,进行以下操作:

  • 将jsonnet.tar.gz下载到本地临时文件夹
  • 调用pip install jsonnet命令来编译.cpp文件
  • 构建c++(这是我的Mac OS计算机的正确库格式)
  • _jsonnet.cpython-37m-darwin.so中记录车轮分布信息(通常存在于虚拟环境中)

此流程适用于jsonnet-0.12.1.dist-info,由于jsonnet最终是C扩展,因此它有点复杂。但是常规的python软件包只会在virtualenv中下载并安装源文件。您可以走同样的路来了解任何包装背后的情况。