3 ms·
This page, or series of pages—The State of Python Packaging in $YEAR—should have no reason to exist in the first place. But things being as they are, https://xk
by DemocracyFTW 5y ago
This page, or series of pages—The State of Python Packaging in $YEAR—should have no reason to exist in the first place. But things being as they are, https://xkcd.com/1987/ https://xkcd.com/1987/ is as relevant as ever. Compare what's going in the Python ecosystem with how e.g. `npm` works in NodeJS. You can hate NodeJS and npm all day long and point out a not-so-small number of problems and gotchas in the details, it's still lightyears ahead of anything Python has to offer in terms of reliability and simplicity. And it's not only Python's packaging system, it's the entire module import system that is a boat load of overcomplicated c**p. In NodeJS, when you want the contents of a module that lives at `/path/to/module.js`, you say `const x = require( '/path/to/module.js' )`. There's some amount of additional computation going on there in order to resolve relative and underspecified paths and to keep a cache of loaded modules, but other than that, the module contents are basically loaded, then `eval()`ed, that's it.
In Python, when you want to import a module from a path, you have to:
def module_from_path( name, path ):
import importlib
import importlib.util
spec = importlib.util.spec_from_file_location( name, path )
module = importlib.util.module_from_spec( spec )
sys.modules[ spec.name ] = module
spec.loader.exec_module( module )
return importlib.import_module( name )
wat?
- ViViDboarder 5y agoIn what cases is this even useful or necessary? In my 8 years of working Python, I’ve never once needed to import a module from an absolute path. Just because doing this one task is complicated doesn’t mean that the system is bad.
- touristtam 5y agoBoth PHP and Java have better package manager than python and arguably node. But a lot of devs don't find the language as sexy.