0

I have upgrade poetry in my github ci in my tox.ini. My ci have problem. I use zuul. When I use poetry pip install -v poetry==1.1.15. I have no problem But when I use 1.2.0 I have this error :

Invalid PEP 440 version: '3.8.13+'

3.8.13 it's my python version.

I don't understand why I have problem with python version and not the previous version.

pyproject.toml

[tool.poetry]
name = zeus
version = "0.1.0"
description = ***
authors = ***

[tool.poetry.dependencies]
python = "3.8.*"
pandas = "1.4.*"
click = "8.1.*"



[tool.poetry.dev-dependencies]
black = "22.6.*"
flake8 = "5.0.*"
freezegun = "1.2.*"
pre-commit = "2.20.*"
pycodestyle = "2.9.*"
pytest = "7.*"
pylint = "2.14.*"
tox = "3.25.*"
yamllint = "1.27.*"


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

tox.ini

[testenv]
whitelist_externals =
    bash
    poetry

basepython = python3.8

commands_pre =
    bash -c "pip install --upgrade pip"
    bash -c "pip install -q poetry"

    poetry config repositories****
    poetry config http-basic.artifactory ****

    poetry install

[testenv:lint]
description = Run the quality checks
commands =
    poetry run pre-commit run --from-ref origin/master --to-ref HEAD

[testenv:test]
setenv =
    PYTHONPATH = {toxinidir}/app
description = Run the tests
commands =
    poetry run pytest
  • 1
    Related: https://github.com/python-poetry/poetry/issues/6334 – 9769953 Sep 02 '22 at 08:40
  • 1
    Have you searched through all of your project for a string like "3.8.13+"? – 9769953 Sep 02 '22 at 08:41
  • @9769953 Thanks, it's my issue on the poetry github project and yes i search in my project. I have no string 3.8.13+. – jemmy Negatron Sep 02 '22 at 09:09
  • 1
    It might be a dependency that has Python version 3.8.13+ set as a dependency. So you could comment out all (dev) dependencies, then try to install/run your unit tests (they will fail for lack of dependencies). But if you don't get the Poetry error, that could indicate one of the dependency packages is the problem. Then "turn on" the dependencies one by one, until you've found the culprit. – 9769953 Sep 02 '22 at 10:36

1 Answers1

0

There's a couple of unorthodox actions taken in your setup:

  1. The whitelist externals denotes poetry and then in commands_pre you install poetry into the tox virtual env. You should only need one or the other. But rather, I'd recommend the approach documented here. Usecase 1 is closest to what users experience during installation of your package.
  2. You're using a dedicated test environment ([testenv:test]). There's no need, you can simply use the default [testenv] section. Then you can run your testsuite tox -e py38 for python3.8 or any other supported tag (py37, py39, ... source). This also makes the basepython key redundant. And for a much more versatile experience with tox.
  3. Setting PYTHONPATH = {toxinidir}/app is a codesmell to me. If you've configured your pyproject.toml correctly then poetry should know where your code lives (and install it accordingly). There would be no need to set PYTHONPATH. Hence, you probably need to add a section such as:
[tool.poetry]
name = "zeus"
packages = [
    { include = "zeus", from = "app" },
]

Note: that a /src folder is much more common then an /app folder. Which is likely the root cause of you not finding this option. See this answer.

I suspect that if you tackle all these points that your code and its installation will work entirely different possibly solving your issue.

Shine
  • 676
  • 6
  • 12