23 ms·
I’m curious. Can you explain the problems you were having? And how they would’ve been solved by a static binary. > Trying to load source files from all over th
by Spiritus 6y ago
I’m curious. Can you explain the problems you were having? And how they would’ve been solved by a static binary.
> Trying to load source files from all over the filesystem at runtime is hell.
This sounds like a mess unrelated to Python. Why are you trying to load source files from "all over the filesystem" at runtime?
> I would love to see a move towards "static" binaries that package everything together into a single, self-contained unit.
Compiling source files from all over the filesystem would be equally annoying.
- IshKebab 6y agoAssuming you are genuinely asking... Python programs are almost always run from source, and they usually import third party libraries. Those libraries are installed by Pip... somewhere on your system. And then Python has to find it somehow at runtime. That relies on environment variables being set correctly, and works differently on different systems and is basically a huge mess even before you consider things like virtualenv and the fact that non-Linux systems usually have multiple copies of Python installed (and Python 2 and 3!). It's basically a huge mess. There's even an XKCD about it. Consider the alternative: Go compiles programs to a single statically linked executable with no dependencies. You literally just copy one file to your target machine and run it. It basically can't fail. That's part of the reason Go is so popular for server stuff. And it's not just because Python isn't compiled. Other scripting languages handle this much better. Even JavaScript - for all the hate node_modules gets for being enormous, at least it works reliably!
- Spiritus 6y agoYes, I was genuinely asking. I'm very familiar with how the Python ecosystem works (I've been using it professionally for the past 8 years or so), and I disagree with your assessment. At least not when comparing to other dynamic languages. > Those libraries are installed by Pip... somewhere on your system. They go into your virtualenv. > And then Python has to find it somehow at runtime. If you use a virtualenv, this works 99.9% of the time. > That relies on environment variables being set correctly What environment variables? Just use `./venv/bin/python` directly without environment variables. > a huge mess even before you consider things like virtualenv There's nothing to consider, always use a virtualenv. It's the same for thing for Node, except it implicitly handles it for you. > and the fact that non-Linux systems usually have multiple copies of Python installed (and Python 2 and 3!). How is that a problem? Just pick the interpreter you want to use when creating the virtualenv: virtualenv -p /usr/bin/python2 venv virtualenv -p python3 venv virtualenv -p python3.7 venv > Consider the alternative: Go compiles programs to a single statically linked executable with no dependencies. You literally just copy one file to your target machine and run it. It basically can't fail. That's part of the reason Go is so popular for server stuff. I agree that Go got it mostly right and it just works, except for that fact that it didn't even have a package manager for like 10 years so pinning dependencies was impossible unless you forked repositories. > Even JavaScript - for all the hate node_modules gets for being enormous, at least it works reliably! In what way is Python + virtualenv + requirements.txt less reliable?
- ghshephard 6y ago100% agree with the one addendum that you may want to use virtualenvwrapper.sh - as it makes using virtualenv somewhat more convenient. Mostly syntactic sugar though.
- IshKebab 6y ago"There's no issue, it's easy! Just don't do it the obvious way. Instead use this other tool, then create an environment, and don't forget to activate it. You need to specify the interpreter you want, and then installing the dependencies is simple, just run `pip3 install -r requirements.txt`. I don't know what the problem is?" > It's the same for thing for Node, except it implicitly handles it for you. Indeed.
- marton_s 6y ago> for all the hate node_modules gets for being enormous, at least it works reliably! Funnily enough node_modules is one of the main regrets Ryan Dahl, the creator of Node.js has: https://www.youtube.com/watch?v=M3BM9TB-8yA&t=755s https://www.youtube.com/watch?v=M3BM9TB-8yA&t=755s
- IshKebab 6y agoYeah it's not a great design but it does at least work reliably!
- PeterisP 6y agoThe python package requires a C extension that fails to compile because it requires some (non-python) dependency C library which it can't find (or use) despite it being installed to the system. Often because it expects version X but the system has installed version Y and I can't or don't want to install the particular version that this python package needs to compile its C code.