python - 如果它有多个子目录,如何从 git 使用 pip 安装包?

标签 python python-2.7 pip

我正在使用具有以下结构的存储库:

  • foo/bar/setup.py
  • foo/bar/我的包

我正在尝试使用类似这样的方式安装这个包:

pip install git+ssh://git@github.com/owner/repo-namegit@commithash#egg=mypackage&subdirectory=foo/bar

然而,它只是卡在这里,似乎没有任何反应。

他们的 documentation没有像这样的多嵌套目录包路径的示例。不管它怎么说,强调我的:

For projects where setup.py is not in the root of project, "subdirectory" component is used. Value of "subdirectory" component should be a path starting from root of the project to where setup.py is located

通过 pip 为多目录正确构建的安装是什么样的?

上面返回的错误如下:

  Could not find a tag or branch 'commit', assuming commit.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-gAwA3W-build/setup.py'

我使用我测试过的所有 pip 版本(9.0.1 和 8.1.1)看到了这一 pip 。

详细日志如下:

$ pip install git+ssh://git@github.com/user/repo.git@hash#egg=projectname&subdirectory=lib/python
[1] 4195

Collecting projectname from git+ssh://git@github.com/user/repogit@hash#egg=projectname
  Cloning ssh://git@github.com/user/repo.git (to 8d109c760ae8a9599299924be1b78645e2617a50) to /private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo
  Could not find a tag or branch 'hash', assuming commit.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/wf/89r2567s5hv48lj1g9l65mbw0000gp/T/pip-build-w01D4G/repo/

[1]+  Exit 1                  pip install git+ssh://git@github.com/user/repo.git@hash#egg=projectname

看起来在我调用它的初始 subdirectory 行之后,pip 命令的那部分正在消失?

最佳答案

在 pip 中使用多个运算符时,整个参数需要用引号引起来:

pip install git+ssh://git@github.com/owner/repo-name.git@commithash#"egg=mypackage&subdirectory=foo/bar"

否则,pip 会在 & 之后丢弃任何内容,并且无法成功识别它。

关于python - 如果它有多个子目录,如何从 git 使用 pip 安装包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40731224/

相关文章:

python - 找到我的数据中斜率变化的位置作为可以轻松索引和提取的参数

python - 替换文件中的字符串

python - pip:没有模块名称_internal.main

python - 精确在线 API : deleting and updating items like BankEntryLines

python - 在字典中循环键

python - 在一个字符串中查找多个正则表达式

python - 将非零元素向右挤压

python - pip安装后找不到包

pip - 防止 pip 缓存包

python - 什么时候使用变量类? (BooleanVar, DoubleVar, IntVar, StringVar)