# -*- coding: utf-8 -*-
# czifile/setup.py

"""Czifile package setuptools script."""

import sys
import re

from setuptools import setup

buildnumber = ''

with open('czifile/czifile.py') as fh:
    code = fh.read()

version = re.search(r"__version__ = '(.*?)'", code).groups()[0]

version += ('.' + buildnumber) if buildnumber else ''

description = re.search(r'"""(.*)\.(?:\r\n|\r|\n)', code).groups()[0]

readme = re.search(r'(?:\r\n|\r|\n){2}"""(.*)"""(?:\r\n|\r|\n){2}from', code,
                   re.MULTILINE | re.DOTALL).groups()[0]

readme = '\n'.join([description, '=' * len(description)] +
                   readme.splitlines()[1:])

license = re.search(r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+""', code,
                    re.MULTILINE | re.DOTALL).groups()[0]

license = license.replace('# ', '').replace('#', '')

if 'sdist' in sys.argv:
    with open('LICENSE', 'w') as fh:
        fh.write(license)
    with open('README.rst', 'w') as fh:
        fh.write(readme)

setup(
    name='czifile',
    version=version,
    description=description,
    long_description=readme,
    long_description_content_type='text/x-rst',
    author='Christoph Gohlke',
    author_email='cgohlke@cgohlke.com',
    url='https://www.cgohlke.com',
    project_urls={
        'Bug Tracker': 'https://github.com/cgohlke/czifile/issues',
        'Source Code': 'https://github.com/cgohlke/czifile',
        # 'Documentation': 'https://',
    },
    license='BSD-3-Clause',
    packages=['czifile'],
    python_requires='>=2.7',
    install_requires=[
        'numpy>=1.11.3',
        # 'scipy>=1.1',
        'tifffile>=2019.7.2',
        'imagecodecs>=2019.5.22;platform_system=="Windows"',
    ],
    entry_points={
        'console_scripts': [
            'czifile = czifile.czifile:main',
            'czi2tif = czifile.czi2tif:main',
        ]},
    platforms=['any'],
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Science/Research',
        'Intended Audience :: Developers',
        'Operating System :: OS Independent',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.5',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
    ],
)
