|
1 | | -"""a binding for the libvips image processing library |
2 | | -
|
3 | | -See: |
4 | | -https://github.com/libvips/pyvips |
5 | | -""" |
6 | | - |
7 | | -# flake8: noqa |
8 | | - |
9 | 1 | import sys |
10 | | -from codecs import open |
11 | | -from os import path |
12 | | - |
13 | | -from setuptools import setup, find_packages |
14 | | -from distutils import log |
15 | | - |
16 | | -here = path.abspath(path.dirname(__file__)) |
17 | | - |
18 | | -info = {} |
19 | | -with open(path.join(here, 'pyvips', 'version.py'), encoding='utf-8') as f: |
20 | | - exec(f.read(), info) |
21 | | - |
22 | | -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: |
23 | | - long_description = f.read() |
24 | | - |
25 | | -# See https://pypi.python.org/pypi?%3Aaction=list_classifiers |
26 | | -pyvips_classifiers = [ |
27 | | - 'Development Status :: 5 - Production/Stable', |
28 | | - 'Environment :: Console', |
29 | | - 'Intended Audience :: Developers', |
30 | | - 'Intended Audience :: Science/Research', |
31 | | - 'Topic :: Multimedia :: Graphics', |
32 | | - 'Topic :: Multimedia :: Graphics :: Graphics Conversion', |
33 | | - 'License :: OSI Approved :: MIT License', |
34 | | - 'Programming Language :: Python :: 3' |
35 | | - 'Programming Language :: Python :: 3 :: Only', |
36 | | - 'Programming Language :: Python :: 3.3', |
37 | | - 'Programming Language :: Python :: 3.4', |
38 | | - 'Programming Language :: Python :: 3.5', |
39 | | - 'Programming Language :: Python :: 3.6', |
40 | | - 'Programming Language :: Python :: 3.7', |
41 | | - 'Programming Language :: Python :: 3.8', |
42 | | - 'Programming Language :: Python :: 3.9', |
43 | | - 'Programming Language :: Python :: 3.10', |
44 | | - 'Programming Language :: Python :: 3.11', |
45 | | - 'Programming Language :: Python :: 3.12', |
46 | | - 'Programming Language :: Python :: Implementation :: CPython', |
47 | | - 'Programming Language :: Python :: Implementation :: PyPy', |
48 | | -] |
49 | 2 |
|
50 | | -setup_deps = [ |
51 | | - 'cffi>=1.0.0', |
52 | | -] |
53 | | - |
54 | | -install_deps = [ |
55 | | - 'cffi>=1.0.0', |
56 | | -] |
57 | | - |
58 | | -test_deps = [ |
59 | | - 'cffi>=1.0.0', |
60 | | - 'pytest', |
61 | | - 'pyperf', |
62 | | -] |
63 | | - |
64 | | -extras = { |
65 | | - 'test': test_deps, |
66 | | - 'doc': ['sphinx', 'sphinx_rtd_theme'], |
67 | | -} |
68 | | - |
69 | | -pyvips_packages = find_packages(exclude=['docs', 'tests', 'examples']) |
70 | | - |
71 | | -sys.path.append(path.join(here, 'pyvips')) |
72 | | - |
73 | | -def setup_API(): |
74 | | - setup( |
75 | | - name='pyvips', |
76 | | - version=info['__version__'], |
77 | | - description='binding for the libvips image processing library, API mode', |
78 | | - long_description=long_description, |
79 | | - url='https://github.com/libvips/pyvips', |
80 | | - author='John Cupitt', |
81 | | - |
82 | | - license='MIT', |
83 | | - classifiers=pyvips_classifiers, |
84 | | - keywords='image processing', |
85 | | - |
86 | | - packages=pyvips_packages, |
87 | | - setup_requires=setup_deps + ['pkgconfig>=1.5'], |
88 | | - cffi_modules=['pyvips/pyvips_build.py:ffibuilder'], |
89 | | - install_requires=install_deps + ['pkgconfig>=1.5'], |
90 | | - tests_require=test_deps, |
91 | | - extras_require=extras, |
92 | | - |
93 | | - # we will try to compile as part of install, so we can't run in a zip |
94 | | - zip_safe=False, |
95 | | - ) |
| 3 | +from os import path |
| 4 | +from setuptools import setup |
96 | 5 |
|
97 | | -def setup_ABI(): |
98 | | - setup( |
99 | | - name='pyvips', |
100 | | - version=info['__version__'], |
101 | | - description='binding for the libvips image processing library, ABI mode', |
102 | | - long_description=long_description, |
103 | | - url='https://github.com/libvips/pyvips', |
104 | | - author='John Cupitt', |
105 | | - |
106 | | - license='MIT', |
107 | | - classifiers=pyvips_classifiers, |
108 | | - keywords='image processing', |
| 6 | +base_dir = path.dirname(__file__) |
| 7 | +src_dir = path.join(base_dir, 'pyvips') |
109 | 8 |
|
110 | | - packages=pyvips_packages, |
111 | | - setup_requires=setup_deps, |
112 | | - install_requires=install_deps, |
113 | | - tests_require=test_deps, |
114 | | - extras_require=extras, |
115 | | - ) |
| 9 | +# When executing the setup.py, we need to be able to import ourselves, this |
| 10 | +# means that we need to add the pyvips/ directory to the sys.path. |
| 11 | +sys.path.insert(0, src_dir) |
116 | 12 |
|
117 | | -# try to install in API mode first, then if that fails, fall back to ABI |
| 13 | +# Try to install in API mode first, then if that fails, fall back to ABI |
118 | 14 |
|
119 | 15 | # API mode requires a working C compiler plus all the libvips headers whereas |
120 | 16 | # ABI only needs the libvips shared library to be on the system |
121 | 17 |
|
122 | 18 | try: |
123 | | - setup_API() |
| 19 | + setup(cffi_modules=['pyvips/pyvips_build.py:ffibuilder']) |
124 | 20 | except Exception as e: |
125 | | - log.warn('Falling back to ABI mode. Details: {0}'.format(e)) |
126 | | - setup_ABI() |
| 21 | + print('Falling back to ABI mode. Details: {0}'.format(e)) |
| 22 | + setup() |
0 commit comments