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

Fail to import typing while running test which runs process which imports typing from setup.py with pytest in python 3.7 #573

Open
ThomasHickman opened this issue Jul 18, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ThomasHickman
Copy link

commented Jul 18, 2018

setup.py

from setuptools import setup

setup(
    setup_requires=['pytest-runner'],
    install_requires=[
        'typing',
        "pytest"
    ]
)

test_test.py

import subprocess

subprocess.check_call(["python", "-c", "import typing"])
$ docker run --rm -it -w /pwd -v $(pwd):/pwd python:3.7 python setup.py pytest
running pytest
Searching for pytest
Best match: pytest 3.6.3
Processing pytest-3.6.3-py3.7.egg

Using /pwd/.eggs/pytest-3.6.3-py3.7.egg
Searching for typing
Best match: typing 3.6.4
Processing typing-3.6.4-py3.7.egg

Using /pwd/.eggs/typing-3.6.4-py3.7.egg
Searching for six>=1.10.0
Best match: six 1.11.0
Processing six-1.11.0-py3.7.egg

Using /pwd/.eggs/six-1.11.0-py3.7.egg
Searching for py>=1.5.0
Best match: py 1.5.4
Processing py-1.5.4-py3.7.egg

Using /pwd/.eggs/py-1.5.4-py3.7.egg
Searching for pluggy<0.7,>=0.5
Best match: pluggy 0.6.0
Processing pluggy-0.6.0-py3.7.egg

Using /pwd/.eggs/pluggy-0.6.0-py3.7.egg
Searching for more-itertools>=4.0.0
Best match: more-itertools 4.2.0
Processing more_itertools-4.2.0-py3.7.egg

Using /pwd/.eggs/more_itertools-4.2.0-py3.7.egg
Searching for attrs>=17.4.0
Best match: attrs 18.1.0
Processing attrs-18.1.0-py3.7.egg

Using /pwd/.eggs/attrs-18.1.0-py3.7.egg
Searching for atomicwrites>=1.0
Best match: atomicwrites 1.1.5
Processing atomicwrites-1.1.5-py3.7.egg

Using /pwd/.eggs/atomicwrites-1.1.5-py3.7.egg
running egg_info
writing UNKNOWN.egg-info/PKG-INFO
writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
writing requirements to UNKNOWN.egg-info/requires.txt
writing top-level names to UNKNOWN.egg-info/top_level.txt
reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
running build_ext
============================================ test session starts ============================================
platform linux -- Python 3.7.0, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /pwd, inifile:
collected 0 items / 1 errors

================================================== ERRORS ===================================================
____________________________________ ERROR collecting tests/test_test.py ____________________________________
tests/test_test.py:3: in <module>
    subprocess.check_call(["python", "-c", "import typing"])
/usr/local/lib/python3.7/subprocess.py:328: in check_call
    raise CalledProcessError(retcode, cmd)
E   subprocess.CalledProcessError: Command '['python', '-c', 'import typing']' returned non-zero exit status 1.
---------------------------------------------- Captured stderr ----------------------------------------------
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/pwd/.eggs/typing-3.6.4-py3.7.egg/typing.py", line 1347, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/pwd/.eggs/typing-3.6.4-py3.7.egg/typing.py", line 1003, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================== 1 error in 0.59 seconds ==========================================

I've used docker, to make this error more reproducible but this errors outside docker as well

@ThomasHickman ThomasHickman changed the title Fail to import typing while running test which runs process which imports typing from setup.py with pytest in python 2.7 Fail to import typing while running test which runs process which imports typing from setup.py with pytest in python 3.7 Jul 18, 2018

@JelleZijlstra

This comment has been minimized.

Copy link
Contributor

commented Jul 18, 2018

You don't need to install the backport on 3.7, because typing is in the standard library since 3.5. I suspect you need a requirement like 'typing; python_version < '3.5'.

@ThomasHickman

This comment has been minimized.

Copy link
Author

commented Jul 19, 2018

@JelleZijlstra, that would work, thanks. It would be nice if this worked using this backport anyway, if this backport is installed by a package not under my control.

Also, if it is not suggested for people to install this backport under newer versions of python, should there be a warning on installation of this package with newer versions of python?

MartinoMensio added a commit to MartinoMensio/allennlp that referenced this issue Aug 21, 2018

typing is part of standard library from python3.6
installing it on python3.7 causes AttributeError: type object 'Callable' has no attribute '_abc_registry'
refers allenai#1457 and python/typing/issues/573

joelgrus added a commit to allenai/allennlp that referenced this issue Aug 21, 2018

typing is part of standard library from python3.6 (gives errors on py…
…thon3.7) (#1638)

* typing is part of standard library from python3.6
installing it on python3.7 causes AttributeError: type object 'Callable' has no attribute '_abc_registry'
refers #1457 and python/typing/issues/573

* remove typing backport because is part of python3.6 natively and allennlp requires python3.6

gabrielStanovsky pushed a commit to gabrielStanovsky/allennlp that referenced this issue Sep 7, 2018

typing is part of standard library from python3.6 (gives errors on py…
…thon3.7) (allenai#1638)

* typing is part of standard library from python3.6
installing it on python3.7 causes AttributeError: type object 'Callable' has no attribute '_abc_registry'
refers allenai#1457 and python/typing/issues/573

* remove typing backport because is part of python3.6 natively and allennlp requires python3.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.