Skip to content

Present a warning if user attempts to install a non-existant extra option #2138

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

Closed
derwolfe opened this issue Nov 24, 2014 · 7 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@derwolfe
Copy link
Contributor

Using setuptools' extra_requires option, a user might try to install an option that doesn't exist.

An example being:

pip install "twisted[zorro]" 

Since the zorro option doesn't actually exist in Twisted, pip will just install twisted and then try to install the zorro option. The install will succeed without the user knowing that zorro had no effect on the install.

In speaking with dstufft, it seems like it would be best if pip presented a colorized warning (if the terminal supports it) stating that the requested option doesn't exist.

It also looks like this could be achieved using something like

logger.warn("couldn't find option 'zorro'")
@derwolfe
Copy link
Contributor Author

The more I think about this, the more this seems related to setuptools some how passing an argument on to pip and not pip itself.

@dstufft
Copy link
Member

dstufft commented Nov 24, 2014

pip can install things from Wheels without any involvement of setuptools and it's well positioned to present user facing messages like that anyways.

@dstufft dstufft reopened this Nov 24, 2014
@derwolfe
Copy link
Contributor Author

Sorry for the early closure - I didn't think about Wheels. Thanks for reopening!

@derwolfe
Copy link
Contributor Author

It looks like an error is already thrown from line 2409 in pip/_vendor/pkg_resources.py. It seems like this provides the type of error I was looking for.


    def requires(self, extras=()):
        """List of Requirements needed for this distro if `extras` are used"""
        dm = self._dep_map
        deps = []
        deps.extend(dm.get(None, ()))
        for ext in extras:
            try:
                deps.extend(dm[safe_extra(ext)])
            except KeyError:
                raise UnknownExtra(
                    "%s has no such extra feature %r" % (self, ext)
                )
        return deps

@derwolfe
Copy link
Contributor Author

I also don't remember this being thrown when I was testing on my own, but maybe my memory is failing me.

@derwolfe
Copy link
Contributor Author

dstufft and I discussed this on IRC a bit more.

Currently, if a non existent option is passed in and a single exception is thrown, This means if a user has a list of options like

pip install twisted[zorro, tls]

where tls actually exists; because of zorro failing, the tls option will not be installed.

The implementation of this error should allow for a message to be logged for each of the missing options, ideally the options that cannot be installed will be displayed in a single warning. Options that are installable should be allowed to proceed.

E.g., Let's say twisted only has a TLS option. Bob, a user, tries to

pip install twisted[zorro, tls, superman]

Bob will see the following

Unknown Extra: twisted has no such extra feature zorro
Unknown Extra: twisted has no such extra feature superman

...then all of the messages relating to the successful installation of the tls packages

@dstufft
Copy link
Member

dstufft commented Mar 16, 2015

Closed by #2142

@dstufft dstufft closed this as completed Mar 16, 2015
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

2 participants