I have these aliases in my .bashrc, and I can't remember the last time I had a major issue.
alias venv='rm -rf ./venv && virtualenv venv && source ./venv/bin/activate'
alias vact='source ./venv/bin/activate'
alias pinstall='source ./venv/bin/activate && pip install . && pip install -r ./requirements.txt && pip install ./test_requirements.txt'
I don't have all the fancy features, like automatically activating the virtualenv when I cd into the directory, but I've always found those to be a bigger headache than they are worth. And if I ever run into some incompatibility or duplicate library or something, I blow away the old venv and start fresh. It's a good excuse to get up and make a cup of tea.
That would be python2, in 3 it's "python -m venv venv" (first venv is package to run, second is directory to put it in)
Otherwise yeah, it's the same and I also use it manually. Never had any problems.
Using virtualenv directly has also been my approach, and has not failed me yet.
I also used Poetry for one of my personal projects, and I liked what I saw.
[1] https://github.com/pyenv/pyenv [2] https://github.com/pyenv/pyenv-virtualenv
That's just for managing your python installation and virtualenv though. You still need to manage your packages and for that you have options like requirements.txt, pipenv (not pyenv lol), Poetry, and others.
It was a nightmare.
[1] https://github.com/python-virtualenvwrapper/virtualenvwrappe...
Never had a single problem, venv + pyenv is a great combo. As far as I can tell, like so many sources of frustration in tech, the issue typically lies with user error/not fully understanding the tool you're using. That isn't saying that there isn't room for improvement -- most notably, package management in Python flies in the face of "there should be one -- and preferably only one -- obvious way to do it" -- but the tools we have work quite well.
I should learn to use venv properly
Thanks
To this day I'm not quite sure why the venv developers decided that sourcing was a good idea; all it does can be effectively replaced with
#!/bin/sh
export VIRTUAL_ENV="path to venv"
export PATH="$VIRTUAL_ENV/bin:$PATH"
unset PYTHONHOME
exec "$SHELL"
Just run this script to get into an "activated" shell. To deactivate, just press Ctrl+D. If you're really fancy, you can replace the last line with exec "${@:-$SHELL}"
to run a command directly in the activated environment (and then deactivate it immediately).I'm now curious whether there are languages out there that do have a really nice packaging system.
I’ll often look for command line tools written in Rust, but not because of Rust fanboyism, but because I know I can just git clone the project and immediately start hacking on a new feature I need or a quick bug fix. In almost every other language I have to jump through one million hoops before I can build and run whatever it is, let alone have a nice developer experience (autocomplete, go to definition, etc).
In my experience, Java, Go, PHP, NodeJS have all got similar package management that works.
Java package managers tend to install packages written in java
Go installs packages written in go, and maybe C using cgo
Cargo installs packages written in rust
php package managers install packages written in PHP, extra extensions are rare
etc
People having trouble with python are NOT having trouble with python. They are having trouble because they are trying to use packages that are just python bindings to absolutely massively complex c++ and Fortran libraries.
Often people using python don't even have a C compiler installed (let alone a fortran one for the scientific stuff), so pip blows up the first time they try to install a package that hasn't been pre-built for their system+python version.
https://learn.microsoft.com/en-us/nuget/reference/nuget-exe-...
Rust's system is probably the next best.
ObjC/Swift packaging is a flaming disaster in practice, unless it's improved since I jumped that ship. Last time, I remember every single project having to rely on Cocoapods.
I see anyone sticking with CJS syntax the same way I see Python devs who continue writing 2.7 code by choice in new projects and not because they are maintaining older projects.
Sure tree-shaking and browser support are nice, but they didn't have to make the syntax this complicated to achieve that. Not an issue with other languages.
The bigger thing is, I'm subject to however the deps I use want to export things, so they use a mix of those. Maybe in some cases you have to use `require` even if you don't want to, I forget.
Swift got fixed over time (which is why every basic SO question has 20 different answers for each Swift version), but it still sucks, and so does UIKit, and Xcode. That whole toolchain has been relegated to being just a dependency behind React Native for me. I mean look at the shitfest involved just to get a substring https://stackoverflow.com/questions/39677330/how-does-string...
Also doesn't play nice with publishing to custom pypi destinations (e.g. self-hosted Gitlab) in my experience. I could track down the issue but the code around was clearly a mess so that I gave up on that one.
https://hpc.guix.info/blog/2021/09/whats-in-a-package/ does a good job of explaining why installing packages like that is a complete shitshow.
i dont need them demystified, i need someone smarter than me to just tell me what to do lol
(Seriously, I’ve gotten so fed up with Python package management that I just use CondaPkg.jl, which uses Julia’s package manager to take care of Python packages. It is just so much cleaner and easier to use than anything in Python.)