您可以用诗歌管理CDK项目吗?

发布于 2025-02-11 08:39:29 字数 580 浏览 2 评论 0原文

第一次尝试CDK。虽然可以将诗歌用于功能依赖性,但我正在寻找一种使用诗歌来管理CDK项目本身的方法。

遵循本指南: https://docs.aws .amazon.com/cdk/v2/guide/with-with-with-cdk-python.html 设置项目的建议包含以下步骤:

cdk init app --language python
source .venv/bin/activate 
python -m pip install -r requirements.txt

本质上,我希望能够诗歌运行CDK INIT APP-语言Python而不是cdk init需要一个空目录开始。

是否有最好的做法可以将CDK项目完全置于诗歌之下?否则,将TypeScript用于该项目,而Python进行功能是我的下一个最佳选择。

Trying CDK for the first time. While it is possible to use poetry for the function dependencies, I am looking for a way to also manage the CDK project itself using poetry.

Following this guide: https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-python.html
the recommendation to set up a project contains these step:

cdk init app --language python
source .venv/bin/activate 
python -m pip install -r requirements.txt

Essentially, I'd like to be able to poetry run cdk init app --language python instead but cdk init requires an empty directory to begin with.

Is there a best practice to put the cdk project entirely under poetry? Otherwise using Typescript for the project and Python for the functions would be my next best option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿港小镇 2025-02-18 08:39:29

是的,可以做到。我为我开发的每个Python CDK项目都这样做。正如@gshpychka所说,您可以自己创建项目。您也可以让CDK INIT执行此操作,然后删除unignts.txt,然后用pyproject.toml替换它。 readme.md文件也可能需要更新。

这部分不是必需的,但是我也喜欢更新cdk.json,因此诗歌是自动为我执行的。替换:

{
  "app": "python app.py",

与:

{
  "app": "poetry run python app.py",

每次运行CDK合成器cdk部署或任何其他命令时,它都会自动为您使用诗歌。

最后,您可以使用 projen 用诗歌为您生成整个事物。这是非常意见的,但确实包含许多有用的功能,例如计划的GitHub操作以自动更新依赖项,合并等。

npx projen new awscdk-app-py --poetry

Yes, it can be done. I do it for every Python CDK project I develop. As @gshpychka said, you can create the project yourself. You can also let cdk init do its thing and then delete requirements.txt and replace it with pyproject.toml. The README.md file might also need an update.

This part is not required, but I like updating cdk.json as well so Poetry is executed automatically for me. Replace:

{
  "app": "python app.py",

With:

{
  "app": "poetry run python app.py",

That way every time you run cdk synth, cdk deploy or any other command, it will automatically use Poetry for you.

Finally, you can use projen to generate the whole thing for you with Poetry. It is quite opiniated but does include a lot of useful features like scheduled GitHub Actions to update dependencies automatically, mergify, etc.

npx projen new awscdk-app-py --poetry
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文