Fetch flask_compress version from __version__ module#1797
Fetch flask_compress version from __version__ module#1797europa502 wants to merge 1 commit intoplotly:devfrom
Conversation
| _flask_compress_version = parse_version(get_distribution("flask-compress").version) | ||
| except DistributionNotFound: | ||
| from flask_compress import __version__ as _flask_compress_version | ||
| _flask_compress_version = parse_version(_flask_compress_version) |
There was a problem hiding this comment.
Interesting, nice find! Unfortunately flask_compress.__version__ doesn't seem to exist until v1.10, which is probably why get_distribution was used in the first place.
I'd suggest a further fallback for the AttributeError: module 'flask_compress' has no attribute '__version__' you'll get before v1.10.0 that assumes it's maybe parse_version("1.9.0") (all that matters is >=1.6.0)
Another thing to note though: the default for compress was changed to False in Dash 2.0 (on the theory that for local dev this compression just slows things down, and for production deployments this is normally handled at a lower level like gunicorn). So this whole issue is irrelevant for most people as long as it doesn't error.
So if you're feeling adventurous, we could probably take this this whole block, plus the original from flask_compress import Compress AND the block where we use this to modify the server config:
Lines 308 to 316 in b32ac95
and move it into the block where we actually turn compression on, so the only people who will hit any of this code will be those who explicitly enable compression, everyone else won't even import the module.
Lines 453 to 455 in b32ac95
If we do this we'll just want to manually check that you actually do get gzip compression with current flask_compress
|
It looks like this issue was addressed independently in |
Fix for #1606
Added code to handle "pkg_resources.DistributionNotFound: The 'flask-compress' distribution was not found and is required by the application" while building app with cx_freeze.
Since version is included only in and above cx_freeze 1.10.0, I've added the try/except condition.