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

warn user when requested extra does not exist - 2138 #2142

Merged
merged 30 commits into from Mar 16, 2015

Conversation

Projects
None yet
6 participants
@derwolfe
Contributor

derwolfe commented Nov 26, 2014

Working on adding loggers for the pkg_resources.UnknonwExtra exception that can be thrown when a user attempts to install an unknown extra.

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Nov 26, 2014

Contributor

This is in reference to issue #2138

Contributor

derwolfe commented Nov 26, 2014

This is in reference to issue #2138

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Nov 26, 2014

Member

I'm actually confused a little bit about how this is working right now. It appears that pip install requests[nonexistent] fails right now because it installs from a Wheel, but pip install --no-use-wheel requests[nonexistant] doesn't fail from an sdist (and doesn't print any kind of message either).

Since this code looks like it takes a failure and turns it into a warning I'm guessing that this is only going to take affect for Wheel installs. It would be great to unify this so that we raise the same warning in both cases.

Member

dstufft commented Nov 26, 2014

I'm actually confused a little bit about how this is working right now. It appears that pip install requests[nonexistent] fails right now because it installs from a Wheel, but pip install --no-use-wheel requests[nonexistant] doesn't fail from an sdist (and doesn't print any kind of message either).

Since this code looks like it takes a failure and turns it into a warning I'm guessing that this is only going to take affect for Wheel installs. It would be great to unify this so that we raise the same warning in both cases.

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Nov 26, 2014

Contributor

Sorry about that dstufft, I meant to put a label on the PR that this was in progress. In effect, this PR doesn't do anything right now.

I mainly made the PR so that I could use travis.

Contributor

derwolfe commented Nov 26, 2014

Sorry about that dstufft, I meant to put a label on the PR that this was in progress. In effect, this PR doesn't do anything right now.

I mainly made the PR so that I could use travis.

@derwolfe derwolfe changed the title from Extras user warn 2138 to Extras user warn 2138 - WIP Nov 26, 2014

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Dec 16, 2014

Contributor

@derwolfe: Are you planning to update this?

Contributor

msabramo commented Dec 16, 2014

@derwolfe: Are you planning to update this?

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Dec 16, 2014

Contributor

@msabramo - yes, I am planning on working on it this week before Friday.

Contributor

derwolfe commented Dec 16, 2014

@msabramo - yes, I am planning on working on it this week before Friday.

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Dec 19, 2014

Contributor

This is related to PR #2153. Once it lands, the job of this PR will (should) be very simple to implement. Most of the legwork is really done by the pkg_resources.Distribution.requires() function, which that PR enables for non-wheel installs.

Contributor

derwolfe commented Dec 19, 2014

This is related to PR #2153. Once it lands, the job of this PR will (should) be very simple to implement. Most of the legwork is really done by the pkg_resources.Distribution.requires() function, which that PR enables for non-wheel installs.

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Dec 20, 2014

Contributor

Sine PR #2153 has landed, tbis should be pretty simple to implement. I'm on vacation now, but I will be able to start working on this again on Dec 28.

Contributor

derwolfe commented Dec 20, 2014

Sine PR #2153 has landed, tbis should be pretty simple to implement. I'm on vacation now, but I will be able to start working on this again on Dec 28.

derwolfe added some commits Dec 30, 2014

logging working a bit better
Need to access the extras defined on the distribution itself. This way I could just check for membership in the set of extras defined, and throw an error for each, instead of stopping entirely.
@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Jan 7, 2015

Contributor

Still working on this, albeit very slowly. I've rebased against develop so the #2153 changes are included.

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.

In my mind the correct behaviour should be: try to install every option, if the option doesn't exist, log it, and move on to the next. @dstufft: does this proposed behaviour seem reasonable to you?

Contributor

derwolfe commented Jan 7, 2015

Still working on this, albeit very slowly. I've rebased against develop so the #2153 changes are included.

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.

In my mind the correct behaviour should be: try to install every option, if the option doesn't exist, log it, and move on to the next. @dstufft: does this proposed behaviour seem reasonable to you?

@derwolfe derwolfe changed the title from Extras user warn 2138 - WIP to warn user when requested extra does not exist - 2138 - WIP Feb 24, 2015

derwolfe added some commits Feb 26, 2015

remove assignement
iterate directly over the results of the function calls

@derwolfe derwolfe changed the title from warn user when requested extra does not exist - 2138 - WIP to warn user when requested extra does not exist - 2138 Feb 26, 2015

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Feb 26, 2015

Contributor

Ready for review :-).

Contributor

derwolfe commented Feb 26, 2015

Ready for review :-).

Show outdated Hide outdated pip/req/req_set.py Outdated
Show outdated Hide outdated pip/req/req_set.py Outdated
@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Feb 26, 2015

Contributor

I've integrated @xavfernandez's suggested changes into the patch.
It looks like travis only failed due to a connection error installing dependencies.

If anyone can restart the build, it is ready for re-review.

Contributor

derwolfe commented Feb 26, 2015

I've integrated @xavfernandez's suggested changes into the patch.
It looks like travis only failed due to a connection error installing dependencies.

If anyone can restart the build, it is ready for re-review.

Show outdated Hide outdated pip/req/req_set.py Outdated
@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Mar 11, 2015

Contributor

@msabramo - thanks for your comments. I've made the changes you requested.

Contributor

derwolfe commented Mar 11, 2015

@msabramo - thanks for your comments. I've made the changes you requested.

@rbu

This comment has been minimized.

Show comment
Hide comment
@rbu

rbu Mar 12, 2015

Also fixes #852 ?

rbu commented Mar 12, 2015

Also fixes #852 ?

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor

Nice.

$ pip install 'bpython[nonexistent]'
Collecting bpython[nonexistent]
  Using cached bpython-0.14.1-py2.py3-none-any.whl
  bpython 0.14.1 does not provide the extra 'nonexistent'
...

$ pip install --no-use-wheel 'bpython[nonexistent]'
Requirement already satisfied (use --upgrade to upgrade): bpython[nonexistent] in /Users/marca/python/virtualenvs/pip/lib/python2.7/site-packages
  bpython 0.14.1 does not provide the extra 'nonexistent'

It's nice that it's a warning instead of a fatal error with a traceback.

I did run into a problem where it couldn't figure out the name of the package when I tried it with sentry (the example in #852):

$ pip install -U 'sentry[lol]'
...
  Unknown 7.4.1 does not provide the extra 'lol'

Note how it say "Unknown" instead of "sentry".

Although to be fair, the current code on develop has the same problem:

$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
  Exception:
  Traceback (most recent call last):
    File "/Users/marca/dev/git-repos/pip/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
    File "/Users/marca/dev/git-repos/pip/pip/commands/install.py", line 342, in run
      requirement_set.prepare_files(finder)
    File "/Users/marca/dev/git-repos/pip/pip/req/req_set.py", line 427, in prepare_files
      req_to_install.extras):
    File "/Users/marca/dev/git-repos/pip/pip/_vendor/pkg_resources/__init__.py", line 2504, in requires
      "%s has no such extra feature %r" % (self, ext)
  UnknownExtra: Unknown 7.4.1 has no such extra feature 'lol'
Contributor

msabramo commented Mar 12, 2015

Nice.

$ pip install 'bpython[nonexistent]'
Collecting bpython[nonexistent]
  Using cached bpython-0.14.1-py2.py3-none-any.whl
  bpython 0.14.1 does not provide the extra 'nonexistent'
...

$ pip install --no-use-wheel 'bpython[nonexistent]'
Requirement already satisfied (use --upgrade to upgrade): bpython[nonexistent] in /Users/marca/python/virtualenvs/pip/lib/python2.7/site-packages
  bpython 0.14.1 does not provide the extra 'nonexistent'

It's nice that it's a warning instead of a fatal error with a traceback.

I did run into a problem where it couldn't figure out the name of the package when I tried it with sentry (the example in #852):

$ pip install -U 'sentry[lol]'
...
  Unknown 7.4.1 does not provide the extra 'lol'

Note how it say "Unknown" instead of "sentry".

Although to be fair, the current code on develop has the same problem:

$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
  Exception:
  Traceback (most recent call last):
    File "/Users/marca/dev/git-repos/pip/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
    File "/Users/marca/dev/git-repos/pip/pip/commands/install.py", line 342, in run
      requirement_set.prepare_files(finder)
    File "/Users/marca/dev/git-repos/pip/pip/req/req_set.py", line 427, in prepare_files
      req_to_install.extras):
    File "/Users/marca/dev/git-repos/pip/pip/_vendor/pkg_resources/__init__.py", line 2504, in requires
      "%s has no such extra feature %r" % (self, ext)
  UnknownExtra: Unknown 7.4.1 has no such extra feature 'lol'
@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor
$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
processing ~/.pdbrc.py
[5] > /Users/marca/dev/git-repos/pip/pip/_vendor/pkg_resources/__init__.py(2504)requires()
-> raise UnknownExtra(
(Pdb++) list 2504, 3
2504 ->                  raise UnknownExtra(
2505                       "%s has no such extra feature %r" % (self, ext)
2506                   )
2507           return deps
(Pdb++) self
Unknown 7.4.1 (/private/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/pip-build-zo2eu1/sentry/pip-egg-info/sentry.egg-info)
Contributor

msabramo commented Mar 12, 2015

$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
processing ~/.pdbrc.py
[5] > /Users/marca/dev/git-repos/pip/pip/_vendor/pkg_resources/__init__.py(2504)requires()
-> raise UnknownExtra(
(Pdb++) list 2504, 3
2504 ->                  raise UnknownExtra(
2505                       "%s has no such extra feature %r" % (self, ext)
2506                   )
2507           return deps
(Pdb++) self
Unknown 7.4.1 (/private/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/pip-build-zo2eu1/sentry/pip-egg-info/sentry.egg-info)
@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor

OK, I think I found a fix for the above issue. I'll file a separate PR for it.

Contributor

msabramo commented Mar 12, 2015

OK, I think I found a fix for the above issue. I'll file a separate PR for it.

@derwolfe

This comment has been minimized.

Show comment
Hide comment
@derwolfe

derwolfe Mar 12, 2015

Contributor

@msabramo - Great! When that error is fixed, some of my new tests can be updated as well.

Contributor

derwolfe commented Mar 12, 2015

@msabramo - Great! When that error is fixed, some of my new tests can be updated as well.

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor

Here's the PR I mentioned: #2530

Contributor

msabramo commented Mar 12, 2015

Here's the PR I mentioned: #2530

@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor

If I merge the change here with the change in #2530:

$ git log -n 1
commit 631a1827806822875862db520deaf2460cd60c5d
Merge: 97b03f4 a12ecdf
Author: Marc Abramowitz <marc@marc-abramowitz.com>
Date:   Thu Mar 12 12:57:57 2015 -0700

    Merge branch 'get_dist_handle_when_egg_info_path_has_trailing_slash' into pr_2142_get_dist

then I get correct behavior:

$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
  sentry 7.4.1 does not provide the extra 'lol'
...
Contributor

msabramo commented Mar 12, 2015

If I merge the change here with the change in #2530:

$ git log -n 1
commit 631a1827806822875862db520deaf2460cd60c5d
Merge: 97b03f4 a12ecdf
Author: Marc Abramowitz <marc@marc-abramowitz.com>
Date:   Thu Mar 12 12:57:57 2015 -0700

    Merge branch 'get_dist_handle_when_egg_info_path_has_trailing_slash' into pr_2142_get_dist

then I get correct behavior:

$ pip install -U 'sentry[lol]'
Collecting sentry[lol]
  Using cached sentry-7.4.1.tar.gz
  sentry 7.4.1 does not provide the extra 'lol'
...
@msabramo

This comment has been minimized.

Show comment
Hide comment
@msabramo

msabramo Mar 12, 2015

Contributor

Also fixes #852 ?

Yes. I believe it does.

Contributor

msabramo commented Mar 12, 2015

Also fixes #852 ?

Yes. I believe it does.

dstufft added a commit that referenced this pull request Mar 16, 2015

Merge pull request #2142 from derwolfe/extras-user-warn-2138
warn user when requested extra does not exist - 2138

@dstufft dstufft merged commit cccefe1 into pypa:develop Mar 16, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment