Bitbucket 应用程序密码拒绝使用“pip”安装,但适用于“pipenv”

Bitbucket app password refused for installation using “pip” but works for “pipenv”

我必须为我们团队的 Python 包提供私有 BitBucket 存储库的访问权限,以便从 Google App Engine 安装。

我创建了一个只有一个权限“存储库读取”的应用程序密码,并且能够使用它来克隆我的存储库并且使用 pipenv 安装我的包没有任何问题,但是 pip 确实收到来自 BitBucket 的 HTTP 403:

Collecting my-package-0.1.0.beta1 from https://my_user:****@bitbucket.org/my-team/my_repo.git@v0.1#egg=my-package-0.1.0.beta1 (from -r requirements.txt (line 35))
  HTTP error 403 while getting https://my_user:****@bitbucket.org/my-team/my_repo.git@v0.1#egg=my-package-0.1.0.beta1
  Could not install requirement my-package-0.1.0.beta1 from https://my_user:****@bitbucket.org/my-team/my_repo.git@v0.1#egg=my-package-0.1.0.beta1 (from -r requirements.txt (line 35)) because of error 403 Client Error: Forbidden for url: https://bitbucket.org/my-team/my_repo.git@v0.1

在我的requirements.txt第35行是https://${BIT_USER}:${BIT_PASS}@bitbucket.org/my-team/my_repo.git@v0.1#egg=my-package-0.1.0.beta1

使用命令行克隆:git clone "https://${BIT_USER}:${BIT_PASS}@bitbucket.org/my-team/my_repo.git" 非常有效,pipenv 安装时没有任何问题,我的 Pipfile.[=23= 中的 my-package = {git = "https://my_user:app_password@bitbucket.org/my-team/my_repo.git",ref = "v0.1"} ]

请注意,当使用 pipenv 安装时,在我 运行 pip freeze 之后,我看到我的包被列为 my-package==0.1.0b1 即使它在 setup.py 中的版本是 0.1.0.beta1

我是不是漏掉了什么?

因为pip supports installing from multiple VCS, you need to add the prefix identifying the particular VCS when installing from repo URL. Git examples from the Git部分:

pip currently supports cloning over git, git+http, git+https, git+ssh, git+git and git+file:

Here are the supported forms:

[-e] git://git.example.com/MyProject#egg=MyProject
[-e] git+http://git.example.com/MyProject#egg=MyProject
[-e] git+https://git.example.com/MyProject#egg=MyProject
[-e] git+ssh://git.example.com/MyProject#egg=MyProject
[-e] git+git://git.example.com/MyProject#egg=MyProject
[-e] git+file:///home/user/projects/MyProject#egg=MyProject
-e git+git@git.example.com:MyProject#egg=MyProject