# -*- coding: utf-8 -*-

# Credits: https://python-packaging.readthedocs.io/en/latest/minimal.html

from __future__ import print_function, unicode_literals

import codecs
import sys

from setuptools import setup
from setuptools.command.install import install


# Credits: http://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/
class CheckExtDepsInstallCommand(install):
    """
    Install command checking GnuCash Python bindings dependency

    The GnuCash Python bindings are neither available from PyPi nor can they be
    installed from a repo or similar source compatible with Setuptools. This
    subclass makes the install command check whether the user has installed the
    GnuCash Python bindings herself before installing this Python package.
    """

    def run(self):
        try:
            import gnucash.gnucash_core # pylint: disable=unused-variable
        except ImportError:
            print("It looks like the GnuCash Python Bindings are not installed"
                  " on your system, but you need them in order to use"
                  " gnucash_autobudget. For installation instructions, see"
                  " http://wiki.gnucash.org/wiki/Python_Bindings.",
                  file=sys.stdout)
            sys.exit(1)

        install.run(self)


def get_readme():
    with codecs.open('README.rst', 'r') as f:
        return f.read()


setup(name='gnucash_autobudget',
      version='0.1.1',
      description="Automatically adjust GnuCash transactions for envelope budgeting",
      long_description=get_readme(),
      classifiers=[
          'License :: OSI Approved :: MIT License',
          'Programming Language :: Python :: 2.7',
          'Topic :: Office/Business :: Financial :: Accounting',
      ],
      keywords="GnuCash budget YNAB",
      url="https://github.com/rmoehn/gnucash_autobudget",
      author="<NAME>",
      author_email="<EMAIL>",
      license="MIT",
      include_package_data=True,
      zip_safe=True,
      cmdclass={ 'install': CheckExtDepsInstallCommand },
)

# -*- coding: utf-8 -*-

# Credits: https://python-packaging.readthedocs.io/en/latest/minimal.html

from __future__ import print_function, unicode_literals

import codecs
import sys

from setuptools import setup
from setuptools.command.install import install


# Credits: http://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/
class CheckExtDepsInstallCommand(install):
    """
    Install command checking GnuCash Python bindings dependency

    The GnuCash Python bindings are neither available from PyPi nor can they be
    installed from a repo or similar source compatible with Setuptools. This
    subclass makes the install command check whether the user has installed the
    GnuCash Python bindings herself before installing this Python package.
    """

    def run(self):
        try:
            import gnucash.gnucash_core # pylint: disable=unused-variable
        except ImportError:
            print("It looks like the GnuCash Python Bindings are not installed"
                  " on your system, but you need them in order to use"
                  " gnucash_autobudget. For installation instructions, see"
                  " http://wiki.gnucash.org/wiki/Python_Bindings.",
                  file=sys.stdout)
            sys.exit(1)

        install.run(self)


def get_readme():
    with codecs.open('README.rst', 'r') as f:
        return f.read()


setup(name='gnucash_autobudget',
      version='0.1.1',
      description="Automatically adjust GnuCash transactions for envelope budgeting",
      long_description=get_readme(),
      classifiers=[
          'License :: OSI Approved :: MIT License',
          'Programming Language :: Python :: 2.7',
          'Topic :: Office/Business :: Financial :: Accounting',
      ],
      keywords="GnuCash budget YNAB",
      url="https://github.com/rmoehn/gnucash_autobudget",
      author="<NAME>",
      author_email="<EMAIL>",
      license="MIT",
      include_package_data=True,
      zip_safe=True,
      cmdclass={ 'install': CheckExtDepsInstallCommand },
)

# -*- coding: utf-8 -*- # Credits: https://python-packaging.readthedocs.io/en/latest/minimal.html # Credits: http://blog.niteoweb.com/setuptools-run-custom-code-in-setup-py/ Install command checking GnuCash Python bindings dependency      The GnuCash Python bindings are neither available from PyPi nor can they be     installed from a repo or similar source compatible with Setuptools. This     subclass makes the install command check whether the user has installed the     GnuCash Python bindings herself before installing this Python package. # pylint: disable=unused-variable