Actually, I was too soon to say it works now. 
with 
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
branches command works.
but upgrade fails on the other hand if I have 
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'
)))
then branches fails, but upgrade works.

On Monday, August 11, 2014 5:51:46 PM UTC-7, Anton wrote:
>
> You are right Michael, in my alembic/env.py I had a line:
> sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 
> '..')))
>
> I replaced it with 
> sys.path.append(os.path.abspath(os.path.dirname(__file__)))
> Is there any better or let's more conventional way of setting this up?
>
> And it works now, if I run the script from my root directory, that 
> contains my_app and alembic directories. I was confused, because other 
> commands would run without issues. 
>
> Thanks a lot!
>
> On Monday, August 11, 2014 5:24:11 PM UTC-7, Michael Bayer wrote:
>>
>> I would guess this is a side effect of something that occurs in your 
>> env.py script.   Not all commands load env.py, so if your migration files 
>> depend on env.py being loaded in order for their imports to work that would 
>> be what’s happening here.
>>
>>    
>>
>> On Aug 11, 2014, at 8:21 PM, Anton <anton.sch...@gmail.com> wrote:
>>
>> I have a flask application. My project tree looks like:
>> .
>> ├── Procfile
>> ├── README.md
>> ├── alembic
>> ├── alembic.ini
>> ├── my_app
>> ├── requirements.txt
>> ├── start_server.py
>> └── venv
>>
>> Where my_app contains Flask application, for some reason *branches* 
>> command fails to run with an error ImportError: No module named my_app.types
>> Traceback (most recent call last):
>>   File "/Users/anton/dev/my_app/venv/bin/alembic", line 9, in <module>
>>     load_entry_point('alembic==0.6.5', 'console_scripts', 'alembic')()
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py"
>> , line 298, in main
>>     CommandLine(prog=prog).main(argv=argv)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py"
>> , line 293, in main
>>     self.run_cmd(cfg, options)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/config.py"
>> , line 279, in run_cmd
>>     **dict((k, getattr(options, k)) for k in kwarg)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/command.py"
>> , line 200, in branches
>>     for sc in script.walk_revisions():
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py"
>> , line 81, in walk_revisions
>>     heads = set(self.get_heads())
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py"
>> , line 288, in get_heads
>>     for script in self._revision_map.values():
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/util.py"
>> , line 268, in __get__
>>     obj.__dict__[self.__name__] = result = self.fget(obj)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py"
>> , line 213, in _revision_map
>>     script = Script._from_filename(self, self.versions, file_)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/script.py"
>> , line 496, in _from_filename
>>     module = util.load_python_file(dir_, filename)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/util.py"
>> , line 212, in load_python_file
>>     module = load_module_py(module_id, path)
>>   File 
>> "/Users/anton/dev/my_app/venv/lib/python2.7/site-packages/alembic/compat.py"
>> , line 58, in load_module_py
>>     mod = imp.load_source(module_id, path, fp)
>>   File "alembic/versions/213495jl1br_.py", line 39, in <module>
>>     from my_app.types import DbType
>> ImportError: No module named my_app.types
>>
>> Other commands like upgrade or revision --autogenerate work fine.
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy-alembic" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sqlalchemy-alembic+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to