#! /usr/bin/env python3
#
# Advene: Annotate Digital Videos, Exchange on the NEt
# Copyright (C) 2021 Olivier Aubert <contact@olivieraubert.net>
#
# This file is part of Advene.
#
# Advene is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Advene is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Foobar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
from pathlib import Path
import sys

# Try to find if we are running from a development tree
# (using resolve() because we may use a symbolic link)
app_dir = Path(__file__).resolve().parent.parent

if ( (app_dir / "setup.py").exists()
     and (app_dir / "lib" / "advene").exists() ):
    # Chances are that we are using a development tree
    # Prepend lib dir to sys.path to use this version in priority
    sys.path.insert(0, str(app_dir / "lib"))
else:
    # Reset app_dir, we must be using a "standard" Advene install
    app_dir = None
import advene.core.config as config
config.data.fix_paths(app_dir)

from advene.util.importer import main

if __name__ == "__main__":
    main()
