Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask app installed as egg raises builtins.NotADirectoryError for templates #1562

Closed
davidmegginson opened this issue Aug 26, 2015 · 7 comments

Comments

@davidmegginson
Copy link

I've created a MANIFEST.in file and added the include_package_data flag to setup as recommended in #84 and have confirmed that the template files do appear in the egg file installed into my virtualenv:

(test)david@snape:~$ unzip -l .virtualenvs/test/lib/python3.4/site-packages/hxl_proxy-0.3-py3.4.egg | grep error
      154  2015-08-26 16:48   hxl_proxy/templates/error.html

When I run from the source directory, all is fine. When I try to run from the egg installed in the virtualenv, I get the following error:

Traceback (most recent call last):
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/app.py", line 1379, in handle_user_exception
    return handler(e)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/hxl_proxy-0.3-py3.4.egg/hxl_proxy/controllers.py", line 44, in error
    return render_template('error.html', message=str(e)), status
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/templating.py", line 127, in render_template
    return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/environment.py", line 851, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/environment.py", line 812, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/environment.py", line 774, in _load_template
    cache_key = self.loader.get_source(self, name)[1]
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Flask-0.10.1-py3.4.egg/flask/templating.py", line 60, in get_source
    return loader.get_source(environment, local_name)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/loaders.py", line 171, in get_source
    f = open_if_exists(filename)
  File "/home/david/.virtualenvs/test/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/utils.py", line 151, in open_if_exists
    return open(filename, mode)
NotADirectoryError: [Errno 20] Not a directory: '/home/david/.virtualenvs/test/lib/python3.4/site-packages/hxl_proxy-0.3-py3.4.egg/hxl_proxy/templates/error.html'
@dkasak
Copy link

dkasak commented Dec 4, 2015

@davidmegginson, just stumbled across this myself. You can work around it by giving zip_safe=False as a parameter to setup in your setup.py.

@davidmegginson
Copy link
Author

Thanks, Denis! That should make life much easier. I'll test when I'm back at my computer, then close.

davidmegginson added a commit to HXLStandard/hxl-proxy that referenced this issue Dec 7, 2015
@davidmegginson
Copy link
Author

Confirmed.

@RonnyPfannschmidt
Copy link
Contributor

isnt the actual problem that a filesystemloader is used instead of a packageloader?

@davidmegginson
Copy link
Author

@RonnyPfannschmidt - would that be a configuration error in my app, or a core problem with flask? I'm still relatively new to the world of Python and WSGI.

@RonnyPfannschmidt
Copy link
Contributor

problem with flask

@davidmegginson
Copy link
Author

@RonnyPfannschmidt - would you want to create a new issue, referencing this one? This one has gone a bit off track, and I don't have the background to describe the problem properly.

samueldg added a commit to samueldg/snappass that referenced this issue Jul 16, 2016
Prevents NotADirectoryError's in flask templates

Ref.:
pallets/flask#1562
pallets/flask#1645
samueldg added a commit to samueldg/snappass that referenced this issue Jul 18, 2016
Prevents NotADirectoryError's in flask templates

Ref.:
pallets/flask#1562
pallets/flask#1645
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants