@carlton the thing about multi-version support that I always wondered about it... If this feature existed, it would mean no global state, right? Since global state is often kept at module-level, and there would be several (maybe many) copies of each module.
"Ooh I have to configure structlog 1.2, 1.3 and better not forget 1.4" ;)
@tintvrtkovic @carlton Global (in the #Python sense of "global", i.e. module-level) state is kept in the module object in memory, but once that module object has been loaded from a file, it exists independently of the file it came from. So if you did load multiple different versions of a package, they'd all correspond to different module objects in memory, each of which could have its own global state. Heck, even with just one version of a package, you could load some module from that package a hundred times and get a hundred different module objects in memory, again each with its own individual global state.
This is kind of what the importlib.reload() function does, although IIRC it also tries to mix the original and reloaded versions of the module in a way that is supposed to make sense if you don't care about the old module. To get a true fresh and independent copy of the module object you'd have to use other importlib functions.
@carlton Some of my Ruby and Node friends feel Python's package management will never be adequate if this problem isn't addressed.
Assuming you don't mean multiple versions of the same package available everywhere but instead one per package, I think we'd basically need a separate site-packages directory location per package for this. 😬
@treyhunner Yeah, I have no grand solution waiting up my sleeve. Greater minds than mine can solve the how. 🥳
It’s frustrating when all dependencies (and the project) have to be on the same compatible ranges. A slow updating package blocks everyone else updating even if its usage of the target package are entirely internal.
🤷
@carlton @treyhunner To your last point, this is why we are still stuck on Python 3.12 for more projects that I care to admit to.
Since we can't stop authors from pinning to upper boundaries, I wish we had the mechanics to at least say, "IGNORE THIS" very loudly so we can move around it.
@webology @carlton @treyhunner
For this reason:
> When evaluating requires-python ranges for dependencies, uv only considers lower bounds and ignores upper bounds entirely.
https://docs.astral.sh/uv/concepts/resolution/#universal-resolution
@adamchainz @carlton @treyhunner Sorry, I was sharing two different thoughts which was confusing.
What I mean was we could not override package upper boundaries, and I should have known that UV has literally thought of everything and including this annoying situation.
See https://docs.astral.sh/uv/reference/settings/#override-dependencies
@carlton @treyhunner FWIW, "one module instance per process" is more an import system restriction rather than strictly being a packaging one. We'll potentially get to a point where different subinterpreters can load different versions of pure Python packages, but even if that happens, extension modules are still going to be constrained by the way platform dynamic library loading works.
In the meantime, `uv` version overrides at least offer an escape hatch for overly pessimistic upper limits.
@brettcannon @treyhunner @carlton
@mitsuhiko Has a blog post from earlier this year with thought on that - and it would be feasible without changes in the language and a lot of hackish stuff.
Me? just put the calls needing a different package version on the other end of a Celery-managed call.
(Actually - it could be done with subinterpreters now as well, in a way that would be a lot cleaner)
@carlton Down that path madness lies.
https://stackoverflow.com/questions/15806152/how-do-i-override-nested-npm-dependency-versions
I would like to use the grunt-contrib-jasmine NPM package. It has various dependencies. Part of the dependency graph looks like this: ─┬ [email protected] │ ├─┬ [email protected]....