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

Preserve pip.main() in some fashion #5080

Closed
sernst opened this issue Mar 17, 2018 · 9 comments
Closed

Preserve pip.main() in some fashion #5080

sernst opened this issue Mar 17, 2018 · 9 comments
Labels
auto-locked Outdated issues that have been locked by automation C: public api Public API stuff resolution: no action When the resolution is to not do anything type: maintenance Related to Development and Maintenance Processes

Comments

@sernst
Copy link

sernst commented Mar 17, 2018

I'm opening this issue on the recommendation of @dstufft to carry over a tangential discussion that arose in #5079.

While understanding that pip.main() is not officially supported and is being refactored to pip._internal.main() in the 10.0.0 release, there is definitely usage of it out there. GitHub code search won't allow for using . so this search isn't perfect:

https://github.com/search?l=Python&q=import+pip+main%28&type=Code&utf8=%E2%9C%93

but it returns ~850k hits of import pip + main( on public github projects.

An anecdotal pattern I notice from a quick look through them, is that many are installing data packages. Not surprising since there are many data environments (notebook deployments especially) that obfuscate access to the host environment. This is serving as an in-python way of managing dependencies that can be shared in such contexts.

I'm not sure if there's any interest in maintaining the pip.main() as a passthrough command execution wrapper, but that could potentially mitigate the pain of upgrading for many.

@sernst sernst changed the title Preserve pip.main() in some fashion Preserve pip.main() in some fashion Mar 17, 2018
@pfmoore
Copy link
Member

pfmoore commented Mar 17, 2018

I wouldn't have any objection to reintroducing pip.main() in some form (it wouldn't be in pip 10, but could be in some future version). But I'd prefer it to be a wrapper around a subprocess call to pip, rather than simply exposing pip's internal function (as doing that has already been shown to have issues).

If someone were to create a PR for this, I think it would be a good thing to consider - but it would be something that needs discussion, and that's likely easier to do in the context of a proposed implementation, not just in the abstract.

@henryiii
Copy link
Contributor

henryiii commented Apr 2, 2018

This change causes the following docker lines to fail:

docker run -it ubuntu
apt update && apt install -y python-pip
pip install pip==10.0b1
pip

Now pip (the command) is broken, since the pip script in /usr/bin is simply a wrapper for from pip import main, and pip's update can't touch that script. Only python -m pip works. If this remains in Pip 10, I'm afraid Pip 10 will be seen as "buggy" and people won't update (and I really want to require Pip 10 to get pyproject.toml).

@henryiii
Copy link
Contributor

henryiii commented Apr 2, 2018

And, unrelated to my last post but related to this discussion, it's quite common for Jupyter notebooks (at least in the sciences) to check for a requirement, then install any missing requirements using from pip import main.

@pfmoore
Copy link
Member

pfmoore commented Apr 3, 2018

Now pip (the command) is broken, since the pip script in /usr/bin is simply a wrapper for from pip import main, and pip's update can't touch that script.

That script is presumably managed by the OS python-pip package. You shouldn't be using pip install --upgrade to upgrade OS packages, precisely for this reason. I understand that docker is a subtly different situation than the normal cases we see of users trying to use sudo pip install --upgrade to update the system installation of pip, but nevertheless the situation is the same - the distribution doesn't support using pip directly to upgrade the system packages, so you'd need to take this up with them.

Regarding Jupyter notebooks, which don't have access to a command prompt, we're aware that they have a specific problem. I'd suggest that using !pip install (using the Jupyter syntax to run a shell command) is better than invoking pip.main.

@pradyunsg pradyunsg added C: public api Public API stuff state: needs discussion This needs some more discussion type: maintenance Related to Development and Maintenance Processes resolution: deferred till PR Further discussion will happen when a PR is made and removed state: needs discussion This needs some more discussion labels Apr 8, 2018
@pradyunsg
Copy link
Member

#5149 is the PR for this.

cschneid pushed a commit to scoutapp/scout_apm_python that referenced this issue Apr 9, 2018
Previously, we used internal pip code, which was changing in point
releases, causing issues. We actually don't need pip to do this, we can
instead ask the installed python's pkg_resources directly for the same
info.

Related issues:

pypa/pip#5079
pypa/pip#5080
pypa/pip#5081
@sirosen
Copy link
Contributor

sirosen commented May 11, 2018

The decision on this appears to be "no", judging from the thread in #5149.
This issue should probably be closed.

I did toss something together which I'll shamelessly link here, in case people find it useful (or objectionable and want to yell at me):

@pradyunsg
Copy link
Member

This issue should probably be closed.

Indeed.

@pradyunsg pradyunsg added resolution: no action When the resolution is to not do anything and removed resolution: deferred till PR Further discussion will happen when a PR is made labels May 11, 2018
mplanchard added a commit to pypiserver/pypiserver that referenced this issue Jun 12, 2018
Resolves #205 - pypi.python.org shutting down

* Updated the default fallback URL to `pypi.org/simple` rather than
`pypi.python.org/simple`
* Scrubbed references and links to `pypi.python.org`
* Fixed tests breaking due to the removal of `pip.main()` in pip 10.0 -
see pypa/pip#5080 for more info
@maxymczech
Copy link

This is so sad :'( Why do you people do this?

@lock
Copy link

lock bot commented Jun 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 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 C: public api Public API stuff resolution: no action When the resolution is to not do anything type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

No branches or pull requests

6 participants