Unable to find html file in pex executable

57 Views Asked by At

Hello I will try to define my issue: I have created a pex file with follow commnad:

$ pex --disable-cache . -e ${PYTHON_ENTRYPOINT} -o app.pex -R utils/tasks/templates

And I have my files as:

enter image description here

So when I try to run the pex file I getting follow error:

  File "/home/leraes93/.pex/installed_wheels/ee8bc6748d864a510e8298d9de49c5e41b75faed18b5649089a1a09295a6c8ef/Jinja2-3.1.2-py3-none-any.whl/jinja2/loaders.py", line 126, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/home/leraes93/.pex/installed_wheels/ee8bc6748d864a510e8298d9de49c5e41b75faed18b5649089a1a09295a6c8ef/Jinja2-3.1.2-py3-none-any.whl/jinja2/loaders.py", line 218, in get_source
    raise TemplateNotFound(template)

But if I check the pex conent with follow command is showing me the html files.

$ unzip -Z1 app.pex | grep password
.deps/medical_api-0.0.0-py3-none-any.whl/utils/tasks/templates/template_set_password.html
.deps/medical_api-0.0.0-py3-none-any.whl/utils/tasks/templates/template_set_password_succesfull.html
template_set_password.html
template_set_password_succesfull.html

And this is the part of the code where I calling that function: enter image description here

Also I include the files in the MANIFEST.in , setup.cfg and setup.py files enter image description here Any suggestion about what I'm doing wrong?

1

There are 1 best solutions below

0
Leonardo Radillo escobar On

I was able to read the file doing:

ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))

And then concatenate with the file I want to use.