1# tifffile/setup.py
2
3"""Tifffile package setuptools script."""
4
5import sys
6import re
7
8from setuptools import setup
9
10buildnumber = ''
11
12with open('tifffile/tifffile.py') as fh:
13    code = fh.read()
14
15version = re.search(r"__version__ = '(.*?)'", code).groups()[0]
16version += ('.' + buildnumber) if buildnumber else ''
17
18description = re.search(r'"""(.*)\.(?:\r\n|\r|\n)', code).groups()[0]
19
20readme = re.search(
21    r'(?:\r\n|\r|\n){2}"""(.*)"""(?:\r\n|\r|\n){2}__version__',
22    code,
23    re.MULTILINE | re.DOTALL,
24).groups()[0]
25
26readme = '\n'.join(
27    [description, '=' * len(description)] + readme.splitlines()[1:]
28)
29
30if 'sdist' in sys.argv:
31    # update README, LICENSE, and CHANGES files
32
33    with open('README.rst', 'w') as fh:
34        fh.write(readme)
35
36    license = re.search(
37        r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+""',
38        code,
39        re.MULTILINE | re.DOTALL,
40    ).groups()[0]
41
42    license = license.replace('# ', '').replace('#', '')
43
44    with open('LICENSE', 'w') as fh:
45        fh.write('BSD 3-Clause License\n\n')
46        fh.write(license)
47
48    revisions = (
49        re.search(
50            r'(?:\r\n|\r|\n){2}(Revisions.*)   \.\.\.',
51            readme,
52            re.MULTILINE | re.DOTALL,
53        )
54        .groups()[0]
55        .strip()
56    )
57
58    with open('CHANGES.rst', 'r') as fh:
59        old = fh.read()
60
61    d = revisions.splitlines()[-1]
62    old = old.split(d)[-1]
63    with open('CHANGES.rst', 'w') as fh:
64        fh.write(revisions.strip())
65        fh.write(old)
66
67setup(
68    name='tifffile',
69    version=version,
70    description=description,
71    long_description=readme,
72    author='Christoph Gohlke',
73    author_email='cgohlke@uci.edu',
74    license='BSD',
75    url='https://www.lfd.uci.edu/~gohlke/',
76    project_urls={
77        'Bug Tracker': 'https://github.com/cgohlke/tifffile/issues',
78        'Source Code': 'https://github.com/cgohlke/tifffile',
79        # 'Documentation': 'https://',
80    },
81    packages=['tifffile'],
82    python_requires='>=3.7',
83    install_requires=[
84        'numpy>=1.15.1',
85        # 'imagecodecs>=2021.7.30',
86    ],
87    extras_require={
88        'all': [
89            'imagecodecs>=2021.7.30',
90            'matplotlib>=3.2',
91            'lxml',
92            # 'zarr',
93            # 'fsspec'
94        ]
95    },
96    tests_require=[
97        'pytest',
98        'imagecodecs',
99        'czifile',
100        'cmapfile',
101        'oiffile',
102        'lfdfiles',
103        'roifile',
104        'lxml',
105        'zarr',
106        'fsspec>=2021.5.0',
107    ],
108    entry_points={
109        'console_scripts': [
110            'tifffile = tifffile:main',
111            'tiffcomment = tifffile.tiffcomment:main',
112            'tiff2fsspec = tifffile.tiff2fsspec:main',
113            'lsm2bin = tifffile.lsm2bin:main',
114        ],
115        # 'napari.plugin': ['tifffile = tifffile.napari_tifffile'],
116    },
117    platforms=['any'],
118    classifiers=[
119        'Development Status :: 4 - Beta',
120        'License :: OSI Approved :: BSD License',
121        'Intended Audience :: Science/Research',
122        'Intended Audience :: Developers',
123        'Operating System :: OS Independent',
124        'Programming Language :: Python :: 3 :: Only',
125        'Programming Language :: Python :: 3.7',
126        'Programming Language :: Python :: 3.8',
127        'Programming Language :: Python :: 3.9',
128        'Programming Language :: Python :: 3.10',
129    ],
130)
131