是否可以创建一个完全独立的Python包? [英] Is it possible to create a fully self-contained Python package?

查看:71
本文介绍了是否可以创建一个完全独立的Python包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ansible是一个可通过pip安装的python moduel.它依赖于几个依赖项,也依赖于pip模块.是否有可能将所有这些依赖项和Ansible自身汇总"到某种形式的单个软件包中,而无需root用户即可脱机安装?尽管安装包可以使用pip,但最好不要安装pip.

Ansible is a python moduel, installable via pip. It relies on several dependencies, also pip modules. Is it possible to "roll up" all of those dependencies and Ansible itself into some sort of a single package, that can be installed offline, without root? It's highly preferable to not need pip for the install, although it will be available for package creation.

我正在尝试在我们的一台服务器上安装Ansible.服务器无权访问Internet,没有root访问权.没有安装Pip,但安装了Python.可以在此处安装pip,但可能很复杂.在服务器上获取任何内容的唯一方法是通过内部tar.gz软件包共享解决方案.

I'm trying to install Ansible on one of our servers. The server does not have access to the internet, there is no root access. Pip is not installed, but Python is. It is possible to get pip installed there, but might be complicated. The only way to get anything on the server is via an internal tar.gz package sharing solution.

我尝试摆弄rpm,保存相关性,但是没有root访问权就此结束了.

I've tried fiddling around with rpm, saving dependencies, but the absence of root access put an end to that.

推荐答案

在连接互联网的计算机上使用pip通过-download和-r requirements.txt ,然后将该目录放在已安装pip的已断开连接的计算机上,然后使用-no-index和--find-links =(archive dir)进行安装.

Use pip on an internet-connected machine to download all the deps to a local dir with --download and -r requirements.txt, then drop that dir on the disconnected machine with pip installed, and install using --no-index and --find-links=(archive dir).

请参见 https://pip.pypa.io/en/最新/user_guide/#fast-local-installs

这篇关于是否可以创建一个完全独立的Python包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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