News for hackers. Stuff that matters.
Re:Debian discusses vendoring again by quietbritishjim on Wednesday January 13, 2021 @09:52AM (#25762653)
Put more simply: never run `sudo pip install foo`. That's never expected to work, and it's a pity it doesn't just give a simple error "don't do that!" rather than sometimes partially working.

As you said, you should start a new environment instead and install whatever you like into that. For Python, that means using virtualenv or python -m venv. You can always use the --system-site-packages switch to get the best of both worlds: any apt install python3-foo packages show up in the virtual envioronment, but you can use pip to shadow them with newer versions if you wish.

Re:Debian discusses vendoring again by rcxdude on Wednesday January 13, 2021 @11:21AM (#25764090)
I basically don't let anything but the package manager touch /usr. Too many mysteriously issues in systems that had gotten screwed up. It's extremely rare that it's necessary for any project: if you need to build and install some other project you can generally just install in a directory dedicated to any single codebase you may be working (with appropriate PATH adjustments which can be sources from a shell script so they are isolated from the rest of the system). I really dislike tutorials and guides which encourage just blindly installing stuff into system managed areas but it's rife.
Re:Debian discusses vendoring again by zozbot234 on Wednesday January 13, 2021 @03:49PM (#25767772)
> I basically don't let anything but the package manager touch /usr.

That's the standard approach. Custom system-wide packages (as opposed to packages that are only installed for one user) should go in /usr/local/ or in a package-specific directory under /opt/.

Re:Debian discusses vendoring again by quietbritishjim on Thursday January 14, 2021 @05:23AM (#25774641)
The comment you're replying to is a bit ambiguous. Did they mean don't put anything directly in /usr (i.e. except /usr/local)? Or did they mean don't put anything anywhere under /usr? Both are consistent with my comment.

Personally, I stopped using even /usr/local (or /opt) many years ago. If it's not managed by the operating system then it goes in my home directory (except a few things in /etc that have to go there).

Re:Debian discusses vendoring again by rcxdude on Thursday January 14, 2021 @11:53AM (#25778690)
Exactly. Stuff in /usr/local is very capable of messing with other parts of the system (plus it munges everything not package managed together, which is even worse).
Re:Debian discusses vendoring again by kstrauser on Wednesday January 13, 2021 @02:09PM (#25766616)
Pip has that feature now. Put this in your ~/.pip/pip.conf:

  [global]
  require-virtualenv = true
and then you get errors like:

  $ pip install foo
  ERROR: Could not find an activated virtualenv (required).
Re:Debian discusses vendoring again by nemetroid on Wednesday January 13, 2021 @02:40PM (#25766986)
That's not exactly the same. I might be fine with installing Python packages with pip into my home directory, just not /usr.
Re:Debian discusses vendoring again by kstrauser on Wednesday January 13, 2021 @03:34PM (#25767601)
My workflow's been to temporary disable that, do the stuff I need, then re-enable it. It's a bit clunky, but I don't install stuff outside a virtualenv frequently enough for it to be a major pain in the neck.
Re:Debian discusses vendoring again by skrtskrt on Wednesday January 13, 2021 @03:13PM (#25767359)
Yeah I use pyenv + virtualenvwrapper and there are a few packages I am fine with having in the top-level pyenv version, rather than in any particular virtual environment: black, requests, click, etc.