简体   繁体   中英

How to setup multiple interpreters in CircleCI using Tox and Poetry?

I'm setting up a reusable package for Django. I'm using Poetry as the package manager and I'm using tox for testing across multiple python environments. However, I keep on receiving the following error on CircleCI:

py27-django111: commands succeeded
ERROR:  py34-django111: InterpreterNotFound: python3.4
ERROR:  py34-django20: InterpreterNotFound: python3.4
ERROR:  py34-django21: InterpreterNotFound: python3.4
  py35-django111: commands succeeded
  py35-django20: commands succeeded
  py35-django21: commands succeeded
  py36-django111: commands succeeded
  py36-django20: commands succeeded
  py36-django21: commands succeeded
ERROR:  py37-django111: InterpreterNotFound: python3.7
ERROR:  py37-django20: InterpreterNotFound: python3.7
ERROR:  py37-django21: InterpreterNotFound: python3.7

I couldn't find any reports on how to solve this issue and I've seen different Django package projects in CircleCI however they differ on their approaches to build the environments.

My circle.yml file:

version: 2

jobs:
  development:
    docker:
      - image: circleci/python:3.6.8

    steps:
      - checkout
      - run:
          name: Install
          command: |
            poetry install
      - run:
         name: Lint
         command: |
            poetry run flake8 django_package
      - run:
          name: Test
          command: |
            poetry run tox
      - run:
         name: Codecov
         command: |
            poetry run codecov

  deployment:
      docker:
        - image: circleci/python:3.6.8

      steps:
        - checkout
        - run:
            name: Publish
            command: |
              poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction

workflows:
  version: 2

  development-workflow:
    jobs:
      - development

  deployment-workflow:
    jobs:
      - development:
          filters:
            tags:
              only: /v[0-9]+(\.[0-9]+)*/
            branches:
              ignore: /.*/
      - deployment:
          requires:
            - development
          filters:
              tags:
                only: /v[0-9]+(\.[0-9]+)*/
              branches:
                ignore: /.*/

My tox.ini file:

[tox]
skipsdist = True
envlist =
  {py27}-django{111}
  {py34,py35,py36,py37}-django{111,20,21}

[testenv]
whitelist_externals = poetry
skip_install = true
commands =
    poetry run coverage run --branch runtests.py tests

deps =
  django111: Django>=1.11,<2.0
  django20: Django>=2.0,<2.1
  django21: Django>=2.1

My pyproject.toml file:

[tool.poetry.dependencies]
python = "*"
django = "*"

[tool.poetry.dev-dependencies]
coverage = "^4.5"
codecov = "^2.0"
flake8 = "^3.7"
tox = "^3.7"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

I found that in order to run python 3.4 and 3.7 on CircleCI using Tox, one should add py340 and py370 instead of py34 and py37. Go figure!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM