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

[v2 Downloader] requirements with dotted package names crash the library check #1926

Closed
calebj opened this issue Jul 9, 2018 · 2 comments
Closed

Comments

@calebj
Copy link
Member

calebj commented Jul 9, 2018

Command name

cog install calebj captcha

What cog is this command from?

Downloader

What were you expecting to happen?

Downloader should have pulled in the dependencies like normal using pip before installing the cog.

What actually happened?

Best guess is that since wheezy.captcha is a namespace package with a dot in the PyPI name, it's confusing the check. The wheezy module will import successfully when any subpackages are installed, but there is no package named just wheezy on PyPI. This doesn't happen when the package is already installed.

Exception in command 'cog install'
Traceback (most recent call last):
  File "/data/red/.local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/data/red/cogs/downloader.py", line 397, in _install
    install_cog = await self.install(repo_name, cog, notify_reqs=True)
  File "/data/red/cogs/downloader.py", line 447, in install
    requirements = [r for r in requirements
  File "/data/red/cogs/downloader.py", line 448, in <listcomp>
    if not self.is_lib_installed(r)]
  File "/data/red/cogs/downloader.py", line 530, in is_lib_installed
    return bool(find_spec(name))
  File "/usr/lib/python3.5/importlib/util.py", line 88, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ImportError: No module named 'wheezy'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/data/red/.local/lib/python3.5/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/data/red/.local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 634, in invoke
    yield from ctx.invoked_subcommand.invoke(ctx)
  File "/data/red/.local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/data/red/.local/lib/python3.5/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ImportError: No module named 'wheezy'

How can we reproduce this issue?

  1. Attempt to install Captcha from my cog repo's develop branch
  2. Cry. Cry a lot.
@Twentysix26
Copy link
Member

>>> find_spec("wheezy.captcha")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\...\Python36-32\lib\importlib\util.py", line 88, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'wheezy'

I'm getting a different type of exception. Might be worth catching both?

@calebj
Copy link
Member Author

calebj commented Jul 29, 2018

It's already caught, since ModuleNotFoundError is a subclass of ImportError added in 3.6.

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

2 participants