| 17 Feb 2022 |
worldofgeese | I've changed the code of data.py to access the package resource data.json like so:
from importlib import resources
with resources.open_text("little_bits_of_buddha", "data.json") as json_file:
data = json.load(json_file)
def random_sutta():
attributed_quotes = []
for collection in data["collection"].values():
for quote in collection.values():
attributed_quotes.append(quote)
return random.choice(attributed_quotes)
which again works with poetry run lbob and nix build && ./result/bin/lbob but continues to give errors accessing the resource from inside dockerTools.streamLayeredImage produced image:
File "/nix/store/y3i0wgxmwc9l2r5a167isx4bnpsm4fih-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/data.py", line 7, in <module>
with resources.open_text(__package__, "data.json") as json_file:
File "/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/lib/python3.9/importlib/resources.py", line 121, in open_text
open_binary(package, resource), encoding=encoding, errors=errors)
File "/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/lib/python3.9/importlib/resources.py", line 111, in open_binary
raise FileNotFoundError(message)
FileNotFoundError: 'data.json' resource not found in 'little_bits_of_buddha'
| 07:39:15 |
worldofgeese | * I've changed the code of data.py to access the package resource data.json like so:
from importlib import resources
with resources.open_text("little_bits_of_buddha", "data.json") as json_file:
data = json.load(json_file)
def random_sutta():
attributed_quotes = []
for collection in data["collection"].values():
for quote in collection.values():
attributed_quotes.append(quote)
return random.choice(attributed_quotes)
which again works with poetry run lbob and nix build && ./result/bin/lbob but continues to give errors accessing the resource from inside a dockerTools.streamLayeredImage produced image:
File "/nix/store/y3i0wgxmwc9l2r5a167isx4bnpsm4fih-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/data.py", line 7, in <module>
with resources.open_text(__package__, "data.json") as json_file:
File "/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/lib/python3.9/importlib/resources.py", line 121, in open_text
open_binary(package, resource), encoding=encoding, errors=errors)
File "/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/lib/python3.9/importlib/resources.py", line 111, in open_binary
raise FileNotFoundError(message)
FileNotFoundError: 'data.json' resource not found in 'little_bits_of_buddha'
| 07:39:42 |
K900 | Post the actual image config | 07:40:40 |
K900 | And check if the file is there in your container | 07:40:47 |
worldofgeese | Image config is here from line 23 | 07:41:43 |
worldofgeese | bash-5.1# ls /nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/
__pycache__ app.py data.json data.py run.py
| 07:44:38 |
K900 | That is weird | 07:47:10 |
K900 | What is PYTHONPATH set to in lbob? | 07:47:15 |
worldofgeese | I haven't set it explicitly, should I use this StackOverflow answer to find out? | 07:49:07 |
worldofgeese | And inside or outside the container? | 07:49:23 |
K900 | Inside the container, just run cat $(which lbob) | 07:50:36 |
worldofgeese | bash-5.1# cat $(which lbob)
#! /nix/store/2kh3c4v2vf6d6xg6c9n8zvfpwf3zzwca-bash-5.1-p12/bin/bash -e
export PATH='/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/bin:/nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/bin:/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/bin'${PATH:+':'}$PATH
export PYTHONNOUSERSITE='true'
exec -a "$0" "/nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/bin/.lbob-wrapped" "$@"
| 07:51:42 |
K900 | And now cat /nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/bin/.lbob-wrapped | 07:52:26 |
worldofgeese | bash-5.1# cat /nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/bin/.lbob-wrapped
#!/nix/store/i6vabb4div9iy6lsl642d86k1q8riasn-python3-3.9.9/bin/python3.9
# -*- coding: utf-8 -*-
import sys;import site;import functools;sys.argv[0] = '/nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/bin/lbob';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/3jiz0vgryj2si4bglz14wwak4xna80vy-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages','/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/lib/python3.9/site-packages','/nix/store/fn3hgaz6sfr3cpvmzd1lxl10rivs96wc-python3.9-jinja2-3.0.3/lib/python3.9/site-packages','/nix/store/j68i2axxrgn0wcqxfw4lyqqw94v9r889-python3.9-markupsafe-2.0.1/lib/python3.9/site-packages','/nix/store/lvcvbrk3qm14r7qziblnkgcxmx4wj8rb-python3.9-werkzeug-2.0.3/lib/python3.9/site-packages','/nix/store/1fg49005dvz6nl8xmz677zl3vd4pn5li-python3.9-click-8.0.3/lib/python3.9/site-packages','/nix/store/m6zvprr8r0972c1kc0hjsz3ix6qx7jxd-python3.9-itsdangerous-2.0.1/lib/python3.9/site-packages','/nix/store/jsf2dfbia2n1gwyh4m0kjwq51smdyxsp-python3.9-setuptools-57.2.0/lib/python3.9/site-packages'], site._init_pathinfo());
import re
import sys
from little_bits_of_buddha.app import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
| 07:53:26 |
K900 | That's weird | 07:53:45 |
K900 | It's definitely there | 07:53:47 |
worldofgeese | Should I file this as a bug? | 07:55:12 |
K900 | I'm not sure where you would file this, honestly | 07:56:15 |
K900 | Because it's probably not a poetry2nix bug | 07:56:21 |
K900 | It might be an importlib bug | 07:56:26 |
worldofgeese | Isn't it odd it works as both a Nix derivation and with poetry run lbob but not inside a container? | 07:57:26 |
K900 | It is | 07:57:43 |
worldofgeese | So maybe it's a dockerTools bug? | 07:57:47 |
K900 | It might be | 07:57:54 |
worldofgeese | I think my next step will be to build a container image with something like buildah or just writing a plain Dockerfile and test if it works that way. If it does, I'll file the issue as a dockerTools bug and let the packagers decide what it's a bug of | 08:00:17 |
| 21 Feb 2022 |
Jairo Llopis | Redacted or Malformed Event | 12:47:43 |
Jairo Llopis | hello people. I'm trying to get a proper devShell. So far I have followed the example from https://github.com/nix-community/poetry2nix#example-shellnix | 12:48:56 |
Jairo Llopis | It's working, but... poetry is not inside the shell. How to add it? | 12:49:14 |
Jairo Llopis | > nix develop -c which python
/nix/store/08aymzy89d1r2sviq2rn00ciip25wha4-python3-3.9.10-env/bin/python
> nix develop -c which poetry
/var/home/yajo/.local/bin/poetry
| 12:50:19 |
Jairo Llopis | See? I expected poetry to be available from the nix store instead... how to do that? | 12:51:02 |