简体   繁体   English

Python:如何安装第三方程序包并使其他团队可以使用

[英]Python: How to install a third-party package and make it available to rest of team

My team uses git to track the code and we want to do the following: (1) One team-member installs a third-party python package and (2) makes it available on our git repo, so that the rest of the team can simply install the package by pulling the latest version of our code. 我的团队使用git来跟踪代码,我们想要执行以下操作:(1)一个团队成员安装了一个第三方python软件包,(2)使它在我们的git repo上可用,以便团队的其他成员可以只需安装最新版本的代码即可安装该软件包。

Is that possible at all? 那有可能吗? If so, what are feasible solutions? 如果是这样,什么可行的解决方案? If not, what approach works best in your experience? 如果没有,哪种方法最适合您的经验?

Background: We are using python 2.7.*. 背景:我们正在使用python 2.7。*。 The third-party package is testfixtures to unittest the logging of our software. 第三方软件包是testfixtures,用于对我们软件的日志记录进行单元测试。 We use Windows and Mac. 我们使用Windows和Mac。

Create a requirements.txt file and place it in your directory. 创建一个requirements.txt文件并将其放置在您的目录中。 Each line in the file should contain the name of a package that your entire team should have installed. 文件中的每一行都应包含整个团队应已安装的软件包的名称。 Your team members, once they have the new version of the file, can run pip install -r requirements.txt . 您的团队成员在拥有文件的新版本后,可以运行pip install -r requirements.txt Then, update the requirements.txt file every time you have a new package required, and rerun the command. 然后,每当您需要一个新的程序包时,更新requirements.txt文件,然后重新运行该命令。

Some editors (like PyCharm) will even automatically detect a requirements file and prompt you to install the packages. 一些编辑器(如PyCharm)甚至会自动检测到需求文件并提示您安装软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM