Zer*_*ind 8 python git python-3.x python-poetry pyproject.toml
我正在尝试使用 SSH 添加从 git 到诗歌的依赖性(我对 HTTPS 版本不感兴趣)。poetry add但无论我使用...,我都会收到错误
poetry add git+ssh://git@github.com:myorg/myproj.git\nRun Code Online (Sandbox Code Playgroud)\n...或者如果我手动添加...
\n# Entry in pyproject.toml\nmyproj = { git = "git@github.com:myorg/myproj.git" }\n# cmd\npoetry install\nRun Code Online (Sandbox Code Playgroud)\n在这两种情况下,我都会得到以下输出:
\nStack trace:\n\n 11 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\clikit\\console_application.py:131 in run\n status_code = command.handle(parsed_args, io)\n\n 10 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\clikit\\api\\command\\command.py:120 in handle\n status_code = self._do_handle(args, io)\n\n 9 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\clikit\\api\\command\\command.py:171 in _do_handle\n return getattr(handler, handler_method)(args, io, self)\n\n 8 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\cleo\\commands\\command.py:92 in wrap_handle\n return self.handle()\n\n 7 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\console\\commands\\add.py:106 in handle\n requirements = self._determine_requirements(\n\n 6 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\console\\commands\\init.py:320 in _determine_requirements\n requires = self._parse_requirements(requires)\n\n 5 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\console\\commands\\init.py:410 in _parse_requirements\n package = Provider.get_package_from_vcs(\n\n 4 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\puzzle\\provider.py:193 in get_package_from_vcs\n git.clone(url, tmp_dir)\n\n 3 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\core\\vcs\\git.py:262 in clone\n return self.run("clone", "--recurse-submodules", "--", repository, str(dest))\n\n 2 ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\core\\vcs\\git.py:356 in run\n subprocess.check_output(\n\n 1 ~\\AppData\\Local\\Programs\\Python\\Python310\\lib\\subprocess.py:420 in check_output\n return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,\n\n CalledProcessError\n\n Command '['C:\\\\Program Files\\\\Git\\\\cmd\\\\git.exe', 'clone', '--recurse-submodules', '--', 'git@github.com:myorg/myproj.git', 'C:\\\\Users\\\\Adeom\\\\AppData\\\\Local\\\\Temp\\\\pypoetry-git-myprojwhjkd872g']' returned non-zero exit status 128.\n\n at ~\\AppData\\Roaming\\pypoetry\\venv\\lib\\site-packages\\poetry\\utils\\_compat.py:217 in run\n 213\xe2\x94\x82 process.wait()\n 214\xe2\x94\x82 raise\n 215\xe2\x94\x82 retcode = process.poll()\n 216\xe2\x94\x82 if check and retcode:\n \xe2\x86\x92 217\xe2\x94\x82 raise CalledProcessError(\n 218\xe2\x94\x82 retcode, process.args, output=stdout, stderr=stderr\n 219\xe2\x94\x82 )\n 220\xe2\x94\x82 finally:\n 221\xe2\x94\x82 # None because our context manager __exit__ does not use them.\nRun Code Online (Sandbox Code Playgroud)\nPoetry 从来不会询问我的 SSH 密钥密码。我已经使用 ssh 从命令行测试了通过 git 进行克隆,效果很好。
\n我做错了什么?
\n小智 1
您没有正确指定 git 路径。git clone 和 pip/poetry 要求 GitHub 存储库路径的不同格式,您应该myproj = { git = "git+ssh://git@github.com/myorg/myproj.git" }
这样做,具体来说:
git+ssh:而是由 分隔/。我遇到了同样的问题,尝试直接使用 pip,但 pip 告诉我它找不到我的存储库。修复路径后,我上面写的内容就开始工作了。诗歌并不能真正解释正在发生的事情。
如果你的分支main在 GitHub 上,你还需要通过添加branch="main" 来指定它,否则它会尝试做 master。