24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions
https://www.bitecode.dev/
Email: contact at bitecode.dev
3901.
Pyflow: An Alternative to Poetry and Pyenv(github.com ↗)
3 points · by BiteCode_dev · 5y ago · 2 comments
comment 5y ago · link · parent
If any script, or yourself, run "pip install" using admin rights (the default on a lot of container techs), you have a chance to break it.
comment 5y ago · link · parent
A venv is just a dir and some path, and your os already have some dedicated to their own python install, even if it's not called a venv, but something like dist-packages + manual PATH fudging.
This proposal makes the distinction clearer by putting safeguard to NOT to mess up with the system stdlib.
You should be using "--user" or a local venv, and "-m" to call commands.
See my other comments for more tooling.
comment 5y ago · link · parent
debian packagers won't use pip for obvious reasons. dev need pip because it's portable, and doesn't need packagers validation.
It would have been better if something like nix would have been adopted 30 years ago by both community, but it hasn't been so we have several packages managers. It's even worst now with poetry, conda, snap, flatpack and docker.
> why 'put these files in these locations' is being solved implicitly by running imperative, non-deterministic commands to mutate things in-place, rather than e.g. extracting a .tar.gz of known-good dependencies.
pip now uses wheels, and basically does that. Whl files are zip, and pip just unpack it at a know location. The problem is, this location is currently shared with the OS if you don't use --user or a venv. This article address that problems. My other comment also talk about some other solution.
It's very hacky, because, well legacy and all that.
comment 5y ago · link · parent
Nix is pretty much incompatible with everything, because our entire legacy of software stack has state, and we need to accommodate for it.
So we keep adding those hacks because we favor compat above purity.
Even nix has to, after all, there plenty of bash calls in NixOS config scripts as soon as you do something non trivial.
comment 5y ago · link · parent
PEP 852 is the another one to follow up: https://www.python.org/dev/peps/pep-0582/
It basically uses the concept of node_modules, making python interpreters load any local directory names `__pypackages__` . There are 2 differences though:
• Unlike JS, python can only have one version of each lib for a given setup.
• Since having several versions of python often matters, you may have several __pypackages__/X.Y sub dirs to cater to each of them.
It also forces you to use "-m" to call commands written in Python, which is the best practice anyway. I hope it will push jupyter to fix "-m" on windows for them because that's a blocker for beginners.
If you are not already using "-m", start now. It solves a lot of different problems with running python cli programs. It's an old flag, but too few people know about it.
E.G: instead of running "black" or "pylint", do "python -m black" or "python -m pylint". Or course you may want to chose a specific version of python, so "python3.8 -m black" for unix, or "py -3.8 -m black" on windows.
To test out the __pypackages__ concept, give a try to the pdm project: https://github.com/pdm-project/pdm
At last, some other tools that I wish people knew more about that solves packaging issues:
• pyflow (https://github.com/David-OConnor/pyflow): it's a package manager like poetry, but it also installs whatever python you want like pyenv. Except it provides the binary, no need to compile anything. It's a young project with plenty of bugs, but I wish it succeeds because it's really a great concept. Give it a try, it needs users and we would all benefit from it becoming popular as it's a very sane way of setuping a python dev env.
• shiv (https://shiv.readthedocs.io/): it leverages the concept of zipapp, see PEP 441 from 2013, meaning the ability that python has to execute code inside a zip file. It's a successor to pex. Basically it lets you bundle your code + all deps inside a zip, like a Java .war file. You can then run the resulting zip, a .pyz file, like if it were a regular .py file. It will unzip on the first execution automatically and run transparently. It makes deployment almost as easy as with golang.
• nuitka (https://nuitka.net/): takes your code and all dependencies, turns them into C, and compiles it. Although it does require a bit of setup, since it needs headers and a compiler, it results reliably in a standalone compiled executable that will run on the same architecture with no need for anything else. Also it will speed up your Python program, up to 4 times. In my experience, it's also easier and more robust than pyinstaller, cx_freeze and so on.
• pyodide (https://pyodide.org/en/stable/): python compiled to WASM to run in the Web browser. Useless for web programming given the huge size of the runtime, but great for teaching, as it allows students to basically access a zero install full featured python dev env by clicking a link. Try it out, it's awesome, you can even create and query a sqlite db, thanks to the virtual FS: https://notebook.basthon.fr/
comment 5y ago · link · parent
Just because something is common doesn't mean it's good for you.
I'm not against closed software mind you, I'm using some myself, but the web as a platform has reached this amazing stage because it's been built on openness. And now the very same companies that became rich thanks to this openness want to close it to get all the benefits for themself.
comment 5y ago · link · parent
No, but I'm expecting the average user to be able to enjoy an open ecosystem. Such as bookmarklet, addons, client side widgets, electron apps, WASM plugins, and all the wonderful things we can't yet think of now.
Instead, we will have one more walled garden.
And just like that, piece by piece, the next step in the IT revolution will be more and more close. Because that's the plan, that's what they want. Something the computer runs, but has no control over.
comment 5y ago · link · parent
I've seen data scientists handling big code bases. The problem was not they couldn't use the language features. The problem is that they would be always lacking essential information for their mission because their is not enough time in a day for a regular human being.
They would put a md5 hashed password in their db, create an xml format to be reusable only to realize they'll need to hard code some value later, or have a gunicorn running to a crawl because they didn't know how to calibrate the number of workers.
It's just too many things to know. Once they mastered that, other things would come to bite them.
comment 5y ago · link · parent
Just like if you are standing on your two legs most of the day and sprint once in a while, you can be considered a runner. Sure, you can play with semantics, but most people cannot run a marathon.
> The attitude of considering programming a mundane craft to be picked up as-you-go is the main reason why the scientific software landscape is such a shitshow.
Err... That's kinda my point?
> And as such you should be expected to become a decently proficient programmer.
It's very, very hard to be good in 2 different fields. Most people won't have the ability or the context to do so. Even if they did, the time and energy spent to do so would be taken from their main activity, which is why we employ them in the first place.
It's not reasonable to ask a data scientist, geographer, biologist or physicist to follow up with the right practices to deploy the latest sci-stack on a linux server, understand the trade off between GIL locked python thread, asyncio and multiprocessing or spell out what WSGI stands for.
Hell, I know a lot of professional programmers that don't know those things
> Physicists are not mathematicians, and yet they are required to acquire a relatively high degree of proficiency in maths
The quantity of information required to be learned is of one or two orders of magnitude, because the field of maths required to perform physics is quite stable, and well understood.
IT is a very young field, in constant flux. The scientific stack is a moving target, not to even mention the web one. Nobody can expect them to understand python, numpy, pandas, then a web framework, then css, then js, and html, probably some frameworks for them, a builder or two, how to deploy all that stuff in dev, in prod and architectural concerns for linking all that stuff.
That's crazy talk.
comment 5y ago · link · parent
A data scientist is not even a somebody trained as a programmer. Their strong suit is data analysis, and it turns out one of the tool to manipulate data today are programming languages so their do it.
But I as a Python trainer, I train data analyst regularly, and they don't have a clue about language ecosystems, how the OS work, data formats or reliable software architecture.
They mainly want to output their graph, pdf report or other media to serve their conclusion. They may want to create some reusable algo, or machine learning model, but that's the limit most of them hit.
If one take their code and put it in prod (which I know happens, don't get me wrong), that's not the data scientist fault. They are doing their job, in which programming is just one of the many means to an end, and is not their specialty.
comment 5y ago · link · parent
Just like I'm not a data scientists, I'm a programmer.
Now, I can use pandas in a pinch and makes pretty graphs, but my statistical analysis will never be on part with yours.
Just like a pianist hobbyist will have a hard time to rival somebody who does that 40 hours a week, although he may be able to play a few fantastic pieces.
Hell, even a web dev programmers, if ask to code a GUI desktop app, is not going to do a good job.
IT is becoming a very large field.
And scientists are not even from this field.
comment 5y ago · link · parent
Again, if it's not possible, then you accept the imperfection of the result, or provide better tooling.
There is no blame to put on them whatsoever.
comment 5y ago · link · parent
- unreasonable people will not doubt themself, but reasonable people will. So this discussion has a tendency to turn in favor of the unreasonable.
- unreasonable persons will make you pay for not being on their side. Coming to them gives them a heads up for doing that.
- you usually have less problems with reasonable people, so if you do have a problem, there is more chance the opposite party is not reasonable, and hence risking point 1 or 2.
So I'd say, "test if the opposite side is reasonable with a smaller grievance first".
comment 5y ago · link · parent
Here is an example instance: https://notebook.basthon.fr/
The thing is, creating a whole stack in pure JS would be very hard, since the current scientific stacks uses a lot of fortran, assembly and C with python to bind them all. Or julia. It's millions of man hours we are talking about.
So compiling Python into WASM is probably the best deal for such an app.
For the regular web, it would be a deal breaker: you don't want to load 15 mo of runtime before being able to interact with a web page. But for such a scientific app, it's not a problem. Besides, were you to write it entirely in JS, the size would be huge as well.
comment 5y ago · link · parent
I want my physicists to spend their mental effort on physics, not on software architecture.
comment 5y ago · link · parent
At some point, the status quo was slavery, death penalty, child work, women domination and against gays.
Just because if you do nothing the current equilibrium tends in some direction doesn't mean it's the right thing to do.