ANN: Migration to New Extension Distribution
- From:
- Armin Ronacher
- Date:
- 2011-09-25 @ 17:23
Hi,
One of the mistakes I made in the design of the Flask extension thing
was buying into the namespace package thing. The idea was great but the
implementation of namespace packages in setuptools is a hack that only
worked for as long as people did not use pip. Now that pip is
widespread we suddenly have to deal with a whole lot of problems that
arise from mixing different namespace package installations formats.
Ever had a Flask extension not import even though it should? Yeah,
you're not alone and we want to fix this.
So how do we move forward from that? Flask 0.8 introduce a new thing
called "flask.ext" which is a special module that will redirect your
imports to the most appropriate location.
If you do "from flask.ext import sqlalchemy" for instance it will try
these to modules: "flask_sqlalchemy" and if that is missing it
dispatches to "flaskext.sqlalchemy". This way we can all change our
code to import from that "flask.ext" package and each extension can with
the next release or the one afterwards transition to regular Python
packages/modules.
You will not be affected when this move happens in the extensions when
you upgrade to the "flask.ext' package beforehand.
What happens if you want to support Flask < 0.8 with your code? We
provide the flask.ext module with a compatibility module also for older
Flask versions. For more information have a look at the new extension
documentation: http://flask.pocoo.org/docs/extensions/
The compatibility module as well as flask.ext itself is not entirely
final yet. I still need to make sure that the import redirection
implementation is stable and does not cause issues.
If you are an extension author: Do not upgrade to flask_name just yet,
let Flask 0.8 release first so that we have a more pleasant experience
for people doing the switch.
Regards,
Armin