1. Michael Bayer
  2. alembic
  3. Issues


Issue #72 resolved

`_rev_file` regex is too strict

created an issue

From alembic/script.py:

_rev_file = re.compile(r'([a-z0-9A-Z]+)(?:_.*)?\.py$')

I originally tried defining my scripts to look like 20120916-abcdef-do_something.py, but this regex quietly ignored them.

Comments (10)

  1. Sok Ann Yap

    Good question. I was having some problem with setup.py bdist_egg not picking up the migration files until I added the __init__.py file. Seems to work fine now without the file. Hmm.

  2. Sok Ann Yap

    My "seems to work fine" comment was wrong. Before I removed the __init__.py, my <package>.egg-info/SOURCES.txt contains all the migration .py files. After I removed __init__.py and rerun python setup.py egg_info, the file itself was gone from SOURCES.txt, but all the migration .py files were intact.

    This gave me the false impression that things work fine, until I added additional migration .py files and found that they are no longer being added to SOURCES.txt.

    After blowing away the whole <package>.egg-info directory and rerun python setup.py egg_info, now the whole alembic versions directory can't be found in SOURCES.txt, which was the original symptom that got me to add the __init__.py file.

    I fix this by modifying my project MANIFEST.in and make sure it has:

    recursive-include <package> ... *.py

    By default, a pyramid project doesn't have *.py in the line.

    tl;dr blame setuptools

  3. Michael Bayer repo owner

    yeah, distutils/setuptools only installs packages by default. A package requires an __init__.py. The versions/ directory is not intended to be a package, so needs special directives.

    Now, I'm not opposed to modifying this requirement, such that a versions/ directory can have an __init__.py that would be ignored, just so that in case someone's configuration has turned their versions/ into a package, things are OK.

  4. Log in to comment