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

后端 未结 2 1880
迷失自我
迷失自我 2020-12-12 11:10

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<
相关标签:
2条回答
  • 2020-12-12 11:16

    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 the current directory (.).

    To change the output directory (to for example, ./wheels), you may use the -w / --wheel-dir option:

    pip wheel . -w wheels
    

    All the options available are listed at the pip documentation.

    0 讨论(0)
  • 2020-12-12 11:18

    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/
    0 讨论(0)
提交回复
热议问题