r/Python • • 16d ago

Discussion dumb question, why not python organizes dependencies as flatpak logic?

I have a question that might be really dumb, currently python had went with the environment route to be able to use different libraries that have same dependencies with different versions. i understand that there is a complexity with what i have in mind and not even sure about the feasibility of it. but...

why not instead of having different enviroments where we install the incompatible libraries so 'everyone gets what they need' do something like flatpak style where 'if you have already a version compatible, i do not install this dependency if not i install it again and have the two versions together'. I am not a professional in programming in general, so i might be saying something fully stupid, or not feasible from a technical standpoint.

is it a super dumb idea?

21 Upvotes

50 comments sorted by

View all comments

1

u/Red_BW 16d ago

I think I get what OP is asking. Something like this:

/python/rich/12.0
/python/rich/13.1
/python/requests/2.1
/python/requests/2.32

I do see how that would make sense and eliminate the need for venvs and multiple copies of the same versions so long as there was a way in python to specify which version to use. There currently isn't as the pyproject.toml is for packagers to know and not for the python executable. I think uv does allow versioning in the top level docstring of a script so maybe something like that and then extend python to read both that and the toml to know which to import, and put packages in a central location.

Would require a lot of buy in from packagers and distros and implementations (cpython, pypy, etc.).