<commit_before># -*- coding: utf-8 -*-
# imagecodecs/setup.py

"""Imagecodecs package setuptools script."""

import sys
import re
import warnings

import numpy

from setuptools import setup, Extension
from Cython.Distutils import build_ext

buildnumber = ''  # 'post0'

with open('imagecodecs/_imagecodecs.pyx') as fh:
    code = fh.read()

version = re.search("__version__ = '(.*?)'", code).groups()[0]
version += ('.' + buildnumber) if buildnumber else ''
description = re.search('"""(.*)\.[\r\n?|\n]', code).groups()[0]
readme = re.search('[\r\n?|\n]{2}"""(.*)"""[\r\n?|\n]{2}__version__', code,
                   re.MULTILINE | re.DOTALL).groups()[0]
license = re.search('(# Copyright.*?[\r\n?|\n])[\r\n?|\n]+""', code,
                    re.MULTILINE | re.DOTALL).groups()[0]

readme = '\n'.join([description, '=' * len(description)]
                   + readme.splitlines()[1:])
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)

if sys.platform == 'win32':
    libraries = ['zlib', 'lz4', 'lzf', 'webp', 'png', 'jxrlib', 'jpeg',
                 'zstd_static', 'lzma-static', 'libbz2', 'openjp2']
    define_macros = [('WIN32', 1), ('LZMA_API_STATIC', 1), ('OPJ_STATIC', 1)]
    libraries_jpeg12 = ['jpeg12']

else:
    # TODO: find standard library names and compiler options
    libraries = ['m', 'z', 'jpeg', 'lz4', 'zstd', 'lzma', 'bz2', 'lzf',
                 'png', 'webp', 'jxrglue', 'jpegxr']
    define_macros = []
    libraries_jpeg12 = []


ext_modules = [
    Extension(
        'imagecodecs._imagecodecs',
        ['imagecodecs/imagecodecs.c',
         'imagecodecs/jpeg_0xc3.cpp',
         'imagecodecs/_imagecodecs.pyx'],
        include_dirs=[numpy.get_include(), 'imagecodecs'],
        libraries=libraries,
        define_macros=define_macros
        )
]

if libraries_jpeg12:
    ext_modules += [
        Extension(
            'imagecodecs._jpeg12',
            ['imagecodecs/_jpeg12.pyx'],
            include_dirs=[numpy.get_include(), 'imagecodecs'],
            libraries=libraries_jpeg12,
            define_macros=[('BITS_IN_JSAMPLE', 12)],
        )
    ]

setup_args = dict(
    name='imagecodecs',
    version=version,
    description=description,
    long_description=readme,
    author='<NAME>',
    author_email='<EMAIL>',
    url='https://www.lfd.uci.edu/~gohlke/',
    python_requires='>=2.7',
    install_requires=['numpy>=1.14'],
    tests_require=['pytest', 'zstd', 'lz4', 'python-lzf'],
    packages=['imagecodecs'],
    package_data={'imagecodecs': ['licenses/*']},
    license='BSD',
    zip_safe=False,
    platforms=['any'],
    classifiers=[<commit_msg>Update setup.py<commit_after># -*- coding: utf-8 -*-
# imagecodecs/setup.py

"""Imagecodecs package setuptools script."""

import sys
import re
import warnings

import numpy

from setuptools import setup, Extension
from Cython.Distutils import build_ext

buildnumber = ''  # 'post0'

with open('imagecodecs/_imagecodecs.pyx') as fh:
    code = fh.read()

version = re.search(r"__version__ = '(.*?)'", code).groups()[0]
version += ('.' + buildnumber) if buildnumber else ''
description = re.search(r'"""(.*)\.[\r\n?|\n]', code).groups()[0]
readme = re.search(r'[\r\n?|\n]{2}"""(.*)"""[\r\n?|\n]{2}__version__', code,
                   re.MULTILINE | re.DOTALL).groups()[0]
license = re.search(r'(# Copyright.*?[\r\n?|\n])[\r\n?|\n]+""', code,
                    re.MULTILINE | re.DOTALL).groups()[0]

readme = '\n'.join([description, '=' * len(description)]
                   + readme.splitlines()[1:])
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)
    numpy_required = '1.11.3'
else:
    numpy_required = numpy.__version__


sources = [
    'imagecodecs/imagecodecs.c',
    'imagecodecs/jpeg_0xc3.cpp',
    'imagecodecs/_imagecodecs.pyx',
]

include_dirs = [
    numpy.get_include(),
    'imagecodecs',
]

try:
    # run in Windows development environment?
    import _inclib  # noqa
    libraries = ['zlib', 'lz4', 'webp', 'png', 'jxrlib', 'jpeg', 'lzf',
                 'zstd_static', 'lzma-static', 'libbz2', 'openjp2']
    define_macros = [('WIN32', 1), ('LZMA_API_STATIC', 1), ('OPJ_STATIC', 1)]
    libraries_jpeg12 = ['jpeg12']

except ImportError:
    # this works with Ubuntu 18.04 WSL
    libraries = ['jpeg', 'lz4', 'zstd', 'lzma', 'bz2', 'png', 'webp',
                 'openjp2', 'jxrglue', 'jpegxr', 'z']
    include_dirs.extend(
        ['/usr/include/jxrlib',
         '/usr/include/openjpeg-2.3'])
    define_macros = []
    if sys.platform == 'win32':
        define_macros.append(('WIN32', 1))
    else:
        libraries.append('m')
    libraries_jpeg12 = []


if 'lzf' not in libraries and 'liblzf' not in libraries:
    # use liblzf sources from sdist
    sources.extend(['liblzf-3.6/lzf_c.c', 'liblzf-3.6/lzf_d.c'])
    include_dirs.append('liblzf-3.6')


ext_modules = [
    Extension(
        'imagecodecs._imagecodecs',
        sources,
        include_dirs=include_dirs,
        libraries=libraries,
        define_macros=define_macros,
    )
]

if libraries_jpeg12:
    ext_modules += [
        Extension(
            'imagecodecs._jpeg12',
            ['imagecodecs/_jpeg12.pyx'],
            include_dirs=[numpy.get_include(), 'imagecodecs'],
            libraries=libraries_jpeg12,
            define_macros=[('BITS_IN_JSAMPLE', 12)],
        )
    ]

setup_args = dict(
    name='imagecodecs',
    version=version,
    description=description,
    long_description=readme,
    author='<NAME>',
    author_email='<EMAIL>',
    url='https://www.lfd.uci.edu/~gohlke/',
    python_requires='>=2.7',
    install_requires=['numpy>=%s' % numpy_required],
    tests_require=['pytest', 'zstd', 'lz4', 'python-lzf'],
    packages=['imagecodecs'],
    package_data={'imagecodecs': ['licenses/*']},
    license='BSD',
    zip_safe=False,
    platforms=['any'],
    classifiers=[
{'fraction_non_alphanumeric': 0.19088830829523187, 'fraction_numerical': 0.017472240365774005, 'mean_word_length': 3.056291390728477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '151281', 'n_tokens_mistral': 2281, 'n_tokens_neox': 2210, 'n_words': 380}