Skip to content

Conversation

@ChuranNeko
Copy link

@ChuranNeko ChuranNeko commented Nov 7, 2025

映射venv环境文件,避免重复下载依赖

fixes #XYZ


Motivation / 动机

Modifications / 改动点

Verification Steps / 验证步骤

Screenshots or Test Results / 运行截图或测试结果

Compatibility & Breaking Changes / 兼容性与破坏性变更

  • 这是一个破坏性变更 (Breaking Change)。/ This is a breaking change.
  • 这不是一个破坏性变更。/ This is NOT a breaking change.

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Sourcery 总结

改进:

  • ./venv 目录挂载到 compose.yml 中的 /AstrBot/venv,以在容器重启之间缓存虚拟环境
Original summary in English

Summary by Sourcery

Enhancements:

  • Mount ./venv directory into /AstrBot/venv in compose.yml to cache the virtual environment between container restarts

映射venv环境文件,避免重复下载依赖
@auto-assign auto-assign bot requested review from Raven95676 and anka-afk November 7, 2025 06:43
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿,你好!我已经审阅了你的更改,它们看起来很棒!


Sourcery 对开源项目免费 - 如果你喜欢我们的评论,请考虑分享它们 ✨
帮助我更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LIghtJUNction LIghtJUNction self-assigned this Nov 7, 2025
Copy link
Member

@LIghtJUNction LIghtJUNction left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很好

@Raven95676
Copy link
Member

图片

请在v4.5.6中确认.venv是否还存在

@Dt8333
Copy link
Member

Dt8333 commented Nov 8, 2025

我个人用的方法是映射这个

  astrbot:
    volumes:
      - ./pip-cache:/root/.cache/pip

随着python更新,venv可能变动,直接映射或许不是一个好主意。
不如把pip-cache留下,让pip自己拿去用。

个人暂时没有更新Astrbot。目前使用4.5.0。此意见仅供参考。
未测试在使用UV的新版本中是否仍然有效。
理论上UV应当也有类似目录?

以上仅为个人意见和建议。
请谨慎测试采纳。

@ChuranNeko
Copy link
Author

我个人用的方法是映射这个

  astrbot:
    volumes:
      - ./pip-cache:/root/.cache/pip

随着python更新,venv可能变动,直接映射或许不是一个好主意。 不如把pip-cache留下,让pip自己拿去用。

个人暂时没有更新Astrbot。目前使用4.5.0。此意见仅供参考。 未测试在使用UV的新版本中是否仍然有效。 理论上UV应当也有类似目录?

以上仅为个人意见和建议。 请谨慎测试采纳。

回复:
uv是用来管理虚拟环境的一个工具,你不必担心**.venv目录会变动,如果.venv目录不存在uv会读取你的本地的pyproject.toml 随后来安装依赖,所以你办法只使用于未使用uv来管理依赖的一个方法,uv安装依赖(在有pyproject.toml)只会安装至虚拟环境.现有版本貌似因Soulter工作繁忙的原因,将uv换成了python来进行管理

如果后续继续使用uv来管理依赖的建议映射至‘./venv:/AstrBot/.venv’,以此避免重启时反复下载依赖的问题。
总之,你的提议不错,但是要考虑到项目的一些环境问题

@Dt8333
Copy link
Member

Dt8333 commented Nov 8, 2025

回复: uv是用来管理虚拟环境的一个工具,你不必担心 .venv目录会变动,如果 .venv目录不存在uv会读取你的本地的pyproject.toml 随后来安装依赖,所以你办法只使用于未使用uv来管理依赖的一个方法,uv安装依赖(在有pyproject.toml)只会安装至虚拟环境.现有版本貌似因Soulter工作繁忙的原因,将uv换成了python来进行管理

我在担心的是:
venv/pyvenv.cfg下有建立虚拟环境时原始环境的相关信息。
个人在使用venv的时候,遇到过因Python更换大版本,pyvenv.cfg下对应的Python路径变化等导致venv直接不工作的情况。
遇到这种情况似乎只能删除重建venv。不知道有没有什么其他好的解决方案。

所以我在担心,未来Astrbot依赖的Python版本更新后,遗留的先前venv是否会阻碍其正常更新与运行。

如果后续继续使用uv来管理依赖的建议映射至‘./venv:/AstrBot/.venv’,以此避免重启时反复下载依赖的问题。

Caching
这里有有关UV Cache位置的相关信息。
根据这个,将/root/.cache/uv映射到主机目录应当能起到先前提到的pip映射类似效果。
请参考。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants