仅安装依赖项-SetupTools [英] Installing dependencies only - setuptools

查看:152
本文介绍了仅安装依赖项-SetupTools的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python脚本,带有多个外部依赖项,希望分发给同事.但是,我们将需要定期修改此脚本,因此我不想就其本身 install (即复制到site-packages).从我看到的内容来看,setuptools似乎是暗中做的.

I have a Python script, with several external dependencies, that I wish to distribute to colleagues. However, we will need to modify this script regularly so I don't want to install it per-se (i.e. copy to site-packages). From what I've seen setuptools seems to do this implicitly.

是否有推荐的方法来安装依赖项而不安装应用程序/脚本本身?

Is there a recommended approach to installing dependencies without installing the application/script itself?

推荐答案

您可能希望确保您和您的同事在开发过程中使用相同的依赖项.

You probably want to make sure that you and your colleagues use the same dependencies during development.

我想我会尝试为此使用virtualenv.如果您和您的同事安装了该程序,它将仅为该项目提供一个python环境,并且仅为该项目提供依赖项.

I think I would try to use virtualenv for this. If you and your collegues install it, it will give you a python environment for this project only, and dependencies for this project only.

因此步骤将是:

  1. 每个人都在他们的计算机上安装了virtualenv,因此他们得到了一个隔离的环境,只能用于开发该项目.

  1. Everybody installs virtualenv on their computers so they get an isolated environment to use for development of this project only.

你们中的一个确定当前依赖关系并将其安装在您的virtualenv中.

One of you determine the current dependencies and installs them in your virtualenv.

您可以使用以下命令导出使用的依赖项列表:

You export a list of your used dependencies using this command:

(在虚拟环境中)点冻结> requirements.txt

(inside virtual environment) pip freeze > requirements.txt

然后与其他人共享此文本文件.他们使用以下命令将完全相同的软件包和版本导入其虚拟环境:

You then share this text file with the others. They use this command to import the exact same packages and versions into their virtual environment:

(在虚拟环境中)pip install -r requirements.txt

(inside virtual environent) pip install -r requirements.txt

在发出这些命令之前,请确保每个人都进入了虚拟环境,否则文本文件将包含其在python环境中安装的常规软件包.

Just make sure that everybody enters their virtual environment before issuing these commands, otherwise the text file will contain their normal python environment installed packages.

这篇关于仅安装依赖项-SetupTools的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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