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

Import aliases for Debian #2567

Merged
merged 2 commits into from Oct 5, 2015

Conversation

Projects
None yet
@untitaker
Contributor

untitaker commented Apr 24, 2015

Alternative to #2375, on the risk of being naive...

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Apr 24, 2015

Member

@sigmavirus24 You own this logic for the most part: how does this look?

Member

Lukasa commented Apr 24, 2015

@sigmavirus24 You own this logic for the most part: how does this look?

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Apr 24, 2015

Contributor

Also I suppose it'd be nice if @dcramer tries this (because of #2558)

Contributor

untitaker commented Apr 24, 2015

Also I suppose it'd be nice if @dcramer tries this (because of #2558)

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Apr 24, 2015

Member

It looks okay but I want to toy with it a bit before we merge it.

Member

sigmavirus24 commented Apr 24, 2015

It looks okay but I want to toy with it a bit before we merge it.

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Apr 24, 2015

Contributor

If you're fine with this, I'd like to add a module docstring (or comment) that explains the whole situation before merging.

Contributor

untitaker commented Apr 24, 2015

If you're fine with this, I'd like to add a module docstring (or comment) that explains the whole situation before merging.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Apr 24, 2015

Member

@untitaker why not just add it while I'm testing it?

Member

sigmavirus24 commented Apr 24, 2015

@untitaker why not just add it while I'm testing it?

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Apr 24, 2015

Contributor

I just meant to say that so you don't merge this too soon.

Contributor

untitaker commented Apr 24, 2015

I just meant to say that so you don't merge this too soon.

@dcramer

This comment has been minimized.

Show comment
Hide comment
@dcramer

dcramer Apr 24, 2015

From my POV this seems safe. @mitsuhiko might have better feedback

dcramer commented Apr 24, 2015

From my POV this seems safe. @mitsuhiko might have better feedback

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol May 3, 2015

Contributor

@untitaker thanks for working on this. Just for reference, here is what it's used in Debian at the moment:
https://anonscm.debian.org/viewvc/python-modules/packages/requests/trunk/debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch?revision=32576&view=markup

Yes, I'm exporting only urllib3 since importing chardet from requests.packages seems not used, at least no one complained about this.

I choosed to not cherry pick #2375 due the problems emerged: I don't want Debian and Ubuntu users to have a system version of requests not in the best shape: it will give only more problems.

Contributor

eriol commented May 3, 2015

@untitaker thanks for working on this. Just for reference, here is what it's used in Debian at the moment:
https://anonscm.debian.org/viewvc/python-modules/packages/requests/trunk/debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch?revision=32576&view=markup

Yes, I'm exporting only urllib3 since importing chardet from requests.packages seems not used, at least no one complained about this.

I choosed to not cherry pick #2375 due the problems emerged: I don't want Debian and Ubuntu users to have a system version of requests not in the best shape: it will give only more problems.

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker May 4, 2015

Contributor

Seems good @eriol. Would you adopt a solution offered by requests though, to avoid Distro-specific breakage?

BTW @sigmavirus24 this is ready for review.

Contributor

untitaker commented May 4, 2015

Seems good @eriol. Would you adopt a solution offered by requests though, to avoid Distro-specific breakage?

BTW @sigmavirus24 this is ready for review.

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol May 4, 2015

Contributor

@untitaker of course I will like to drop a custom patch! 😄
I had to write more to explain better my opinion, sorry for this. My opinion is that less divergence from upstream is the better, and it's for this reason that I forward all modification non Distro-specific to upstream.
Furthermore the Debian patch is not perfect, see Debian Bug #771349.
So to recap I will be extremely happy to drop 04_make-requests.packages.urllib3-same-as-urllib3.patch in favor of an upstream solution.
Thanks!

Contributor

eriol commented May 4, 2015

@untitaker of course I will like to drop a custom patch! 😄
I had to write more to explain better my opinion, sorry for this. My opinion is that less divergence from upstream is the better, and it's for this reason that I forward all modification non Distro-specific to upstream.
Furthermore the Debian patch is not perfect, see Debian Bug #771349.
So to recap I will be extremely happy to drop 04_make-requests.packages.urllib3-same-as-urllib3.patch in favor of an upstream solution.
Thanks!

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 May 9, 2015

Member

This works well for me. Objections to merging @Lukasa?

Member

sigmavirus24 commented May 9, 2015

This works well for me. Objections to merging @Lukasa?

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa May 10, 2015

Member

@sigmavirus24 I'm super reluctant to rush this out, given the way stuff previously went. Can we try to tap people who've had problems/objections in the past and get them to confirm that this works better for them?

Member

Lukasa commented May 10, 2015

@sigmavirus24 I'm super reluctant to rush this out, given the way stuff previously went. Can we try to tap people who've had problems/objections in the past and get them to confirm that this works better for them?

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker May 10, 2015

Contributor

I'll try to reach mitsuhiko

Contributor

untitaker commented May 10, 2015

I'll try to reach mitsuhiko

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 May 10, 2015

Member

@untitaker did you mean @mitsuhiko? I would hope a direct ping would suffice.


@Lukasa I would argue this is probably, on the whole, better than our previous meta_path hackery for several reasons:

  1. It provides the same functionality

  2. It's significantly simpler (simple is better than complex)

  3. It allows for all of this to work in the case where requests is vendored without its vendored dependencies (see @untitaker's use of __name__ when adding the alias to sys.modules)

  4. It doesn't mess with other meta_path plugins (e.g., PyInstaller, the hack that @dcramer and @mitsuhiko are using, etc.)

  5. It falls back in the correct order

  6. It's far easier to explain to someone

  7. When urllib3 is not vendored, the following works as we'd like it to:

    import urllib3
    from requests.packages import urllib3 as rurllib3
    urllib3 is rurllib3

I have yet to test this with PyInstaller, but the root of the problem there was the fact that our meta_path plugin was in the wrong place relative to the multiple plugins that PyInstaller uses. So with that removed, this should just work. I'm also confident that if @mitsuhiko and @dcramer test this with their code that hacks the meta_path, then they'll not see any problems.

Member

sigmavirus24 commented May 10, 2015

@untitaker did you mean @mitsuhiko? I would hope a direct ping would suffice.


@Lukasa I would argue this is probably, on the whole, better than our previous meta_path hackery for several reasons:

  1. It provides the same functionality

  2. It's significantly simpler (simple is better than complex)

  3. It allows for all of this to work in the case where requests is vendored without its vendored dependencies (see @untitaker's use of __name__ when adding the alias to sys.modules)

  4. It doesn't mess with other meta_path plugins (e.g., PyInstaller, the hack that @dcramer and @mitsuhiko are using, etc.)

  5. It falls back in the correct order

  6. It's far easier to explain to someone

  7. When urllib3 is not vendored, the following works as we'd like it to:

    import urllib3
    from requests.packages import urllib3 as rurllib3
    urllib3 is rurllib3

I have yet to test this with PyInstaller, but the root of the problem there was the fact that our meta_path plugin was in the wrong place relative to the multiple plugins that PyInstaller uses. So with that removed, this should just work. I'm also confident that if @mitsuhiko and @dcramer test this with their code that hacks the meta_path, then they'll not see any problems.

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker May 10, 2015

Contributor
Contributor

untitaker commented May 10, 2015

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa May 10, 2015

Member

@sigmavirus24 I'm not disputing better at all. =) What I'd like to do is to take all reasonable precautions to reduce the risk of deploying this fix. For example, can @eriol and @ralphbean confirm that their package building functions correctly with this patch?

Basically, rushing helps nobody, and I'd like to try to begin a run of stable requests releases if at all possible. The last run of four-or-five broken releases in a row is bad, and we need to not get in the habit of doing that.

Member

Lukasa commented May 10, 2015

@sigmavirus24 I'm not disputing better at all. =) What I'd like to do is to take all reasonable precautions to reduce the risk of deploying this fix. For example, can @eriol and @ralphbean confirm that their package building functions correctly with this patch?

Basically, rushing helps nobody, and I'd like to try to begin a run of stable requests releases if at all possible. The last run of four-or-five broken releases in a row is bad, and we need to not get in the habit of doing that.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 May 10, 2015

Member

@Lukasa Note that I'm not arguing for this to be merged with a release to follow immediately after. We could even defer this to 3.0 if you want to not rush it (which I don't think we're doing frankly). The current state of affairs only makes end users' lives more difficult at this point.

Member

sigmavirus24 commented May 10, 2015

@Lukasa Note that I'm not arguing for this to be merged with a release to follow immediately after. We could even defer this to 3.0 if you want to not rush it (which I don't think we're doing frankly). The current state of affairs only makes end users' lives more difficult at this point.

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol May 12, 2015

Contributor

@Lukasa if is it possible I would like to have a bit more of time: right now I'm checking reverse dependencies of requests in Debian to not break stuff, see: https://lists.debian.org/debian-python/2015/05/msg00021.html (@sigmavirus24 thanks for details, I did not have time to reply on the list, but your mail was appreciated 😄).
I should finish during this week, so should be able to cherry pick and test this immediately after.

Contributor

eriol commented May 12, 2015

@Lukasa if is it possible I would like to have a bit more of time: right now I'm checking reverse dependencies of requests in Debian to not break stuff, see: https://lists.debian.org/debian-python/2015/05/msg00021.html (@sigmavirus24 thanks for details, I did not have time to reply on the list, but your mail was appreciated 😄).
I should finish during this week, so should be able to cherry pick and test this immediately after.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 May 12, 2015

Member

@eriol always happy to help. We don't have a release planned so we don't have a timeline for when this would be merged. Take your time. Don't stress out. We'll be here and so will the patch. =D

Member

sigmavirus24 commented May 12, 2015

@eriol always happy to help. We don't have a release planned so we don't have a timeline for when this would be merged. Take your time. Don't stress out. We'll be here and so will the patch. =D

@wangshaochen

This comment has been minimized.

Show comment
Hide comment
@wangshaochen

wangshaochen May 19, 2015

How to down the the code?

wangshaochen commented May 19, 2015

How to down the the code?

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol May 19, 2015

Contributor
Contributor

eriol commented May 19, 2015

@wangshaochen

This comment has been minimized.

Show comment
Hide comment
@wangshaochen

wangshaochen May 19, 2015

@eriol Ths! I yet don't know. with command_line?

wangshaochen commented May 19, 2015

@eriol Ths! I yet don't know. with command_line?

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker May 19, 2015

Contributor
Contributor

untitaker commented May 19, 2015

@wangshaochen

This comment has been minimized.

Show comment
Hide comment
@wangshaochen

wangshaochen May 19, 2015

i'm sorry. this is my first-time see it.

wangshaochen commented May 19, 2015

i'm sorry. this is my first-time see it.

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker May 27, 2015

Contributor

@Lukasa @sigmavirus24 any updates on this?

Contributor

untitaker commented May 27, 2015

@Lukasa @sigmavirus24 any updates on this?

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa May 27, 2015

Member

We're still hoping to have @eriol and/or @ralphbean take a swing at this code and confirm it's working for them.

Member

Lukasa commented May 27, 2015

We're still hoping to have @eriol and/or @ralphbean take a swing at this code and confirm it's working for them.

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol May 29, 2015

Contributor

I waited to upload requests 2.7.0 in unstable (I uploaded into experimental first) to give httpie maintainer the time to update Debian package (we had httpie 0.8).
Unfortunately this week I'm too busy, so I can cherry pick and test only starting from next week.

Contributor

eriol commented May 29, 2015

I waited to upload requests 2.7.0 in unstable (I uploaded into experimental first) to give httpie maintainer the time to update Debian package (we had httpie 0.8).
Unfortunately this week I'm too busy, so I can cherry pick and test only starting from next week.

@ralphbean

This comment has been minimized.

Show comment
Hide comment
@ralphbean

ralphbean Jun 2, 2015

Contributor

Looks good here!

Contributor

ralphbean commented Jun 2, 2015

Looks good here!

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol Jun 9, 2015

Contributor

Sorry for the delay! I have tested it and all seem fine! Many thanks @untitaker!

Contributor

eriol commented Jun 9, 2015

Sorry for the delay! I have tested it and all seem fine! Many thanks @untitaker!

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Jun 9, 2015

Member

\o/ Alright, I'm happy to cautiously wave this through.

Member

Lukasa commented Jun 9, 2015

\o/ Alright, I'm happy to cautiously wave this through.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Jun 9, 2015

Member

So as for including this in a release...

I could be swayed towards either 2.8.0 or 2.7.1. Reasoning:

Prior to 2.7.0 we had several releases that made this work on every system regardless of whether the dependencies were vendored or not. 2.7.0 broke this. This constitutes a fix for 2.7.0. (That's sort of a weak argument IMO.)

2.8.0 makes sense because this is something that could (but I highly doubt will) break things.

Member

sigmavirus24 commented Jun 9, 2015

So as for including this in a release...

I could be swayed towards either 2.8.0 or 2.7.1. Reasoning:

Prior to 2.7.0 we had several releases that made this work on every system regardless of whether the dependencies were vendored or not. 2.7.0 broke this. This constitutes a fix for 2.7.0. (That's sort of a weak argument IMO.)

2.8.0 makes sense because this is something that could (but I highly doubt will) break things.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Jun 9, 2015

Member

I vote for 2.8.0.

Member

Lukasa commented Jun 9, 2015

I vote for 2.8.0.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Jun 9, 2015

Member

Thought you'd say that.

Member

sigmavirus24 commented Jun 9, 2015

Thought you'd say that.

@sigmavirus24 sigmavirus24 added this to the 2.8.0 milestone Jun 9, 2015

@warsaw

This comment has been minimized.

Show comment
Hide comment
@warsaw

warsaw Jun 10, 2015

I've done a fair bit of testing of this patch for Debian and I think it does exactly what we want it to do. @eriol I've been able to remove the 02_user-system-chardet-and-urllib3.patch and 04_make-requests.packages.urllib3-same-as-urllib3.patch quilt patches and replace it with one that essentially does the PR submitted here. AFAICT, it all looks pretty good. I have a diff against the package that makes it all work, and I'd be inclined to upload a 2.7.0-3 with this patch, even if upstream requests puts it off until 2.8. I'll open a Debian bug with additional details.

+1 for this PR from me.

warsaw commented Jun 10, 2015

I've done a fair bit of testing of this patch for Debian and I think it does exactly what we want it to do. @eriol I've been able to remove the 02_user-system-chardet-and-urllib3.patch and 04_make-requests.packages.urllib3-same-as-urllib3.patch quilt patches and replace it with one that essentially does the PR submitted here. AFAICT, it all looks pretty good. I have a diff against the package that makes it all work, and I'd be inclined to upload a 2.7.0-3 with this patch, even if upstream requests puts it off until 2.8. I'll open a Debian bug with additional details.

+1 for this PR from me.

@warsaw

This comment has been minimized.

Show comment
Hide comment
@warsaw

warsaw Jun 10, 2015

The Debian bug report with the packaging diff is at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788383

warsaw commented Jun 10, 2015

The Debian bug report with the packaging diff is at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788383

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol Jun 10, 2015

Contributor

@warsaw thanks for the debdiff, I forgot to commit my changes when I tested it. I agree with you, I want to remove Debian patches in favor of this and I was already working on 2.7.0-3. 😄

Contributor

eriol commented Jun 10, 2015

@warsaw thanks for the debdiff, I forgot to commit my changes when I tested it. I agree with you, I want to remove Debian patches in favor of this and I was already working on 2.7.0-3. 😄

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol
Contributor

eriol commented Jun 12, 2015

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Jun 24, 2015

Member

pip has adopted a similar patch pypa/pip#2925

Member

sigmavirus24 commented Jun 24, 2015

pip has adopted a similar patch pypa/pip#2925

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Jun 30, 2015

Contributor

Are there any notable differences that should be incorporated into this PR as
well?

On Tue, Jun 23, 2015 at 07:38:32PM -0700, Ian Cordasco wrote:

pip has adopted a similar patch pypa/pip#2925


Reply to this email directly or view it on GitHub:
#2567 (comment)

Contributor

untitaker commented Jun 30, 2015

Are there any notable differences that should be incorporated into this PR as
well?

On Tue, Jun 23, 2015 at 07:38:32PM -0700, Ian Cordasco wrote:

pip has adopted a similar patch pypa/pip#2925


Reply to this email directly or view it on GitHub:
#2567 (comment)

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Jun 30, 2015

Member

@untitaker to be honest, there are some differences. @dstufft mentioned that his patch includes something that handles from pip._vendor import requests as well as import pip._vendor.requests but I'm not sure we need that because I think ours just works as it's written. Perhaps @dstufft could explain more about what he found to be necessary in his patch that didn't work with this (assuming he tried this one in pip)

Member

sigmavirus24 commented Jun 30, 2015

@untitaker to be honest, there are some differences. @dstufft mentioned that his patch includes something that handles from pip._vendor import requests as well as import pip._vendor.requests but I'm not sure we need that because I think ours just works as it's written. Perhaps @dstufft could explain more about what he found to be necessary in his patch that didn't work with this (assuming he tried this one in pip)

@sigmavirus24 sigmavirus24 referenced this pull request Jul 18, 2015

Merged

Proposed 2.8.0 #2678

@mitsuhiko

This comment has been minimized.

Show comment
Hide comment
@mitsuhiko

mitsuhiko Jul 29, 2015

Contributor

Since @kennethreitz just pinged me in #2678 i want to give some comments about this. Given all the crappy solutions about this debian bundling thing, this is probably the best so far. My original complaint was about the badly broken import hook. This one comes with it's own insanity.

For a start: if someone imports from requests.packages.urllib3 import submodule and then later someome imports from urllib3 import submodule (with the patch in place), then submodule.__name__ is requests.packages.urllib3.submodule and not urllib3.submodule. This will break pickle in urllib3 as an example. Since you are already down so far the "we don't care about any of this" route I think this is the closest you will get to achieving your goal.

I still argue that what you should be doing is just stop this vendoring. None of this patching business makes any sense.

There be many more dragons.

Contributor

mitsuhiko commented Jul 29, 2015

Since @kennethreitz just pinged me in #2678 i want to give some comments about this. Given all the crappy solutions about this debian bundling thing, this is probably the best so far. My original complaint was about the badly broken import hook. This one comes with it's own insanity.

For a start: if someone imports from requests.packages.urllib3 import submodule and then later someome imports from urllib3 import submodule (with the patch in place), then submodule.__name__ is requests.packages.urllib3.submodule and not urllib3.submodule. This will break pickle in urllib3 as an example. Since you are already down so far the "we don't care about any of this" route I think this is the closest you will get to achieving your goal.

I still argue that what you should be doing is just stop this vendoring. None of this patching business makes any sense.

There be many more dragons.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Jul 29, 2015

Member

Further entertaining corner behaviour

import requests
print(requests.packages.urllib3.__name__)
# urllib3
from requests.packages.urllib3 import connection
import urllib3
print(urllib3.connection.__name__)
# requests.packages.urllib3.connection
Member

sigmavirus24 commented Jul 29, 2015

Further entertaining corner behaviour

import requests
print(requests.packages.urllib3.__name__)
# urllib3
from requests.packages.urllib3 import connection
import urllib3
print(urllib3.connection.__name__)
# requests.packages.urllib3.connection
@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Jul 29, 2015

Contributor

As far as I understand the main advantage Kenneth sees in vendoring urllib3 is that a minimal installation can be done by just unpacking a tarball.

Perhaps there is a way to provide this comfort without making urllib3 a subpackage of requests?

On 29 July 2015 17:52:10 CEST, Armin Ronacher notifications@github.com wrote:

Since @kennethreitz just pinged me in #2678 i want to give some
comments about this. Given all the crappy solutions about this debian
bundling thing, this is probably the best so far. My original
complaint was about the badly broken import hook. This one comes with
it's own insanity.

For a start: if someone imports from requests.packages.urllib3 import submodule and then later someome imports from urllib3 import submodule (with the patch in place), then submodule.name is
requests.packages.urllib3.submodule and not urllib3.submodule.
This will break pickle in urllib3 as an example. Since you are already
down so far the "we don't care about any of this" route I think this is
the closest you will get to achieving your goal.

I still argue that what you should be doing is just stop this
vendoring. None of this patching business makes any sense.

There be many more dragons.


Reply to this email directly or view it on GitHub:
#2567 (comment)

Sent from my phone. Please excuse my brevity.

Contributor

untitaker commented Jul 29, 2015

As far as I understand the main advantage Kenneth sees in vendoring urllib3 is that a minimal installation can be done by just unpacking a tarball.

Perhaps there is a way to provide this comfort without making urllib3 a subpackage of requests?

On 29 July 2015 17:52:10 CEST, Armin Ronacher notifications@github.com wrote:

Since @kennethreitz just pinged me in #2678 i want to give some
comments about this. Given all the crappy solutions about this debian
bundling thing, this is probably the best so far. My original
complaint was about the badly broken import hook. This one comes with
it's own insanity.

For a start: if someone imports from requests.packages.urllib3 import submodule and then later someome imports from urllib3 import submodule (with the patch in place), then submodule.name is
requests.packages.urllib3.submodule and not urllib3.submodule.
This will break pickle in urllib3 as an example. Since you are already
down so far the "we don't care about any of this" route I think this is
the closest you will get to achieving your goal.

I still argue that what you should be doing is just stop this
vendoring. None of this patching business makes any sense.

There be many more dragons.


Reply to this email directly or view it on GitHub:
#2567 (comment)

Sent from my phone. Please excuse my brevity.

@kennethreitz

This comment has been minimized.

Show comment
Hide comment
@kennethreitz

kennethreitz Aug 7, 2015

Member

Maybe we could just add a warning for when the package has been removed :)

Member

kennethreitz commented Aug 7, 2015

Maybe we could just add a warning for when the package has been removed :)

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Aug 7, 2015

Contributor

I would be +1 for requests to just depend on urllib3 using the packaging tooling :D

Contributor

dstufft commented Aug 7, 2015

I would be +1 for requests to just depend on urllib3 using the packaging tooling :D

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Aug 7, 2015

Contributor

I agree.

Perhaps a bundled version could be created for users who don't want to use PIP,
but I don't think doing this in the PyPI tarball warrants the pain.

On Fri, Aug 07, 2015 at 01:43:49PM -0700, Donald Stufft wrote:

I would be +1 for requests to just depend on urllib3 using the packaging tooling :D


Reply to this email directly or view it on GitHub:
#2567 (comment)

Contributor

untitaker commented Aug 7, 2015

I agree.

Perhaps a bundled version could be created for users who don't want to use PIP,
but I don't think doing this in the PyPI tarball warrants the pain.

On Fri, Aug 07, 2015 at 01:43:49PM -0700, Donald Stufft wrote:

I would be +1 for requests to just depend on urllib3 using the packaging tooling :D


Reply to this email directly or view it on GitHub:
#2567 (comment)

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Aug 7, 2015

Member

I'm not sure a warning will be effective since they're off by default in every Python after 2.6. They already effectively get a warning in the form of an import error.

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Member

sigmavirus24 commented Aug 7, 2015

I'm not sure a warning will be effective since they're off by default in every Python after 2.6. They already effectively get a warning in the form of an import error.

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Aug 7, 2015

Contributor

Also the warning would only happen in the downstream modified requests, and presumably they'd just remove the warning too.

Contributor

dstufft commented Aug 7, 2015

Also the warning would only happen in the downstream modified requests, and presumably they'd just remove the warning too.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Aug 7, 2015

Member

Not to take one side or the other, but if we were to change our position on vendoring, this would make updating chardet a lot easier. The project is now using enum from the Python 3.x stdlib (or enum34 if on Python 2.x) and there's no easy way for us to vendor that version unless the project doesn't use enum. This prevents us from getting some very real fixes that would benefit our users. Also, constraining urllib3's version in the dependency would be an interesting topic for discussion.

Member

sigmavirus24 commented Aug 7, 2015

Not to take one side or the other, but if we were to change our position on vendoring, this would make updating chardet a lot easier. The project is now using enum from the Python 3.x stdlib (or enum34 if on Python 2.x) and there's no easy way for us to vendor that version unless the project doesn't use enum. This prevents us from getting some very real fixes that would benefit our users. Also, constraining urllib3's version in the dependency would be an interesting topic for discussion.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Aug 31, 2015

Member

Ok, I think there's no longer consensus on this issue.

I propose releasing 2.8.0 without this patch in it in the short term, to unblock our release process. Separately, we can decide whether or not we're changing our approach to this problem.

Member

Lukasa commented Aug 31, 2015

Ok, I think there's no longer consensus on this issue.

I propose releasing 2.8.0 without this patch in it in the short term, to unblock our release process. Separately, we can decide whether or not we're changing our approach to this problem.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Sep 1, 2015

Member

I disagree. I think we have consensus from downstream that this solves things there. The lack of consensus on here is whether requests should even be vendoring its dependencies. I think any solution around this will be measured by what is the least objectionable way of handling this (if we decide to handle it at all). We can probably dig around for less objectionable ways of doing this without unvendoring requests, but I'm not sure there are many (if there are any).

Perhaps the real solution is to not tell people to import things from urllib3. Perhaps anything that's meant for end-users that needs to come from urllib3 should be provided through the toolbelt? Now that we have it, we can handle the complexity of urllib3 versions and importing the right thing there.

Thoughts?

Member

sigmavirus24 commented Sep 1, 2015

I disagree. I think we have consensus from downstream that this solves things there. The lack of consensus on here is whether requests should even be vendoring its dependencies. I think any solution around this will be measured by what is the least objectionable way of handling this (if we decide to handle it at all). We can probably dig around for less objectionable ways of doing this without unvendoring requests, but I'm not sure there are many (if there are any).

Perhaps the real solution is to not tell people to import things from urllib3. Perhaps anything that's meant for end-users that needs to come from urllib3 should be provided through the toolbelt? Now that we have it, we can handle the complexity of urllib3 versions and importing the right thing there.

Thoughts?

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Sep 1, 2015

Contributor

Speaking as someone who vendors requests, if requests stopped vendoring urllib3 it would barely affect my ability to vendor requests. It'd take me like 3 seconds to adjust.

Contributor

dstufft commented Sep 1, 2015

Speaking as someone who vendors requests, if requests stopped vendoring urllib3 it would barely affect my ability to vendor requests. It'd take me like 3 seconds to adjust.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Sep 1, 2015

Member

I don't think we can tell people not to import from urllib3: there are too many documents etc. around the web that indicate that we expected people to do that. It'll be really painful trying to discourage that behaviour in future, especially as we can't necessarily very easily deprecate/remove it.

I'm mostly interested to see if @kennethreitz is actually open to considering unvendoring. If he's not, this is the best solution we have so far and we should roll with it.

Member

Lukasa commented Sep 1, 2015

I don't think we can tell people not to import from urllib3: there are too many documents etc. around the web that indicate that we expected people to do that. It'll be really painful trying to discourage that behaviour in future, especially as we can't necessarily very easily deprecate/remove it.

I'm mostly interested to see if @kennethreitz is actually open to considering unvendoring. If he's not, this is the best solution we have so far and we should roll with it.

@sigmavirus24

This comment has been minimized.

Show comment
Hide comment
@sigmavirus24

sigmavirus24 Sep 1, 2015

Member

I'm not sure painful is a sufficient reason to stay providing a better experience for all of our users

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Member

sigmavirus24 commented Sep 1, 2015

I'm not sure painful is a sufficient reason to stay providing a better experience for all of our users

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Sep 3, 2015

Member

I don't think telling people "don't import from urllib3" is a 'better' experience by any measure, just a different one. And I think the fact that it's a direct contradiction of our previous position makes it potentially a bit of a worse experience. But I could be wrong here.

Member

Lukasa commented Sep 3, 2015

I don't think telling people "don't import from urllib3" is a 'better' experience by any measure, just a different one. And I think the fact that it's a direct contradiction of our previous position makes it potentially a bit of a worse experience. But I could be wrong here.

@dstufft

This comment has been minimized.

Show comment
Hide comment
@dstufft

dstufft Sep 3, 2015

Contributor

For whatever it's worth, I think a lot of the end user pain when things get unbundled is caused because requests bundles urllib3 but it's not just a private implementation detail (as much as it may be intended to be). Either it should be just a private implementation detail and users shouldn't be expected to import from it and requests itself will need to encaspulate all of the functionality that end users are expected to need without them needing to touch urllib3, or it should be a real dependency declared in setup.py.

Contributor

dstufft commented Sep 3, 2015

For whatever it's worth, I think a lot of the end user pain when things get unbundled is caused because requests bundles urllib3 but it's not just a private implementation detail (as much as it may be intended to be). Either it should be just a private implementation detail and users shouldn't be expected to import from it and requests itself will need to encaspulate all of the functionality that end users are expected to need without them needing to touch urllib3, or it should be a real dependency declared in setup.py.

@warsaw

This comment has been minimized.

Show comment
Hide comment
@warsaw

warsaw commented Sep 3, 2015

@dstufft : +1

@rschoon

This comment has been minimized.

Show comment
Hide comment
@rschoon

rschoon Sep 15, 2015

Either it should be just a private implementation detail and users shouldn't be expected to import from it and requests itself will need to encaspulate all of the functionality that end users are expected to need without them needing to touch urllib3, or it should be a real dependency declared in setup.py.

I think that's definitely a piece of the problem. The documentation mentions urllib3 quite a lot, but only mentions that urllib3 is vendored in passing (in the logging example, no less). It's quite easy to get to from urllib3 import Retry when you really ought to be doing from requests.packages.urllib3 import Retry, especially when it says "import urllib3’s Retry class". I think I only knew to use the vendored name because I had heard of the big mess from distros trying to unvendor it.

Except, if you're trying to be clever when unvendoring, the latter isn't right either, since that's not what requests imports it as:

>>> from urllib3 import Retry as Retry1
>>> from requests.packages.urllib3 import Retry as Retry2
>>> from requests.packages.urllib3.util import Retry as Retry3
>>> from requests.adapters import Retry as Retry4
>>> print(id(Retry1), id(Retry2))
38364744 38364744
>>> print(id(Retry3), id(Retry4))
39516104 39516104

In the example, Retry4 will always be the version that requests actually uses, and because the Retry.from_int class method has an isinstance check, the identity matters. I've seen this behavior with the removed VendorAlias() mechanism, but this pull request seems to suffer from it too. I'm not sure I entirely understand the reasoning for Python's behavior here, either:

>>> Retry2.__module__
'urllib3.util.retry'
>>> sys.modules[Retry2.__module__]
<module 'urllib3.util.retry' from '/home/rschoon/tmp/req/env2/lib/python3.4/site-packages/urllib3/util/retry.py'>
>>> Retry3.__module__
'requests.packages.urllib3.util.retry'
>>> sys.modules[Retry3.__module__]
<module 'requests.packages.urllib3.util.retry' from '/home/rschoon/tmp/req/env2/lib/python3.4/site-packages/urllib3/util/retry.py'>

(Fortunately, the import order does not seem to matter.)

Anyway, if unvendoring from requests proper isn't an option (there's surely backward compatibility issues to deal with), I really feel that it'd be a good idea to give parts of urllib3 that are exposed official "requests" names. At a minimum just making the name of the Retry class in the documentation be "requests.adapters.Retry" would improve things.

rschoon commented Sep 15, 2015

Either it should be just a private implementation detail and users shouldn't be expected to import from it and requests itself will need to encaspulate all of the functionality that end users are expected to need without them needing to touch urllib3, or it should be a real dependency declared in setup.py.

I think that's definitely a piece of the problem. The documentation mentions urllib3 quite a lot, but only mentions that urllib3 is vendored in passing (in the logging example, no less). It's quite easy to get to from urllib3 import Retry when you really ought to be doing from requests.packages.urllib3 import Retry, especially when it says "import urllib3’s Retry class". I think I only knew to use the vendored name because I had heard of the big mess from distros trying to unvendor it.

Except, if you're trying to be clever when unvendoring, the latter isn't right either, since that's not what requests imports it as:

>>> from urllib3 import Retry as Retry1
>>> from requests.packages.urllib3 import Retry as Retry2
>>> from requests.packages.urllib3.util import Retry as Retry3
>>> from requests.adapters import Retry as Retry4
>>> print(id(Retry1), id(Retry2))
38364744 38364744
>>> print(id(Retry3), id(Retry4))
39516104 39516104

In the example, Retry4 will always be the version that requests actually uses, and because the Retry.from_int class method has an isinstance check, the identity matters. I've seen this behavior with the removed VendorAlias() mechanism, but this pull request seems to suffer from it too. I'm not sure I entirely understand the reasoning for Python's behavior here, either:

>>> Retry2.__module__
'urllib3.util.retry'
>>> sys.modules[Retry2.__module__]
<module 'urllib3.util.retry' from '/home/rschoon/tmp/req/env2/lib/python3.4/site-packages/urllib3/util/retry.py'>
>>> Retry3.__module__
'requests.packages.urllib3.util.retry'
>>> sys.modules[Retry3.__module__]
<module 'requests.packages.urllib3.util.retry' from '/home/rschoon/tmp/req/env2/lib/python3.4/site-packages/urllib3/util/retry.py'>

(Fortunately, the import order does not seem to matter.)

Anyway, if unvendoring from requests proper isn't an option (there's surely backward compatibility issues to deal with), I really feel that it'd be a good idea to give parts of urllib3 that are exposed official "requests" names. At a minimum just making the name of the Retry class in the documentation be "requests.adapters.Retry" would improve things.

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Sep 15, 2015

Contributor

@rschoon yes, the problems with __name__ have already been mentioned by mitsuhiko before.

I'd just opt for unbundling all those dependencies, and optionally providing a separate tarball that contains all dependencies (all as top-level package each, not inside the requests package).

Contributor

untitaker commented Sep 15, 2015

@rschoon yes, the problems with __name__ have already been mentioned by mitsuhiko before.

I'd just opt for unbundling all those dependencies, and optionally providing a separate tarball that contains all dependencies (all as top-level package each, not inside the requests package).

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Sep 16, 2015

Member

So folks, the reality of the matter is that unbundling is not going to happen in the short term. Kenneth is currently stepped back a bit from the project but it was always his opinion that was strongest on this matter: until we can get time to sit down and talk about this in depth we're not going to unvendor anything.

The question is whether this change is superior to the status quo. For the moment, please assume unvendoring is off the table: sorry. 😞

Member

Lukasa commented Sep 16, 2015

So folks, the reality of the matter is that unbundling is not going to happen in the short term. Kenneth is currently stepped back a bit from the project but it was always his opinion that was strongest on this matter: until we can get time to sit down and talk about this in depth we're not going to unvendor anything.

The question is whether this change is superior to the status quo. For the moment, please assume unvendoring is off the table: sorry. 😞

@untitaker

This comment has been minimized.

Show comment
Hide comment
@untitaker

untitaker Sep 16, 2015

Contributor

Since this patch already is used in Debian (I think?) and it has no effect in
environments without unbundled dependencies, I would say it doesn't make any
difference at all for existing packages.

Including this hack into requests prevents new unbundled packages from using
broken alternatives, OTOH including it might also encourage unbundling in the
first place.

On Wed, Sep 16, 2015 at 12:59:57AM -0700, Cory Benfield wrote:

So folks, the reality of the matter is that unbundling is not going to happen in the short term. Kenneth is currently stepped back a bit from the project but it was always his opinion that was strongest on this matter: until we can get time to sit down and talk about this in depth we're not going to unvendor anything.

The question is whether this change is superior to the status quo. For the moment, please assume unvendoring is off the table: sorry. 😞


Reply to this email directly or view it on GitHub:
#2567 (comment)

Contributor

untitaker commented Sep 16, 2015

Since this patch already is used in Debian (I think?) and it has no effect in
environments without unbundled dependencies, I would say it doesn't make any
difference at all for existing packages.

Including this hack into requests prevents new unbundled packages from using
broken alternatives, OTOH including it might also encourage unbundling in the
first place.

On Wed, Sep 16, 2015 at 12:59:57AM -0700, Cory Benfield wrote:

So folks, the reality of the matter is that unbundling is not going to happen in the short term. Kenneth is currently stepped back a bit from the project but it was always his opinion that was strongest on this matter: until we can get time to sit down and talk about this in depth we're not going to unvendor anything.

The question is whether this change is superior to the status quo. For the moment, please assume unvendoring is off the table: sorry. 😞


Reply to this email directly or view it on GitHub:
#2567 (comment)

@eriol

This comment has been minimized.

Show comment
Hide comment
@eriol

eriol Sep 16, 2015

Contributor

@untitaker yes, it's included in Debian (and Ubuntu) since 2.7.0-3. It was uploaded on 11 Jun 2015. I did not receive complains related to it yet.

Contributor

eriol commented Sep 16, 2015

@untitaker yes, it's included in Debian (and Ubuntu) since 2.7.0-3. It was uploaded on 11 Jun 2015. I did not receive complains related to it yet.

@Lukasa

This comment has been minimized.

Show comment
Hide comment
@Lukasa

Lukasa Sep 17, 2015

Member

So I'm getting the position that we think that, right now, we should merge this as-is, and look to unbundle at some future release.

Member

Lukasa commented Sep 17, 2015

So I'm getting the position that we think that, right now, we should merge this as-is, and look to unbundle at some future release.

@Lukasa Lukasa merged commit 93216af into requests:master Oct 5, 2015

1 check passed

default Merged build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment