1. Michael Bayer
  2. alembic
  3. Issues


Issue #29 resolved

Allow specifying script_location as resource specification

Sok Ann Yap
created an issue

To deploy the migration scripts more easily, I intend to bundle the {{{script_location}}} directory together with my .egg package. This requires alembic to support using resource specification for {{{script_location}}}, otherwise I have to keep changing the value in the .ini file whenever a newer .egg is deployed.

Attached is a diff for that. And thanks for alembic, it is awesome :)

Comments (9)

  1. Michael Bayer repo owner

    OK, can you try out the attached patch. This patch has you specify the name as "egg:<name>" the way Python Paste (and others?) does, so that a windows filename like "C:/path/to/my/file" wouldn't be misinterpreted for example, and also keeps the pkg_resources import local to that usage to avoid an unnecessary dependency.

    I've had several people ask me about this feature so thanks for showing me the idea !

  2. Sok Ann Yap reporter

    The patch works after setting maxsplit to 1 for the first split. Perhaps it shall be set for the second split as well, just in case the file path contains a semicolon.

    Anyway, I am not sure about the "egg:" prefix. Pyramid, for example, uses just "<package name>:<file path>" for its asset specification, and it only checks for os.path.isabs to handle windows filename. I suppose such checking is insufficient when the code runs on linux while the path is for windows, but that should be a rare (or invalid?) use case.

  3. Michael Bayer repo owner

    Forgot the maxsplit, whoops. Does Pyramid distinguish between filesystem and pkg resources in the same way, just looking for a ":" ? A ":" seems like a pretty generic thing that might be in some weird quoted filesystem path. Looking at their docs at http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html#examples, Pyramid seems to expect that all locations are already resource locations, so they wouldn't have this issue. More docs on this at http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/assets.html#asset-specifications . That is, there's no guessing here, everything is a resource.

    They support Paste so like here: http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html#examples you see the "egg:" thing. Paste has you specify either "egg:" or "config:". In our case, this key is already a filesystem path in the default case so it seems like "egg:" as a prefix means we don't have to guess.

  4. Sok Ann Yap reporter

    This is the function in Pyramid that resolves asset specification by checking for semicolon and os.path.isabs:


    I think PasteDeploy is a different beast, as it supports "egg:", "config:", "call:", and even just a string without semicolon to refer to another section. To add something similar to this issue to PasteDeploy, I actually modified the patch from http://groups.google.com/group/paste-users/browse_thread/thread/1f2ff6295426d1d5 to add "configspec:", which works the same way as the patch you attached here.

  5. Log in to comment