# Copyright 2018 Blink Health LLC

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     https://www.apache.org/licenses/LICENSE-2.0

import os
import subprocess

from sys import version_info
from setuptools import setup, find_packages
from setuptools_scm import get_version

version = get_version()
with open("./version.py", "w") as fh:
    message = "{header}{nl}__version__='{ver}'{nl}".format(
        header="# generated by setup.py", ver=version, nl=os.linesep
    )
    fh.write(message)

deps = {
    # required by datakey
    "aes": "cryptography >=2.8,<3.0",
    # gpg
    "gpg": "pgpy >=0.4.3,<1.0.0",
    # kms
    "boto": "boto3 >=1.4.4,<2.0.0",
}

if version_info[0] == 2:
    # https://github.com/SecurityInnovation/PGPy/issues/217
    six = ["six ==1.10.0"]
else:
    six = []

setup(
    name="config-yourself",
    description="A python library to decrypt config-yourself files",
    use_scm_version=True,
    setup_requires=["setuptools_scm"],
    url="https://github.com/blinkhealth/config-yourself-python",
    license="Apache License 2.0",
    author="Will Richard",
    author_email="william.richard@blinkhealth.com",
    classifiers=[
        "Development Status :: 4 - Beta",
        "Intended Audience :: Developers",
        "Topic :: Software Development :: Libraries",
        "Topic :: Security",
        "Topic :: Security :: Cryptography",
        "Topic :: Utilities",
        "Programming Language :: Python :: 2",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: JavaScript",
    ],
    packages=find_packages(),
    extras_require={
        # gpg requires aes to do datakey decryption
        "gpg": six + [deps["gpg"], deps["aes"]],
        "kms": [deps["boto"]],
        "password": [deps["aes"]],
        "all": six + [deps.values()],
    },
    install_requires=["future >=0.16.0,<1.0.0", "PyYAML >=5.1.1"],
)
