pip install from a private bitbucket repo tar.gz file

时间:2019-01-15 18:11:05

标签: python git pip bitbucket

I have a common private repo that depends on other private repos.

I have a build process that creates a tar.gz file. it's on this url

https://git.my_company.com/projects/RA/repos/my-common-module/browse/scripts/testing_dist/api_common_module-4.0.10.tar.gz

here is the ssh url

ssh://git@git.my_company.com:8500/ra/my-common-module.git

my question is, what's the pip command I should use to install it from the terminal and a follow-up question, what should I write in the requirements.txt file to notate that installation?

1 个答案:

答案 0 :(得分:1)

您可以执行此操作,但这是潜在的安全风险,因此请谨慎操作。

Bitbucket Cloud,Bitbucket Server和GitHub允许您生成应用程序密码(Bitbucket Cloud)或个人访问令牌(Bitbucket Server,GitHub)。这些密码的范围可能受到限制(例如,只读),因此密码不能用于执行破坏性操作。您可以使用它们将用户名和密码直接嵌入可通过pip安装的网址,例如:

pip install -e git+https://charlie:abcdefgh12345678@bitbucket.org/charlie/snakesonaplane.git@master#egg=snakesonaplane

(注意:不是真正的仓库)

这是问题所在:将任何类型的凭据提交给其他人可以看到的项目几乎总是'em>危险。例如,将这样的内容放入您的 requirements.txt 几乎总是一个坏主意。即使这是一个只读密码,即使可以访问该密码的任何人都已经可以访问其他所有密码,否则它将为他们提供访问权限。想象一下,如果您的一个队友离开了您的组/公司/等,只要应用程序密码有效,他们就可能保留对您所有工作的只读访问权限。

这里的“理想”解决方案是托管您自己的PyPi服务器。您可以使用它来托管私有软件包,以便可以通过pip安装它们而无需将凭据嵌入需求文件中,并且如果您在大型组织工作,则很可能已经存在一个私有软件包。这是一个非常有趣的话题,所以我不会复制大量信息,但是值得研究。