Could someone ELI7 why python is struggling so hard with dependencies and dependency management when in the Java world this is a solved problem and just works with maven, which is working so damn well it last got updated in November 2019, and the biggest fight going is whether you should use gradle as client instead of maven to access the same dependency ecosystem? I had to set up Python projects for some machine lea…
People always criticise Python for dependency management, but I've never found it to be that bad. virtualenv with requirements.txt has been completely fine in my experience with medium-sized projects. If necessary you can pin versions with a separate version-locked requirements.txt, and populate that from a base requirements file.
You don't really need a virtualenv
141–148 of 148 posts
Re: You don't really need a virtualenv
#142Earlier quoted context omitted.
Or to be precise, it is a solved issue -- several times over. After years of meandering, I think it is safe to say that deployment of Python libraries is pretty much resolved in one, general way: we have the wheel/PyPI/pip toolchain, and that's about it. On the other hand, deployment of Python applications is still unresolved, and there is no single standard method to ensure both compatibility with and isolation from…
All of the above are suitable for deployment on your cloud servers but not as distribution mechanisms to end users. End users cannot set up virtual envs and pip install stuff into them (which sometimes needs external tools like make). The candidates for distribution are things like pyinstaller or pex (still not fully mature) but I don't think they are as easy to use as Java jars or Go binaries.
> All of the above are suitable for deployment on your cloud servers but not as distribution mechanisms to end users.
virtualenv's are also not a distribution mechanism because they aren't portable (unless that has changed). I can't "distribute" a virtualenv to a host. I can only use virtualenv's to change how pip (or poetry) installs artifacts. Pip is still your distribution mechanism, virtualenv is a runtime customization to change how your distributed artifacts are loaded.
Re: You don't really need a virtualenv
#143This was a good article and looks like an interesting project. Regardless of whether or not you choose to _deploy_ with Docker, _developing_ in Docker containers using the VS Code Remote extensions really solved all of Python's (and Javascript's) annoying packaging problems for me, with the bonus that you also get to specify any additional (non-Python) dependencies right there in the repo Dockerfile and have the deve…
Ive never quite managed to get the hang of setting up a dev container. I'ts a bit too tricky for me. I have resorted to using a throwaway dev container which mimics the local storage of packages. Hopefully someone find the below bash function useful. The only issue I have using this method is that I cant use VSCode to Debug, which I am hoping to find a nice solution for, but nothing yet. function python() { docker ru…
Re: You don't really need a virtualenv
#144Earlier quoted context omitted.
Honestly just use poetry.
This comment would be vastly more valuable (to me at least) if you said why. The parent’s workflow mirrors my own and doesn’t feel onerous. Being completely unfamiliar, their site says: > Poetry either uses your configured virtualenvs or creates its own to always be isolated from your system. So it is just a pretty wrapper? I’m missing the value add.
The "poetry run" command is extremely nice. You can do something like "poetry run pytest" and put that in a Makefile and be done. You don't have to worry about making sure you're in the virtualenv. I basically don't drop into a full shell anymore (although "poetry shell" lets you do that) because I don't like having to juggle whether I'm in a virtualenv or not.
"poetry build" will build your project into tarballs that pip can install. It's not earth-shattering, but it's nice to have it one tool.
The value add is a large number of QoL improvements. I don't think there are any features that other solutions can't compete on; Poetry just makes it easier to do the same things. I would highly suggest it for anything where other people are going to work on it, because of the QoL, but for personal projects I don't think it really matters.
Re: You don't really need a virtualenv
#145Earlier quoted context omitted.
Ah I see, that makes sense. I believe Node modules typically fall back to building from source in those cases. Which can be a little slow, but generally works reliably.
I can see that, but we rely on a bunch of system libraries (libjpeg/zlib, + optional libtiff/freetype/etc, and python headers as well). Pretty much by definition, if we don't provide binaries, it's not going to be that simple. I'd say maybe 25-50% of developer linux workstations have the appropriate packages and will compile out of the box, and if they don't, it's almost always a one line command to install them with…
Re: You don't really need a virtualenv
#146Earlier quoted context omitted.
It's absolutely not required, I assure you. If you run the Python binary inside the venv you have the same environment as if you'd activated the venv, but only for that execution and not affecting your shell. Try making a venv, running python, and looking at sys.path.
I assure you 100%, it is required for everything to work, it's not just here for the show. One of the thing that the virtual environment does is modify the PATH to lookup executables from the virtual environment first. This is to ensure that when a script calls binaries like mypy/python, it's going to find the same binary from the environment it's currently running in. Typically if the environment is not activated, p…
Re: You don't really need a virtualenv
#147Earlier quoted context omitted.
What do you mean "python install[s] globally and only globally"? That's not true. You can instruct pip to install to any place you want.
the thing is python cli has no concept of locally scoped libraries. you can install libs wherever you want, but all python.exe will refer to the same global location. this is why you need to activate virtualenv every time you open a new command line, so that it can set ENV variables for the current session and force python to use the locally scoped folders. While in C# et all. the compiler knows to check files locall…
Re: You don't really need a virtualenv
#148Earlier quoted context omitted.
Ive never quite managed to get the hang of setting up a dev container. I'ts a bit too tricky for me. I have resorted to using a throwaway dev container which mimics the local storage of packages. Hopefully someone find the below bash function useful. The only issue I have using this method is that I cant use VSCode to Debug, which I am hoping to find a nice solution for, but nothing yet. function python() { docker ru…
Couldn't you use this? https://code.visualstudio.com/docs/remote/containers