Closed sonthonaxrk closed 4 years ago
Thanks @sonthonaxrk,
I use pkg_resources
to safely load json files, as I understand, the filesystem cannot be guaranteed, using the technique, "find a json file in the same folder as my file", like
os.path.join(os.path.dirname(__file__), 'file.json')
is not portable, due to embedded environments using eggs and such, where the entire package is just one big zip file, you cannot access the filesystem like this.
But anyway, I understand the difficulty, I will try to use "code generation" to generate raw python code, rather than load json files. This is probably related to https://github.com/xonsh/xonsh/issues/3607 -- are your customers using fedora, by chance?
Hey @jquast thanks for the fast response. I'm not entirely sure if it's the same issue since I can't find a stack trace linked. To be honest our customers are on everything and I've got to be really defensive about packaging.
Basically pkg_resources has some pretty gnarly side effects when at import time. It'd be really great if it was generated via code.
Out of interest, what is version.json for? Could it just be a plain python file?
Hey this is a popular and useful project, it's a 2rd degree transitive dependency in a project I'm using, tabulate -> wcwidth.
Unfortunately some of our slightly dimmer witted customers who refuse to use virtual environments, and live within a hosted Jupyter notebook are getting this kind of error.
Because importing pkg_resources actually requires that the dependency structure of an environment be 100% okay, and this is actually a bit of an unexpected side effect (as we get non-devs messing about with pip).
(I'm going to raise this as a bug with the python core team).