- [bug] setup.py won't install argparse if on
Python 2.7/3.2
+- [feature] script_location can be interpreted
+ by pkg_resources.resource_filename(), if
+ it is a non-absolute URI that contains
+ colons. This scheme is the same
+ one used by Pyramid. [#29]
+
0.2.1
=====
- [bug] Fixed the generation of CHECK constraint,
@classmethod
def from_config(cls, config):
return ScriptDirectory(
- config.get_main_option('script_location'),
+ util.coerce_resource_to_filename(
+ config.get_main_option('script_location')
+ ),
file_template = config.get_main_option(
'file_template',
_default_file_template)
else:
attr_names.add(methname)
+def coerce_resource_to_filename(fname):
+ """Interpret a filename as either a filesystem location or as a package resource.
+
+ Names that are non absolute paths and contain a colon
+ are interpreted as resources and coerced to a file location.
+
+ """
+ if not os.path.isabs(fname) and ":" in fname:
+ import pkg_resources
+ fname = pkg_resources.resource_filename(*fname.split(':'))
+ return fname
+
def status(_statmsg, fn, *arg, **kw):
msg(_statmsg + "...", False)
try:
[alembic]
# path to migration scripts
- script_location = %(here)s/alembic
+ script_location = alembic
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
* ``[alembic]`` - this is the section read by Alembic to determine configuration. Alembic
itself does not directly read any other areas of the file.
-* ``script_location`` - this is the location of the Alembic environment, relative to
- the current directory, unless the path is an absolute file path.
+* ``script_location`` - this is the location of the Alembic environment. It is normally
+ specified as a filesystem location, either relative or absolute. If the location is
+ a relative path, it's interpreted as relative to the current directory.
+
This is the only key required by Alembic in all cases. The generation
of the .ini file by the command ``alembic init alembic`` automatically placed the
- directory name ``alembic`` here.
+ directory name ``alembic`` here. The special variable ``%(here)s`` can also be used,
+ as in ``%(here)s/alembic``.
+
+ For support of applications that package themselves into .egg files, the value can
+ also be specified
+ as a `package resource <http://packages.python.org/distribute/pkg_resources.html>`_, in which
+ case ``resource_filename()`` is used to find the file (new in 0.2.2). Any non-absolute
+ URI which contains colons is interpreted here as a resource name, rather than
+ a straight filename.
+
* ``file_template`` - this is the naming scheme used to generate new migration files.
The value present is the default, so is commented out. The two tokens available
are ``%%(rev)s`` and ``%%(slug)s``, where ``%%(slug)s`` is a truncated string derived