forked from zplab/zbar-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
85 lines (77 loc) · 2.16 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# fmt: off
try:
import setuptools
from setuptools import Extension, setup
setuptools_opts = dict(install_requires='numpy')
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
setuptools_opts = {}
import ctypes
import ctypes.util
import os
SRCS = '''Source/zbar/decoder.c
Source/zbar/decoder/code128.c
Source/zbar/decoder/code39.c
Source/zbar/decoder/ean.c
Source/zbar/decoder/i25.c
Source/zbar/decoder/pdf417.c
Source/zbar/decoder/qr_finder.c
Source/zbar/error.c
Source/zbar/img_scanner.c
Source/zbar/qrcode/bch15_5.c
Source/zbar/qrcode/binarize.c
Source/zbar/qrcode/isaac.c
Source/zbar/qrcode/qrdec.c
Source/zbar/qrcode/qrdectxt.c
Source/zbar/qrcode/rs.c
Source/zbar/qrcode/util.c
Source/zbar/refcnt.c
Source/zbar/scanner.c
Source/zbar/symbol.c'''.split('\n')
INCLUDE = 'Source', 'Source/zbar'
def has_libc_iconv():
if os.name != 'posix':
return False
libc = ctypes.CDLL(ctypes.util.find_library('c'))
return hasattr(libc, 'iconv')
# don't try to link to standalone iconv library if it's already in libc
# (iconv is in glibc, but on OS X one needs a stanalone libiconv)
LIBS = [] if has_libc_iconv() else ['iconv']
zbar = Extension(
'zbar._zbar',
sources=['zbar/_zbar.c'] + SRCS,
include_dirs=INCLUDE,
define_macros=[
('ENABLE_QRCODE', None),
('ENABLE_EAN', None),
('ENABLE_I25', None),
('ENABLE_CODE39', None),
('ENABLE_CODE128', None),
('ENABLE_PDF417', None),
('HAVE_INTTYPES_H', None),
('ZBAR_VERSION_MAJOR', 0),
('ZBAR_VERSION_MINOR', 10),
('NO_STATS', None),
],
libraries=LIBS,
extra_compile_args=['-g', '-O0'],
)
try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
long_description = open('README.md').read()
setup(
name='zbar-py-fix',
version='1.0.4',
description='zbar package',
url='https://github.com/jinzhenj/zbar-py',
author='Zachary Pincus',
author_email='[email protected]',
ext_modules=[zbar],
packages=['zbar'],
license='MIT',
long_description=long_description,
**setuptools_opts,
)