基于pyproject.toml的Python项目CircleCI配置方案问询
适配setuptools管理的pyproject.toml项目的CircleCI配置
你的项目用setuptools通过pyproject.toml管理依赖,CircleCI默认会尝试寻找poetry配置段或requirements.txt,导致适配问题。以下是对应的.circleci/config.yaml配置:
version: 2.1 jobs: build-and-test: docker: - image: cimg/python:3.11 # 选择符合项目requires-python要求的版本(如3.9及以上) steps: - checkout - run: name: 更新pip并安装build依赖 command: | python -m pip install --upgrade pip pip install setuptools>=61.0 wheel - run: name: 安装项目及依赖 command: pip install . - run: name: 运行测试(按需保留) command: pytest
关键说明:
- 选择匹配项目
requires-python的Python镜像,确保环境兼容 - 手动安装build依赖
setuptools和wheel,匹配pyproject.toml中build-system的要求 - 使用
pip install .命令,pip会自动解析pyproject.toml中的dependencies并安装所有依赖,无需依赖requirements.txt或poetry配置 - 测试步骤可根据项目需求添加或移除
内容的提问来源于stack exchange,提问作者RandomCoder
相关产品推荐
相关产品推荐

