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

Closed
ThomasHickman opened this issue Jul 18, 2018 · 3 comments

Comments

@ThomasHickman
Copy link

ThomasHickman 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
Copy link
Member

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
Copy link
Author

@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?

joelgrus pushed a commit to allenai/allennlp that referenced this issue Aug 21, 2018
…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
…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
bddppq added a commit to bddppq/onnx that referenced this issue Jul 25, 2019
houseroad pushed a commit to onnx/onnx that referenced this issue Jul 25, 2019
marco-c added a commit to marco-c/pydriller that referenced this issue Aug 1, 2019
It's part of the standard library starting from 3.5.
See python/typing#573.
hariharans29 pushed a commit to hariharans29/onnx that referenced this issue Aug 15, 2019
clearml-bot pushed a commit to allegroai/clearml that referenced this issue Aug 12, 2020
Installing `typing` on recent Python versions leads to the error described in python/typing#573 (running tests with tox yields `AttributeError: type object 'Callable' has no attribute '_abc_registry'`).

The [`typing` readme](https://pypi.org/project/typing/) suggests to install the package only for Python versions <3.5, which this commit does.
jcwchen pushed a commit to jcwchen/onnx that referenced this issue Sep 23, 2020
cco3 added a commit to cco3/commoncode that referenced this issue Nov 18, 2020
Importing typing causes errors after python 3.6.
See python/typing#573
cco3 added a commit to cco3/commoncode that referenced this issue Nov 18, 2020
Importing typing causes errors after python 3.6.
See python/typing#573

Signed-off-by: Conley Owens <cco3@google.com>
pombredanne added a commit to aboutcode-org/scancode-toolkit that referenced this issue Nov 18, 2020
Importing typing causes errors after python 3.6.
See python/typing#573

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
@srittau
Copy link
Collaborator

srittau commented Nov 4, 2021

All supported Python versions now include the typing module, making the backport obsolete. I don't think we need to keep this open.

@srittau srittau closed this as completed Nov 4, 2021
andre-merzky added a commit to andre-merzky/py-pathmatch that referenced this issue Mar 1, 2024
This is related to python/typing#573: `typing`
is now part of the Python standard library.  Adding `typing` as
dependency to modules will lead to the installation a second,
incompatible versions of that module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants