Better HN
topnewbestaskshowjobs
Log inSign up

BiteCode_dev

24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions

I write to save you time and effort when dealing with Python:

https://www.bitecode.dev/

Email: contact at bitecode.dev

Submissions

3901.

Pyflow: An Alternative to Poetry and Pyenv(github.com ↗)

3 points · by BiteCode_dev · 5y ago · 2 comments

comment 5y ago · link · parent

The container has a system python stdlib, and it's used by apt. If it breaks, everything breaks. I've destroyed it twice, with style I must say.

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

It's already the case, that's why you see some mistaken tutorials telling you to "sudo pip install".

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

No, it fact it will make your workflow easier: no matter what, no script using pip will break your install.

comment 5y ago · link · parent

thanks, I'll fix my bad copy paste.

comment 5y ago · link · parent

> If 'apt-get dist-upgrade' is breaking the packages we pip-installed into /usr/local, I'd ask (a) why we're using two package managers,

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

While I agree about Nix being a cleaner solution, it will never be adopted, because... it's a cleaner solution.

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

It's a good safeguard, and it's going in the direction of the other initiatives to make python package management default behavior saner.

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

People also consume refined sugar, alcohol, saturated fat and cigarettes regularly.

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

Yes, it's a wonderful filter, isn't it?

comment 5y ago · link · parent

Sure but this puts the burden on the citizen.

I'm all about taking your health into your hands, but it won't hold on the long run.

We also need strong policies against this.

comment 5y ago · link · parent

> I fail to see how it being exposed to the javascript running on the page or not makes a meaningful difference to the user. Are we expecting the average user to interact with the page via the developer console or something?

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

If you think functions and modules as an example of what makes a code maintanable, then I'm afraid we won't be able to agree.

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

Yes, but something you can't manipulate client side because we don't want those hippies to have control of the next web thing this time.

comment 5y ago · link · parent

You, the dev. Not you the client, hence the user. It's closed software by design, and we all have seen where it leads to.

comment 5y ago · link · parent

Just like devoos, this is a fallacy. Eventually you can't be an expert in everything. Lost devops are very good at either dev or sysadmin, and not too bad at the other. Same for data scientists.

comment 5y ago · link · parent

It's not a matter of responsability or will, but of ability. Expecting a fish to fly is a very bad working relationship.

comment 5y ago · link · parent

If you want to play with names and semantics, I'll leave you to it.

That's not my point.

comment 5y ago · link · parent

Oh no, I train frontend developers, and they know a lot more than data scientists when it's about programming.

I'm not talking about complete beginners. I don't train beginners.

comment 5y ago · link · parent

> If you spend a non-negligible amount of your time telling a computer what to do, you are, indeed, a programmer. And as such you should be expected to become a decently proficient programmer.

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

Even among devs with very close speciality, the difference in productivity is immense. Take a iOS team, make them dev a MacOS desktop app, and see their output plummet in their of productivity or quality. They will end up doing a good job, but it will take between 6 months and a year to catch up with a specialized team.

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

Err... That's kinda my point ?

comment 5y ago · link · parent

Data scientists are not programmers. They are data scientists.

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

Yeah, that's also part of the "doubt" dichotomy: if you are reasonable, you will ask yourself "am I unreasonable?" while unreasonable people will be certain they are being reasonable.

comment 5y ago · link · parent

Scientists are not meant to create code that ends up on production. Once they have a working concept, they should team up with a programmer to make it live.

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

It works well with reasonable people, but it has some flaws:

- 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

ublock origin is available on firefox mobile is you use android.

comment 5y ago · link · parent

You can, with pyodine: https://github.com/pyodide/pyodide

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

That's because they are not programmers. One should not expect them to be experts in 2 fields. They do their work with the tool provided, and if we want a better output, we need to provide better tooling or accept what comes out.

I want my physicists to spend their mental effort on physics, not on software architecture.

comment 5y ago · link · parent

The market also leads to food full of fat and sugar. Without strong campaigns against cigarettes, the market would make sure it's everywhere. The market also has no problem showing deeply violent content to children.

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.

1
130131132
184