如何构建包括依赖项的Python项目? [英] How to build Python project including dependencies?

查看:113
本文介绍了如何构建包括依赖项的Python项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个项目,都包含 setup.py requirements.txt .是否可以将整个项目打包到一个文件中,包括已编译并准备安装的所有需求?

I have a few projects, all containing setup.py and requirements.txt. Is it possible to package a whole project in one single file including all requirements compiled and ready to install?

我尝试过的事情:

python setup.py bdist_wheel

构建一个 .whl 文件,并将其放在 dist 目录中.滚轮不包含任何依赖项.

Builds a .whl file and puts it in the dist directory. The wheel does not contain any dependencies.

pip wheel -r requirements.txt -w wheelhouse

为每个单独的需求构建轮子,并将其放置在 wheelhouse 目录中.包括例如为 numpy 精心编译的代码(我知道我必须在要使其以后运行的每个平台上构建它,这很好).

Builds wheels for every single requirement and puts it in the wheelhouse directory. Includes nicely compiled code for numpy for example (I know I have to build this on every platform I want it to run later on, that's fine).

似乎我只是错过了最后一个难题.

推荐答案

您可能想看看类似 cx_freeze PyInstaller ,如果您绝对想要一个包含所有内容的文件.点子本身无法做您想做的事.

You probably want to take a look at tools like cx_freeze or PyInstaller if you absolutely want one single file containing everything. Pip itself cannot do what you want.

这篇关于如何构建包括依赖项的Python项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆