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

Reasoning behind unsafe packages #522

Closed
elaichi opened this issue May 30, 2017 · 3 comments
Closed

Reasoning behind unsafe packages #522

elaichi opened this issue May 30, 2017 · 3 comments

Comments

@elaichi
Copy link

elaichi commented May 30, 2017

Why exactly is it that some packages are considered unsafe in a requirements file?

I first noticed the comment after using pip-compile and then found this set in piptools/utils.py:

UNSAFE_PACKAGES = {'setuptools', 'distribute', 'pip'}

I tried googling for an answer but no luck.

Environment Versions
  1. OS Type
  2. Python version: $ python -V — 2.7.13
  3. pip version: $ pip --version — 9.0.1
  4. pip-tools version: $ pip-compile --version — 1.9.0
Steps to replicate
❯ pip-compile --dry-run <(echo "pip")
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --output-file /dev/fd/11.txt /dev/fd/11
#

# The following packages are considered to be unsafe in a requirements file:
pip==9.0.1
Dry-run, so nothing updated.

This is clearly not an actual issue but just a question :)

@vphilippon
Copy link
Member

vphilippon commented May 30, 2017

That was brought a while agot, by this commit:
50f06cb

And I'll admit I'd really like to have @nvie input on this.

The only reasons I could think of would be one of those:

  1. Some packages, like pip, can be installed with a package manager on linux, and could cause some conflict, but I never tested (I'm mostly on Windows these days).
  2. Those are setup/installation packages, and most app (not all though) don't need to pin them.
  3. When doing pip freeze, some of the installed packages are not listed, unless --all is specified. Maybe the original intent was to follow that.

@simon-weber
Copy link

I'm interested in this too. I've got two guesses:

  • upgrading pip/etc at the same time as upgrading other packages might cause issues (though I haven't actually tested this)
  • this has something to do with pip usually being globally installed by a system package manager, and is a band-aid for the conflict described in pip-sync using global pip inside virtualenvs on Ubuntu #328

Am I on the right track?

@vphilippon
Copy link
Member

Coming back on this:

pip, setuptools and distribute and responsible for building/installing packages. Generally speaking, one shouldn't have to pin these as they should have little impact on an application. (I've actually met quite a few exceptions to this assumption in my daily work, but I'll go ahead and hope that I just happen to be an unlucky fellow doing some funky things.)

For, PACKAGES_TO_IGNORE, it seems to be to cover some edged cases with global packages. for pip, setuptools and wheel, I would say it's to avoid issues while pip-sync is running. For pip-tools, that's just to be keep the tool installed. For pip-review, I think its a simple exclusion for this tool that is used to track packages upgrade and might be interesting to use alongside pip-tools`.

I'll close this issue, as it seems there's not much else we can add other than guessing. If this cause any other issue in the future, we can spend the time to figure out the exact needs and impact.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 2, 2021
…env r=ahal

Now that are prioritizing system over virtualenv site-packages, the
system `pip` is sometimes being used instead.
This is causing issues when the system pip is set up in a
distro-specific way, such as when "debundled":
https://github.com/pypa/pip/blob/9.0.1/pip/_vendor/__init__.py#L53-L61

However, if we vendor `pip`, `setuptools` and `wheel`, and ensure that
they're prioritized in the `sys.path` before anything is imported from
the system, then we can ensure that we're using a modern `pip` _and_
sidestep system-specific pip weirdness.

Note that `pip-compile`'s `--allow-unsafe` flag is not as dangerous as
it sounds.
There's confusion among maintainers about its origin:
jazzband/pip-tools#522
Additionally, it's going to be enabled by default in a future
`pip-tools` release. So, it's not scary for us to embrace here.

Also, heads up that the "pip outdated warning" no longer needs
to be manually silenced, since pip avoids that code path when
not running from an "installed" context.

Differential Revision: https://phabricator.services.mozilla.com/D127182
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 3, 2021
…env r=ahal

Now that are prioritizing system over virtualenv site-packages, the
system `pip` is sometimes being used instead.
This is causing issues when the system pip is set up in a
distro-specific way, such as when "debundled":
https://github.com/pypa/pip/blob/9.0.1/pip/_vendor/__init__.py#L53-L61

However, if we vendor `pip`, `setuptools` and `wheel`, and ensure that
they're prioritized in the `sys.path` before anything is imported from
the system, then we can ensure that we're using a modern `pip` _and_
sidestep system-specific pip weirdness.

Note that `pip-compile`'s `--allow-unsafe` flag is not as dangerous as
it sounds.
There's confusion among maintainers about its origin:
jazzband/pip-tools#522
Additionally, it's going to be enabled by default in a future
`pip-tools` release. So, it's not scary for us to embrace here.

Also, heads up that the "pip outdated warning" no longer needs
to be manually silenced, since pip avoids that code path when
not running from an "installed" context.

Differential Revision: https://phabricator.services.mozilla.com/D127182
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

3 participants