ehmatthes,
@ehmatthes@fosstodon.org avatar

I will admit to spending the first half hour of today's sprints figuring out why my tests weren't running, only to realize I had pytest installed system-wide on my laptop. 🤦‍♂️

#PyConUS

ghickman,
@ghickman@mastodon.social avatar

@ehmatthes have you seen the pip option to disable global installs by default?

ehmatthes,
@ehmatthes@fosstodon.org avatar

@ghickman I have. I do a fair amount of quick exploratory coding, so I like having a small set of global packages, ie plotting libraries. I might modify my workflow, but I've only run into this a couple times over the years.

ehmatthes,
@ehmatthes@fosstodon.org avatar

@ghickman Although, after thinking for a moment, I think I'll clear out my global packages, reinstall that small set, and then disable global installs. Thanks for the reminder. :)

pythonbynight,
@pythonbynight@fosstodon.org avatar

@ehmatthes @ghickman I think I may have asked you this before, but is there a reason not to use pipx?

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight @ghickman Mario, you're always nudging me toward better workflows. :)

I have used pipx when it's recommended as the best way to install a specific package, but it's not part of my standard workflow. I just opened an issue to take a closer look at it, in particular to see if it would make some of my packages easier to use.

I tend to try to stay as close as I can to bare tools, for a variety of reasons.

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight Mostly because I work with so many people who don't have much more than bare Python installed, and I don't want to specialize my workflows to the point it's hard to talk to other users about their issues.

That approach has worked for a long time, but I don't know how necessary it is anymore.

pythonbynight,
@pythonbynight@fosstodon.org avatar

@ehmatthes Ah, I see. Yeah, I definitely understand keeping things simple when possible.

I guess my follow up question would be: are there instances where it makes sense for your users to also have packages installed globally?

pipx is only for libraries with cli entrypoints (not importable), meaning general isolation for tools you'd use in any project. In that respect, it's quite a convenience.

I suppose there might be "importable" tools you'd want globally?

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight When I tell people about this, they nod and say, "Yeah that would be useful." It's a really nice example of a tiny utility that can be really useful.

https://pypi.org/project/py-image-border/

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight I have a project called py-image-border that's gotten no attention yet, but I use it almost every time I write a newsletter post because afaik macOS still doesn't have a built-in utility for adding borders to screenshots. Once installed, you can run

$ add-border <filename>

So it's a Python package that's best run without invoking python explicitly. I'm going to look at the current setup, and see if adding instructions for installing with pipx would be helpful.

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight But mostly my global installs are things like pandas, matplotlib, plotly, and pygame.

pythonbynight,
@pythonbynight@fosstodon.org avatar

@ehmatthes Ah yeah... I see. These make more sense as global installs.

I'm guessing you keep these globally out of convenience (not having to install each time or saving space?).

But yes, I'd say py-image-border is a great example of a tool to install with pipx!

ehmatthes,
@ehmatthes@fosstodon.org avatar

@pythonbynight These are packages I use a lot, and are rarely affected by update issues. I don't really need to isolate my pygame library; if I update it for one game project it's usually fine to update for all.

Also, a lot of my quick tests involve visualizations, so it's nice to just have some plotting and data management libraries available.

ghickman,
@ghickman@mastodon.social avatar

@pythonbynight @ehmatthes oh I love pipx! But I also need some libraries installed globally, eg for neovim

treyhunner,
@treyhunner@mastodon.social avatar

@ghickman @pythonbynight @ehmatthes I used to do this to but I now do 0 global installs.

I believe I'm using an option to tell neovim about the virtual env where it can find the packages it needs. For all my CLI apps I use pipx. For one of my commonly used packages I use a "temporary" (though sometimes semi-permanent) venv.

treyhunner,
@treyhunner@mastodon.social avatar

@ghickman @pythonbynight @ehmatthes I also disabled global installs because I kept accidentally globally installing. If "global environment 0" isn't possible for you, temporarily re-enabling global install for just certain packages sounds like a clever compromise.

tartley,
@tartley@mastodon.social avatar

@ghickman @pythonbynight @ehmatthes I personally install the neovim libraries into a virtualenv called 'neovim', and set my vim config to use the python binary from within that virtualenv. I think installing globally is an antipattern that always can and should be avoided.

tartley,
@tartley@mastodon.social avatar

@ghickman @pythonbynight @ehmatthes

let g:python3_host_prog="$HOME/.virtualenvs/neovim/bin/python3"

ghickman,
@ghickman@mastodon.social avatar

@tartley @pythonbynight @ehmatthes yeah, I’ve never liked having it installed globally. Venv just for it is a great idea, will have to try that out, thank you!

ghickman,
@ghickman@mastodon.social avatar

@ehmatthes I do a similar thing with all my Python installs, sometimes you just need your python(s) to have a few extras 😁 https://github.com/ghickman/dotfiles/blob/main/requirements.txt

ehmatthes,
@ehmatthes@fosstodon.org avatar

@ghickman Do those get installed into every one of your venvs, or is that your short list of packages that get installed globally for each python version?

ehmatthes,
@ehmatthes@fosstodon.org avatar

@ghickman BTW I love looking at everyone's dotfiles repo, and stumbled upon this bittersweet commit message in your repo:

"remove the last dregs of Heroku 🍻"

ghickman,
@ghickman@mastodon.social avatar

@ehmatthes yeah 😢

ghickman,
@ghickman@mastodon.social avatar

@ehmatthes just for each Python version. I should review them tbh! The main one was having neovim support available.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • JUstTest
  • everett
  • tacticalgear
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines