1#!/usr/bin/env python
2
3import os
4import platform
5import sys
6
7from setuptools import Extension, setup
8
9if os.name == "nt":
10    libdep = []
11    extra_compile_args = []
12else:
13    libdep = ["m", "pthread"]
14    if platform.processor() == "i386":
15        extra_compile_args = ['-msse2', '-mfpmath=sse']
16    else:
17        extra_compile_args = []
18
19try:
20    with open("src/pillowfight/_version.h", "r") as file_descriptor:
21        version = file_descriptor.read().strip()
22        version = version.split(" ")[2][1:-1]
23        if "-" in version:
24            version = version.split("-")[0]
25except FileNotFoundError:
26    print("WARNING: version.txt file is missing")
27    print("WARNING: Please run 'make version' first")
28    sys.exit(1)
29
30
31setup(
32    name="pypillowfight",
33    version=version,
34    description=("Library containing various image processing algorithms"),
35    long_description=("Library containing various image processing algorithms:"
36                      " Automatic Color Equalization, Unpaper's algorithms,"
37                      " Stroke Width Transformation, etc"),
38    keywords="image processing algorithm pillow pil",
39    url="https://gitlab.gnome.org/World/OpenPaperwork/libpillowfight#readme",
40    download_url=(
41        "https://gitlab.gnome.org/World/OpenPaperwork/libpillowfight/archive/"
42        "{}.zip".format(version)
43    ),
44    classifiers=[
45        "Intended Audience :: Developers",
46        "License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
47        "Operating System :: POSIX :: Linux",
48        "Programming Language :: Python",
49        "Programming Language :: Python :: 3",
50        "Programming Language :: Python :: 3.5",
51        "Topic :: Multimedia :: Graphics :: Graphics Conversion",
52    ],
53    license="GPLv2",
54    author="Jerome Flesch",
55    author_email="jflesch@openpaper.work",
56    packages=[
57        'pillowfight',
58    ],
59    package_dir={
60        'pillowfight': 'src/pillowfight',
61    },
62    ext_modules=[
63        Extension(
64            'pillowfight._clib', [
65                'src/pillowfight/util.c',
66                'src/pillowfight/_ace.c',
67                'src/pillowfight/_blackfilter.c',
68                'src/pillowfight/_blurfilter.c',
69                'src/pillowfight/_border.c',
70                'src/pillowfight/_canny.c',
71                'src/pillowfight/_compare.c',
72                'src/pillowfight/_gaussian.c',
73                'src/pillowfight/_grayfilter.c',
74                'src/pillowfight/_masks.c',
75                'src/pillowfight/_noisefilter.c',
76                'src/pillowfight/_pymod.c',
77                'src/pillowfight/_scanborders.c',
78                'src/pillowfight/_sobel.c',
79                'src/pillowfight/_swt.c',
80                'src/pillowfight/_version.c',
81            ],
82            include_dirs=["include"],
83            libraries=libdep,
84            extra_compile_args=extra_compile_args,
85            undef_macros=['NDEBUG'],
86        ),
87    ],
88    data_files=[],
89    scripts=[],
90    install_requires=[
91        "Pillow",
92    ],
93    setup_requires=['nose>=1.0'],
94)
95