tifffile
/
setup.py
162 строки · 4.5 Кб
1# tifffile/setup.py
2
3"""Tifffile package Setuptools script."""
4
5import re6import sys7
8from setuptools import setup9
10buildnumber = ''11
12
13def search(pattern, string, flags=0):14"""Return first match of pattern in string."""15match = re.search(pattern, string, flags)16if match is None:17raise ValueError(f'{pattern!r} not found')18return match.groups()[0]19
20
21def fix_docstring_examples(docstring):22"""Return docstring with examples fixed for GitHub."""23start = True24indent = False25lines = ['..', ' This file is generated by setup.py', '']26for line in docstring.splitlines():27if not line.strip():28start = True29indent = False30if line.startswith('>>> '):31indent = True32if start:33lines.extend(['.. code-block:: python', ''])34start = False35lines.append((' ' if indent else '') + line)36return '\n'.join(lines)37
38
39with open('tifffile/tifffile.py', encoding='utf-8') as fh:40code = fh.read().replace('\r\n', '\n').replace('\r', '\n')41
42version = search(r"__version__ = '(.*?)'", code).replace('.x.x', '.dev0')43version += ('.' + buildnumber) if buildnumber else ''44
45description = search(r'"""(.*)\.(?:\r\n|\r|\n)', code)46
47readme = search(48r'(?:\r\n|\r|\n){2}r"""(.*)"""(?:\r\n|\r|\n){2}from __future__',49code,50re.MULTILINE | re.DOTALL,51)
52readme = '\n'.join(53[description, '=' * len(description)] + readme.splitlines()[1:]54)
55
56if 'sdist' in sys.argv:57# update README, LICENSE, and CHANGES files58
59with open('README.rst', 'w', encoding='utf-8') as fh:60fh.write(fix_docstring_examples(readme))61
62license = search(63r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+r""',64code,65re.MULTILINE | re.DOTALL,66)67license = license.replace('# ', '').replace('#', '')68
69with open('LICENSE', 'w', encoding='utf-8') as fh:70fh.write('BSD 3-Clause License\n\n')71fh.write(license)72
73revisions = search(74r'(?:\r\n|\r|\n){2}(Revisions.*)- …',75readme,76re.MULTILINE | re.DOTALL,77).strip()78
79with open('CHANGES.rst', encoding='utf-8') as fh:80old = fh.read()81
82old = old.split(revisions.splitlines()[-1])[-1]83with open('CHANGES.rst', 'w', encoding='utf-8') as fh:84fh.write(revisions.strip())85fh.write(old)86
87setup(88name='tifffile',89version=version,90license='BSD',91description=description,92long_description=readme,93long_description_content_type='text/x-rst',94author='Christoph Gohlke',95author_email='cgohlke@cgohlke.com',96url='https://www.cgohlke.com',97project_urls={98'Bug Tracker': 'https://github.com/cgohlke/tifffile/issues',99'Source Code': 'https://github.com/cgohlke/tifffile',100# 'Documentation': 'https://',101},102packages=['tifffile'],103package_data={'tifffile': ['py.typed']},104python_requires='>=3.9',105install_requires=[106'numpy',107# 'imagecodecs>=2023.8.12',108],109extras_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},140entry_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},149platforms=['any'],150classifiers=[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