import re
from os import path

from setuptools import setup

github_user = "avryhof"
github_repo_name = "geo_ez"
module_path = "geo_ez"
author = "Amos Vryhof"
author_email = "amos@vryhofresearch.com"
description = "Tools for building geographically aware django apps, without needing to install a real GIS backend."


def read(*parts):
    return open(path.join(path.dirname(__file__), *parts)).read()


def find_version(*file_paths):
    version_file = read(*file_paths)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError("Unable to find version string.")


def find_name(*file_paths):
    name_file = read(*file_paths)
    name_match = re.search(r"^__name__ = ['\"]([^'\"]*)['\"]", name_file, re.M)
    if name_match:
        return name_match.group(1)
    return module_path


setup(
    name=find_name(module_path, "__init__.py"),
    version=find_version(module_path, "__init__.py"),
    packages=[find_name(module_path, "__init__.py")],
    url="https://github.com/%s/%s" % (github_user, github_repo_name),
    license="MIT",
    author=author,
    author_email=author_email,
    description=description,
    long_description="",
    include_package_data=True,
    package_data={"": ["LICENSE"]},
    zip_safe=False,
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
    ],
    install_requires=["bleach", "django", "future", "requests", "xmltodict"],
)
