使用CDK部署时如何使用pip缓存?

How to use pip cache when deploying using CDK?

每当我 运行 cdk deploy 时,就会出现这样的消息(在上下文中显示):

Bundling asset api/import_status/user-import_status-endpoint-function/Code/Stage...
WARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)

这是一个实际问题吗?如果是这样,我该如何解决? CDK 构建看起来确实很慢,当人们提到 CDK 时,这条消息随处可见(尽管我找不到问这个具体问题的人)。

我通过有效地使用 --cache-dir="$(mktemp --directory)".

解决了这个问题