tifffile

Форк
0
/
setup.py 
162 строки · 4.5 Кб
1
# tifffile/setup.py
2

3
"""Tifffile package Setuptools script."""
4

5
import re
6
import sys
7

8
from setuptools import setup
9

10
buildnumber = ''
11

12

13
def search(pattern, string, flags=0):
14
    """Return first match of pattern in string."""
15
    match = re.search(pattern, string, flags)
16
    if match is None:
17
        raise ValueError(f'{pattern!r} not found')
18
    return match.groups()[0]
19

20

21
def fix_docstring_examples(docstring):
22
    """Return docstring with examples fixed for GitHub."""
23
    start = True
24
    indent = False
25
    lines = ['..', '  This file is generated by setup.py', '']
26
    for line in docstring.splitlines():
27
        if not line.strip():
28
            start = True
29
            indent = False
30
        if line.startswith('>>> '):
31
            indent = True
32
            if start:
33
                lines.extend(['.. code-block:: python', ''])
34
                start = False
35
        lines.append(('    ' if indent else '') + line)
36
    return '\n'.join(lines)
37

38

39
with open('tifffile/tifffile.py', encoding='utf-8') as fh:
40
    code = fh.read().replace('\r\n', '\n').replace('\r', '\n')
41

42
version = search(r"__version__ = '(.*?)'", code).replace('.x.x', '.dev0')
43
version += ('.' + buildnumber) if buildnumber else ''
44

45
description = search(r'"""(.*)\.(?:\r\n|\r|\n)', code)
46

47
readme = search(
48
    r'(?:\r\n|\r|\n){2}r"""(.*)"""(?:\r\n|\r|\n){2}from __future__',
49
    code,
50
    re.MULTILINE | re.DOTALL,
51
)
52
readme = '\n'.join(
53
    [description, '=' * len(description)] + readme.splitlines()[1:]
54
)
55

56
if 'sdist' in sys.argv:
57
    # update README, LICENSE, and CHANGES files
58

59
    with open('README.rst', 'w', encoding='utf-8') as fh:
60
        fh.write(fix_docstring_examples(readme))
61

62
    license = search(
63
        r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+r""',
64
        code,
65
        re.MULTILINE | re.DOTALL,
66
    )
67
    license = license.replace('# ', '').replace('#', '')
68

69
    with open('LICENSE', 'w', encoding='utf-8') as fh:
70
        fh.write('BSD 3-Clause License\n\n')
71
        fh.write(license)
72

73
    revisions = search(
74
        r'(?:\r\n|\r|\n){2}(Revisions.*)- …',
75
        readme,
76
        re.MULTILINE | re.DOTALL,
77
    ).strip()
78

79
    with open('CHANGES.rst', encoding='utf-8') as fh:
80
        old = fh.read()
81

82
    old = old.split(revisions.splitlines()[-1])[-1]
83
    with open('CHANGES.rst', 'w', encoding='utf-8') as fh:
84
        fh.write(revisions.strip())
85
        fh.write(old)
86

87
setup(
88
    name='tifffile',
89
    version=version,
90
    license='BSD',
91
    description=description,
92
    long_description=readme,
93
    long_description_content_type='text/x-rst',
94
    author='Christoph Gohlke',
95
    author_email='cgohlke@cgohlke.com',
96
    url='https://www.cgohlke.com',
97
    project_urls={
98
        'Bug Tracker': 'https://github.com/cgohlke/tifffile/issues',
99
        'Source Code': 'https://github.com/cgohlke/tifffile',
100
        # 'Documentation': 'https://',
101
    },
102
    packages=['tifffile'],
103
    package_data={'tifffile': ['py.typed']},
104
    python_requires='>=3.9',
105
    install_requires=[
106
        'numpy',
107
        # 'imagecodecs>=2023.8.12',
108
    ],
109
    extras_require={
110
        'codecs': ['imagecodecs>=2023.8.12'],
111
        'xml': ['defusedxml', 'lxml'],
112
        'zarr': ['zarr', 'fsspec'],
113
        'plot': ['matplotlib'],
114
        'all': [
115
            'imagecodecs>=2023.8.12',
116
            'matplotlib',
117
            'defusedxml',
118
            'lxml',
119
            'zarr',
120
            'fsspec',
121
        ],
122
        'test': [
123
            'pytest',
124
            'imagecodecs',
125
            'czifile',
126
            'cmapfile',
127
            'oiffile',
128
            'lfdfiles',
129
            'psdtags',
130
            'roifile',
131
            'lxml',
132
            'zarr',
133
            'dask',
134
            'xarray',
135
            'fsspec',
136
            'defusedxml',
137
            'ndtiff',
138
        ],
139
    },
140
    entry_points={
141
        'console_scripts': [
142
            'tifffile = tifffile:main',
143
            'tiffcomment = tifffile.tiffcomment:main',
144
            'tiff2fsspec = tifffile.tiff2fsspec:main',
145
            'lsm2bin = tifffile.lsm2bin:main',
146
        ],
147
        # 'napari.plugin': ['tifffile = tifffile.napari_tifffile'],
148
    },
149
    platforms=['any'],
150
    classifiers=[
151
        'Development Status :: 4 - Beta',
152
        'License :: OSI Approved :: BSD License',
153
        'Intended Audience :: Science/Research',
154
        'Intended Audience :: Developers',
155
        'Operating System :: OS Independent',
156
        'Programming Language :: Python :: 3 :: Only',
157
        'Programming Language :: Python :: 3.10',
158
        'Programming Language :: Python :: 3.11',
159
        'Programming Language :: Python :: 3.12',
160
        'Programming Language :: Python :: 3.13',
161
    ],
162
)
163

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.