You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 21:54:17