Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tox + Poetry Issues #1163

Closed
adithyabsk opened this issue Feb 11, 2019 · 8 comments
Closed

tox + Poetry Issues #1163

adithyabsk opened this issue Feb 11, 2019 · 8 comments
Labels
area:documentation help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@adithyabsk
Copy link

Simple base project created using:

$ poetry new test
Poetry
Version: 1.0.0a2
Python:  3.6.5

Virtualenv
Python:         3.6.5
Implementation: CPython
Path:           /Users/adithyabalaji/Coding/GeorgianPartners/test/custom
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/adithyabalaji/.pyenv/versions/3.6.5
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Name <email@email.com>"]

[tool.poetry.dependencies]
python = "^3.6"
tensorflow = "^1.13.0-rc1"

[tool.poetry.dev-dependencies]
pytest = "^3.0"
tox = "^3.5.0"

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

[tool.tox]
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py36

[testenv]
whitelist_externals = poetry
commands =
    poetry install -vvv
    poetry run pytest
"""

Error:

  AttributeError: module 'enum' has no attribute 'IntFlag'

Issue

After many hours of trials and tribulations, I am unable to coerce tox to work with poetry. As suggested in the latest poetry and tox documentation, I am using the isolated_build parameter in the tox ini and have found that for some odd reason, tox seems to be using the wrong python version (ie enum34 becomes active) when executing. I have found the same issue when building the project from scratch using poetry using custom virtualenv (pyenv) causes the enum34 error whereas a venv using standard python does not which makes me think the bug is on poetry's end as opposed to tox. I have cross posted the bug report to both projects to hopefully get some help to track this one down.

@gaborbernat
Copy link
Member

gaborbernat commented Feb 11, 2019

Hello,

tox will use by default the same python version tox is installed under to build the package. So your options is either to install tox under python 3.6/3.7 or:

If you need a different python you should specify inside the packaging env accordingly, for example: require 3.6 via

[tox:.package]
basepython=python3.6

Sorry for this causing issues to you we should probably document under https://tox.readthedocs.io/en/latest/example/package.html how to use poetry (that is not python 2 compatible compared to all other build systems).

@gaborbernat gaborbernat changed the title Tox + Poetry Issues tox + Poetry Issues Feb 11, 2019
@gaborbernat gaborbernat added area:documentation help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. labels Feb 11, 2019
@adithyabsk
Copy link
Author

adithyabsk commented Feb 11, 2019

Thank you for the quick response! Hmm, I'm not sure I understand. If I pass the build_isolated parameter, will tox not build the project using multiple python versions as specified? tox is currently installed under python 3.6.5. (I also tried your suggestion just to double check and no dice) It's super quick to reproduce this bug so you can see it for yourself.

$ curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
$ poetry init test
$ # copy and paste the provided toml file
$ poetry lock
$ poetry install -vvv # this works
$ poetry run tox # this does not

@gaborbernat
Copy link
Member

gaborbernat commented Feb 11, 2019

Can you post the output of the tox -rvvv? Furthemore you should also post what python above stands for.

@adithyabsk
Copy link
Author

adithyabsk commented Feb 11, 2019

According to poetry documentation the above python (in the curl install) should be your system python to keep poetry isolated from the rest of the various python versions on your system. A bash_profile (or rc) amendment is made to add the installed poetry to your path exposing the command everywhere. Poetry then uses the various pythons installed on your system (I'm using pyenv) to build virtualenvs in Library/Cache on a mac (not sure on linux) which houses each project's virtual environment. The local python version for the test dir is set to python 3.6.5 (if that is not already you're global python version). I am following that suggested setup to the tee.

$ curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
$ poetry init test
$ # copy and paste the provided toml file
$ pyenv local 3.6.5
$ poetry lock
$ poetry install -vvv # this works
$ poetry run tox -rvvv # this does not

Here are the command outputs that you had requested:
Gist Links

@gaborbernat
Copy link
Member

gaborbernat commented Feb 11, 2019

What pulls in - Installing enum34 (1.1.6), this is the faulty line, as that seems to not have IntFlag.

   1: fact: grpcio (1.18.0) depends on enum34 (>=1.0.4)
   1: selecting grpcio (1.18.0)
   1: derived: enum34 (>=1.0.4)
   1: derived: futures (>=2.2.0)
   1: selecting enum34 (1.1.6)

That was introduced in python 3.6 https://docs.python.org/3/library/enum.html#intflag. Your error is not caused by tox, enum34 should never be installed in python>=3.4, it breaks your interpreter effectively.

  Traceback (most recent call last):
    File "/Users/adithyabalaji/.pyenv/versions/3.6.5/lib/python3.6/runpy.py", line 193, in _run_module_as_main
      "__main__", mod_spec)
    File "/Users/adithyabalaji/.pyenv/versions/3.6.5/lib/python3.6/runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "/Users/adithyabalaji/Coding/GeorgianPartners/test/.tox/py36/lib/python3.6/site-packages/pip/__main__.py", line 16, in <module>
      from pip._internal import main as _main  # isort:skip # noqa
    File "/Users/adithyabalaji/Coding/GeorgianPartners/test/.tox/py36/lib/python3.6/site-packages/pip/_internal/__init__.py", line 4, in <module>
      import locale
    File "/Users/adithyabalaji/Coding/GeorgianPartners/test/.tox/py36/lib/python3.6/locale.py", line 16, in <module>
      import re
    File "/Users/adithyabalaji/Coding/GeorgianPartners/test/.tox/py36/lib/python3.6/re.py", line 142, in <module>
      class RegexFlag(enum.IntFlag):
  AttributeError: module 'enum' has no attribute 'IntFlag'

You probably want to raise a bug to grpcio.

@adithyabsk
Copy link
Author

That makes sense but I'm curious as to why poetry install would work then? Unless I am mistaken does tox not do the same thing expect managing custom venvs for each python version.

@gaborbernat
Copy link
Member

The install works, however would you try to use any module that uses the enum intflag class that would fail at runtime. in the case above pip calls the regex module that blows up because of this. It's a faulty successful install that causes subsequent runtime errors. tox also succeeds creating the virtual environment, but then trying to invoke pip to get information from the environment fails.

@adithyabsk
Copy link
Author

Hmm that makes complete sense, let me see what I can do to prevent it from poetry's end from installing! @gaborbernat, thank you for being so helpful!

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:documentation help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

2 participants