5 ms·
Every time I notice something is a Python codebase I feel a letdown as it means it will likely break some other Python project from someone else I have on my de
by pmarreck 3y ago
Every time I notice something is a Python codebase I feel a letdown as it means it will likely break some other Python project from someone else I have on my dev machine which I may not have touched in a while but which I will find got silently broken when I most need it
Especially if it's a nice TUI app like this looks
EDIT: Guys, in my experience, virtual environments do not fix this problem in all cases. At least, not sufficiently for me (after getting used to Nix's guarantees, for example). Not to mention, there's multiple ways/attempts at creating and working with virtual environments: https://twitter.com/pmarreck/status/1735363908515295253 https://twitter.com/pmarreck/status/1735363908515295253). See below comment.
- nicoco 3y agoInstall using pipx to avoid that. (or virtualenvs directly if you don't mind getting your hands dirty)
- pmarreck 3y agosee my response to your sibling comment by whalesalad.
- sgarland 3y agoWhile I do like pipx, and am a diehard Python fan, if the interpreter used to install the project changes, I still have to reinstall the project, which is annoying. I suppose I could get around that by installing a Python interpreter outside of brew, and only use that for packages.
- isp 3y agoThis is the problem that 'venv' (virtual environments) was designed to solve. You can run pip in an isolated virtual environment, in user mode (not as root) - see https://gist.github.com/saurabhshri/46e4069164b87a708b39d947e4527298 https://gist.github.com/saurabhshri/46e4069164b87a708b39d947...
- pmarreck 3y agoSee my sibling response(s). Also this comment criticizing the solution in that link you gave me: https://gist.github.com/saurabhshri/46e4069164b87a708b39d947e4527298?permalink_comment_id=2268663#gistcomment-2268663 https://gist.github.com/saurabhshri/46e4069164b87a708b39d947...
- whalesalad 3y agoevery project you have should be in a virtual environment. it is not hard. https://docs.python.org/3.12/library/venv.html https://docs.python.org/3.12/library/venv.html python -m venv ~/my-venvs/<name> source ~/my-venvs/name/bin/activate pip install <package> but stuff like this would usually get installed globally, and your projects would instead have a venv. personally my favorite tool is pyenv, which allows you to have many versions of python on your machine as well as many virtualenv (which are assigned to any version you have installed) then it is as simple as pyenv virtualenv <version> <name> pyenv virtualenv 3.11.1 xyz and to activate pyenv activate xyz this allows you to keep every project you have isolated not only to the packages required to run it, but also the python version required. I work on a handful of projects that run on 3.10, 3.11 and 3.12. Each has their own independent python version, and within that version they also have their own python packages (pip environment). At the end of the day these are simply directories on disk.
- pmarreck 3y agoYeah. I've heard this same comment before in different forms from "Python apologists" about a dozen times. In practice it's still a lot of hair-pulling, because your entire comment assumes that EVERY Python project is already doing things exactly this way and hasn't screwed up a single part of it: https://twitter.com/pmarreck/status/1735363908515295253 https://twitter.com/pmarreck/status/1735363908515295253 but also... > but stuff like this would usually get installed globally well, you just killed (apparently unknowingly?) your whole argument right there, because globals are bad and absolutely not project-specific and absolutely do cause compatibility issues between different Python projects If you ever come around to Nix, it takes care of this problem for good (as in, it guarantees that you will never have 2 projects that step on each other), across every ecosystem, not just Python's. Unfortunately, I don't see very many Python projects at all that contain a flake.nix file, which is a damn shame, because it would cause people like me to hate Python just a tiny bit less
- whalesalad 3y agoHair pulling? It's the most barebones unix thing you can imagine. If you understand unix principles, you can use virtual environments and python. It used to be hard. A global site-packages or dist-packages dir is hard. Conda and all those tools make it worse. A virtualenv is a directory. It contains a copy of Python and everything needed. You don't even need to activate it. You can simply use the binaries that exist in those directories. It's literally this simple: $ python -m venv pmarreck $ pmarreck/bin/python --version Python 3.10.12 $ pmarreck/bin/pip install harlequin Collecting harlequin Downloading harlequin-1.8.0-py3-none-any.whl (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 1.2 MB/s eta 0:00:00 ... Successfully installed MarkupSafe-2.1.3 click-8.1.7 duckdb-0.9.2 harlequin-1.8.0 jinja2-3.1.2 linkify-it-py-2.0.2 markdown-it-py-3.0.0 mdit-py-plugins-0.4.0 mdurl-0.1.2 numpy-1.26.3 platformdirs-3.11.0 prompt_toolkit-3.0.36 pyarrow-14.0.2 pygments-2.17.2 pyperclip-1.8.2 questionary-2.0.1 rich-13.7.0 rich-click-1.7.3 shandy-sqlfmt-0.21.1 textual-0.46.0 textual-fastdatatable-0.5.0 textual-textarea-0.9.5 tomli-2.0.1 tomlkit-0.12.3 tqdm-4.66.1 tree-sitter-0.20.4 tree_sitter_languages-1.9.1 typing-extensions-4.9.0 uc-micro-py-1.0.2 wcwidth-0.2.12 $ pmarreck/bin/harlequin Boom, the tool launched immediately. No conflicts with anything else. When I am done, `rm -rf ~/pmarreck`, done. I did all of this in my home directory. It literally cannot get easier than this.
- billowycoat 3y agoThis isn’t an issue if you use virtual environments. See also pipx for installing isolated Python apps.
- pmarreck 3y agoSee my sibling response(s).
- jzombie 3y agoDocker could be an alternative if virtual environments aren't your thing. I'd imagine they would provide a greater degree of isolation, too.
- pmarreck 3y agoDocker wastes a lot of extra space/resources (disk space, memory, possibly CPU) and can have issues when it comes to needing networking (you start to need a container coordinator). But yes, I've used it in the past. Seems more geared towards server apps than anything else though (although being able to run macOS via Docker is kind of neat).