使用setup.py从gitattag安装python包

我在私有 git 仓库中有一个包 (foo)。我想通过 bar 的 setup.py 安装 foo 以供另一个包 bar 使用。我想要一个特定的版本 - setup.py 中 foo 的版本匹配它的 git 标签(0.3.2,git 标签是 v0.3.2)

bar 的 setup.py 如下所示:

#!/usr/bin/env python
  
from setuptools import setup, find_packages

setup(name='bar',
        install_requires=['foo@ git+ssh://git@github.com/fergusmac/foo.git@v0.3.2#subdirectory=somedir']
    )

我还尝试在最后明确添加版本:

install_requires=['foo@ git+ssh://git@github.com/fergusmac/foo.git@v0.3.2#subdirectory=somedir==0.3.2']

我目前在我的 venv 中安装了 0.3.1 版。当我尝试安装这个 setup.py 时,通过pip install .,或者pip install . -U版本没有升级 - 甚至没有检出 repo:

Requirement already satisfied, skipping upgrade: foo@ git+ssh://git@github.com/fergusmac/foo.git@v0.3.2#subdirectory=src==0.3.2 from 
git+ssh://****@github.com/fergusmac/foo.git@v0.3.2#subdirectory=src==0.3.2 in 
./venv/lib/python3.8/site-packages (from bar==0.0.0) (0.3.1)

但是,当我直接使用pip安装foo时,升级就完成了:

pip install git+ssh://git@github.com/fergusmac/foo.git@v0.3.2#subdirectory=src

Collecting git+ssh://****@github.com/fergusmac/foo.git@v0.3.2#subdirectory=src
  Cloning ssh://****@github.com/fergusmac/foo.git (to revision v0.3.2) to /tmp/pip-req-build-gxj2duq6
  Running command git clone -q 'ssh://****@github.com/fergusmac/foo.git' /tmp/pip-req-build-gxj2duq6
  Running command git checkout -q 40fa65eb75fc26541c90ee9e489ae6dd5538db1f
  Running command git submodule update --init --recursive -q
...
Installing collected packages: foo
  Attempting uninstall: foo
    Found existing installation: foo0.3.1
    Uninstalling foo-0.3.1:
      Successfully uninstalled foo-0.3.1
    Running setup.py install for foo... done
Successfully installed foo-0.3.2

我不明白为什么用 setup.py 安装会产生不同的行为。我如何确保它检查回购并寻找正确的版本?

后续问题 - 我将如何指定“检查 foo 的主分支并安装任何版本,如果它高于当前安装的版本”?

以上是使用setup.py从gitattag安装python包的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>