来自 bitbucket 的 pip 升级包不起作用

pip upgrade package from bitbucket not working

我想升级 python 驻留在 bitbucket 私有存储库中的包,就像您对 pypi 包所做的那样。假设我有几个提交之后的包,并且我的 ssh 运行良好。

我将结果添加为

实际上包的版本保持不变。所以除非我更改版本号,否则我无法升级包?

(env) pip install git+ssh://git@bitbucket.org/path/to/git.git --upgrade

Collecting git+ssh://****@bitbucket.org/path/to/git.git
  Cloning ssh://****@bitbucket.org/path/to/git.git/ to /private/var/folders/blabla
  Running command git clone --filter=blob:none -q 'ssh://****@bitbucket.org/path/to/git.git' /private/var/folders/blabla
  warning: filtering not recognized by server, ignoring
  Resolved ssh://****@bitbucket.org/path/to/git.git to commit random_commit_hash
  Preparing metadata (setup.py) ... done


Requirement already satisfied: django in ./.venv/lib/python3.7/site-packages (from mypackage==1.0.0) (2.2.12)
Requirement already satisfied: material in ./.venv/lib/python3.7/site-packages (from mypackage==1.0.0) (0.1)
Requirement already satisfied: django-filter in ./.venv/lib/python3.7/site-packages (from mypackage==1.0.0) (21.1)
Requirement already satisfied: six in ./.venv/lib/python3.7/site-packages (from mypackage==1.0.0) (1.16.0)
Requirement already satisfied: pytz in ./.venv/lib/python3.7/site-packages (from mypackage==1.0.0) (2021.3)
Requirement already satisfied: sqlparse in ./.venv/lib/python3.7/site-packages (from django==2.2.12->mypackage==1.0.0) (0.4.2)


您可能希望这段代码会更新您的包,但我没有看到代码有任何变化,即使最新的提交肯定有一些新代码。请注意,我故意遗漏了一些不必要的东西,但你会明白的。

我还试过把master之类的后缀放在末尾(git+ssh://git@bitbucket.org/path/to/git.git@master),想看看冗长有没有效果,但是没有用。

由于无法重现,我能做的就是描述情况,所以请多多包涵。

也许是 bitbucket 的问题?任何帮助将不胜感激。

编辑 我注意到在生产脚本中 pip install git+ssh://git@bitbucket.org/path/to/git.git --upgrade 工作正常。它确实有一些不同的日志

pip install git+ssh://git@bitbucket.org/path/to/git.git --upgrade
Collecting git+ssh://****@bitbucket.org/path/to/git.git
  Cloning ssh://****@bitbucket.org/path/to/git.git to /random/path
  Running command git clone -q 'ssh://****@bitbucket.org/path/to/git.git' /random/path
Requirement already satisfied, skipping upgrade: django==2.2.12 in /path/to/env/lib/python3.7/site-packages (from mypackage==1.0.0) (2.2.12)
Requirement already satisfied, skipping upgrade: material in /path/to/env/lib/python3.7/site-packages (from mypackage==1.0.0) (0.1)
Requirement already satisfied, skipping upgrade: django-filter in /path/to/env/lib/python3.7/site-packages (from mypackage==1.0.0) (2.2.0)
Requirement already satisfied, skipping upgrade: six in /path/to/env/lib/python3.7/site-packages (from mypackage==1.0.0) (1.14.0)
Requirement already satisfied, skipping upgrade: pytz in /path/to/env/lib/python3.7/site-packages (from mypackage==1.0.0) (2020.1)
Requirement already satisfied, skipping upgrade: sqlparse in /path/to/env/lib/python3.7/site-packages (from django==2.2.12->mypackage==1.0.0) (0.2.4)
Building wheels for collected packages: mypackage
  Building wheel for mypackage (setup.py): started
  Building wheel for mypackage (setup.py): finished with status 'done'
  Created wheel for mypackage: filename=mypackage-1.0.0-py3-none-any.whl size=4960455 sha256=44e088cf39ec635435731ef6e6b483bb6a1be64e4d86327d6c0a61672de80a49
  Stored in directory: /random/path
Successfully built mypackage
Installing collected packages: mypackage
  Attempting uninstall: mypackage
    Found existing installation: mypackage 1.0.0
    Uninstalling mypackage-1.0.0:
      Successfully uninstalled mypackage-1.0.0
Successfully installed mypackage-1.0.0

如您所见,部署日志中的 pip install .. 已转换为 git clone -q,而在我的本地 git clone --filter=blob:none -q.

可能是git版本不同? Git部署版本是1.8.3.1,本地版本是2.29.1。

每次更改一些代码时,我都觉得编辑包版本很乏味。相反,我决定保持包的版本不变,运行 this in shell:

pip uninstall -y pakcage_name && pip install git+ssh://bitbucket.org/path/to/repo.git

这种方法与使用 --force-reinstall 安装的区别在于前者保留了对软件包的一些依赖性,而后者则没有。