Build a wheel/egg and all dependencies for a python project

我的梦境 提交于 2019-11-27 09:32:37

问题


In order to stage python project within our corporation I need to make an installable distribution.

This should include:

  • An egg or whl for my project
  • An egg or whl for every dependency of the project
  • (optionally) produce a requirements.txt file listing all the installable components for this release

Is there an easy plug in, (e.g. an alternative to bdist_wheel) that will not only compile one wheel but also that project's components?

Obviously I can script this, but I was hoping that there might be a short-cut that builds the package + dependencies in fewer steps.

This needs to work on Python 2.7 on Windows + Linux.


回答1:


You will need to create a setup.py file for your package. Make sure you have the latest setuptools and pip installed. Then run the following:

python setup.py bdist_wheel

This will create a wheel file for your package. This assumes you don't have C/C++ headers, DLLs, etc. If you do, then you'll probably have a lot more work to do.

To get dependencies, you will want to create a requirements.txt file and run the following:

pip wheel -r requirements.txt

If your package isn't on PyPI, then you'll have to manually copy your package's wheel file into the wheel folder that this command creates. For more information see the following excellent article:

  • http://lucumr.pocoo.org/2014/1/27/python-on-wheels/



回答2:


With the latest pip and wheel, you can simply run

pip wheel .

within your project folder, even if your application isn't on PyPi. All wheels will be stored in ./wheelhouse. When I tried it, though, it missed one of my dependencies and I needed to manually build it. Not sure why.



来源:https://stackoverflow.com/questions/26059111/build-a-wheel-egg-and-all-dependencies-for-a-python-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!