pypoetry 可以只安装我要求它添加的依赖项吗?

Phi*_*ert 8 python python-poetry

运行时poetry add package,poetry 决定在没有我询问的情况下更新一些过时的依赖项:

\n
$ poetry add -D ipython\nUsing version ^7.26.0 for ipython\n\nUpdating dependencies\nResolving dependencies... (6.8s)\n\nWriting lock file\n\nPackage operations: 13 installs, 2 updates, 0 removals\n\n  \xe2\x80\xa2 Installing ipython-genutils (0.2.0)\n  \xe2\x80\xa2 Installing parso (0.8.2)\n  \xe2\x80\xa2 Installing ptyprocess (0.7.0)\n  \xe2\x80\xa2 Installing traitlets (5.0.5)\n  \xe2\x80\xa2 Installing wcwidth (0.2.5)\n  \xe2\x80\xa2 Installing appnope (0.1.2)\n  \xe2\x80\xa2 Installing backcall (0.2.0)\n  \xe2\x80\xa2 Updating connexion (2.8.0 -> 2.9.0) <---------- "I never asked for this"\n  \xe2\x80\xa2 Installing jedi (0.18.0)\n  \xe2\x80\xa2 Installing matplotlib-inline (0.1.2)\n  \xe2\x80\xa2 Installing pexpect (4.8.0)\n  \xe2\x80\xa2 Installing pickleshare (0.7.5)\n  \xe2\x80\xa2 Installing prompt-toolkit (3.0.19)\n  \xe2\x80\xa2 Installing ipython (7.26.0)\n  \xe2\x80\xa2 Updating ramda (0.6.0 -> 0.6.1) <---------- "I never asked for this"\n
Run Code Online (Sandbox Code Playgroud)\n

然而,当获得该命令的帮助时,似乎没有任何内容表明可以禁用此行为:

\n
$ poetry add --help\nUSAGE\n  poetry add [-D] [-E\xc2\xa0<...>] [--optional] [--python\xc2\xa0<...>]\n             [--platform\xc2\xa0<...>] [--source\xc2\xa0<...>] [--allow-prereleases]\n             [--dry-run] [--lock] <name1> ... [<nameN>]\n\nARGUMENTS\n  <name>                 The packages to add.\n\nOPTIONS\n  -D (--dev)             Add as a development dependency.\n  -E (--extras)          Extras to activate for the dependency.\n                         (multiple values allowed)\n  --optional             Add as an optional dependency.\n  --python               Python version for which the dependency must be\n                         installed.\n  --platform             Platforms for which the dependency must be\n                         installed.\n  --source               Name of the source to use to install the\n                         package.\n  --allow-prereleases    Accept prereleases.\n  --dry-run              Output the operations but do not execute\n                         anything (implicitly enables --verbose).\n  --lock                 Do not perform operations (only update the\n                         lockfile).\n\nGLOBAL OPTIONS\n  -h (--help)            Display this help message\n  -q (--quiet)           Do not output any message\n  -v (--verbose)         Increase the verbosity of messages: "-v" for\n                         normal output, "-vv" for more verbose output and\n                         "-vvv" for debug\n  -V (--version)         Display this application version\n  --ansi                 Force ANSI output\n  --no-ansi              Disable ANSI output\n  -n (--no-interaction)  Do not ask any interactive question\n\n...\n
Run Code Online (Sandbox Code Playgroud)\n

有什么方法可以只安装感兴趣的包吗?\n我不想更新 deps,即使是一个小问题 - dependentabot 已经存在用于此目的。

\n

Sil*_*eri 2

手动添加依赖项pyproject.toml,然后运行poetry lock --no-update,以便将依赖项添加到您的锁定文件中,而无需根据其他包的当前版本规范更新它们。

您还可以将您的所有版本规范锁定pyproject.toml为确切的版本,即0.8.2使用^0.8.2.