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

typing_extensions 3.7.4 - Pulls typing dependency if used with python3.7 and poetry #660

Closed
gcarq opened this issue Jul 31, 2019 · 5 comments · Fixed by #661
Closed

typing_extensions 3.7.4 - Pulls typing dependency if used with python3.7 and poetry #660

gcarq opened this issue Jul 31, 2019 · 5 comments · Fixed by #661

Comments

@gcarq
Copy link
Contributor

gcarq commented Jul 31, 2019

typing_extensions has a conditional check if typing should be pulled in depending on the python version, although in https://pypi.org/pypi/typing-extensions/json its specified as required dependency.

That leads to the following exception if used with python3.7:

  Traceback (most recent call last):                                          
    File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_ma  
in                                                                            
      "__main__", mod_spec)                                                   
    File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code           
      exec(code, run_globals)                                                 
    File "/usr/local/lib/python3.7/site-packages/pip/__main__.py", line 16,   
in <module>                                                                   
      from pip._internal import main as _main  # isort:skip # noqa            
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/__init__.py",  
 line 40, in <module>                                                         
      from pip._internal.cli.autocompletion import autocomplete               
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/autocompl  
etion.py", line 8, in <module>                                                
      from pip._internal.cli.main_parser import create_main_parser            
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main_pars  
er.py", line 7, in <module>                                                   
      from pip._internal.cli import cmdoptions                                
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/cmdoption  
s.py", line 24, in <module>                                                   
      from pip._internal.models.search_scope import SearchScope               
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/models/search  
_scope.py", line 11, in <module>                                              
      from pip._internal.utils.misc import normalize_path, redact_password_f  
rom_url                                                                       
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/utils/misc.py  
", line 58, in <module>                                                       
      from typing import cast, Tuple                                          
    File "/usr/local/lib/python3.7/site-packages/typing.py", line 1357, in <  
module>                                                                       
      class Callable(extra=collections_abc.Callable, metaclass=CallableMeta)  
:                                                                             
    File "/usr/local/lib/python3.7/site-packages/typing.py", line 1005, in _  
_new__                                                                        
      self._abc_registry = extra._abc_registry                                
  AttributeError: type object 'Callable' has no attribute '_abc_registry'   

Poetry does not execute the setup.py file for security reasons so it can't see it and if you take a look at https://pypi.org/pypi/typing-extensions/json you will see in the info.requires_dist section that typing is declared as an unconditional dependency.

Using a environment marker instead should fix this:

install_requires = ["typing >= 3.7.4; python_version < '3.5'"]

Related poetry issue: python-poetry/poetry#1258

@gvanrossum
Copy link
Member

I cannot repro this. I don't know what poetry is -- perhaps the problem is due to poetry? When I install typing_extensions using pip in python3.7 I do not get this error. Note that pip doesn't execute setup.py either, it gets the info from the wheels.

Nevertheless if you think you have a solution, please submit a PR (put "fixes #660" in the body of the commit message) and we'll see what we can do.

@wesinator
Copy link

I started getting this error trying to install local package with pip:

typing 3.7.4 updated to typing-3.7.4.1
pip 20.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
python 3.7.7 homebrew
macOS 10.14.6

$ pip install --user .
Processing <project>
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/kx/3n56qwpd1flgsv6mhg6n7_jr0000gn/T/pip-build-env-pd6snuqs/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (44 lines):
  Traceback (most recent call last):
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
      "__main__", mod_spec)
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "/usr/local/lib/python3.7/site-packages/pip/__main__.py", line 26, in <module>
      sys.exit(_main())
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
      command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
      module = importlib.import_module(module_path)
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 16, in <module>
      from pip._internal.index.package_finder import PackageFinder
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 21, in <module>
      from pip._internal.index.collector import parse_links
    File "/usr/local/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 14, in <module>
      from pip._vendor import html5lib, requests
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/requests/__init__.py", line 114, in <module>
      from . import utils
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/requests/utils.py", line 25, in <module>
      from . import certs
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/requests/certs.py", line 15, in <module>
      from pip._vendor.certifi import where
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/certifi/__init__.py", line 1, in <module>
      from .core import contents, where
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/certifi/core.py", line 12, in <module>
      from importlib.resources import read_text
    File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/resources.py", line 11, in <module>
      from typing import Iterable, Iterator, Optional, Set, Union   # noqa: F401
    File "/usr/local/lib/python3.7/site-packages/typing.py", line 1357, in <module>
      class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
    File "/usr/local/lib/python3.7/site-packages/typing.py", line 1005, in __new__
      self._abc_registry = extra._abc_registry
  AttributeError: type object 'Callable' has no attribute '_abc_registry'
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/python/bin/python3.7 /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/kx/3n56qwpd1flgsv6mhg6n7_jr0000gn/T/pip-build-env-pd6snuqs/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.

Installing with python3 setup.py install --user --prefix= works

@gvanrossum
Copy link
Member

gvanrossum commented May 8, 2020 via email

@JelleZijlstra
Copy link
Member

One suspicious thing is that typing is in site-packages. It should be in the stdlib in 3.7.

@wesinator
Copy link

One suspicious thing is that typing is in site-packages. It should be in the stdlib in 3.7.

Thanks - pip uninstall typing typing-extensions fixed it
not sure what dependency installed it there to begin with

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

Successfully merging a pull request may close this issue.

4 participants