Search code examples
pythoncirclecipipenv

Can't make CircleCI work along Python project set through pyproject.toml


I have setup a Python Project with dependencies listed in a pyproject.toml file as explained in PyPI packaging tutorial. Here is pyproject.toml file:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "easypeasy"
version = "0.0.0"

readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.9"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]
dependencies = [
  'pytest',
  'numpy',
]

[project.urls]
"Homepage" = "https://github.com/RandomCraftr/easypeasy"
"Bug Tracker" = "https://github.com/RandomCraftr/easypeasy/issues"

Whatever configuration file I use, CircleCI desperately look for petry section in my pyproject.toml file or look for requirement.txt, which is defintely uselesss given pyproject.toml file.

What should be config.yaml configuration file for this project to enable CircleCI to work ?


Solution

  • After digging documentation, it appears none "orbs" (some kind of pre-defined actions you can import) provided by circleci does the trick off the shelf for pyproject.toml configured project. Hence, I had to start from a blank config.yml to make it happen. Moreover, I had to test both Win and Linux platform. Which leads me to the following.

    • If you want to test your Python package with circleai
    • If your Python package relies exclusively on pyproject.toml definition
    • If you selected pytest testing framework

    Then, the following config.yml file will allow you to make use of circleci CI solution for your package.

    version: 2.1
    jobs:
      buildandtest_linux_latest:
        machine:
          image: ubuntu-2004:current
        resource_class: medium
        steps:
          - checkout
          - run: python3 -m pip install .
          - run: python3 -m pytest
      buildandtest_win_latest:
        machine:
          image: windows-server-2022-gui:current
        resource_class: windows.medium
        steps:
          - checkout
          - run: python -m pip install .
          - run: python -m pytest
    workflows:
      main:
        jobs:
          - buildandtest_linux_latest
          - buildandtest_win_latest