-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
152 lines (130 loc) · 5.2 KB
/
setup.py
File metadata and controls
152 lines (130 loc) · 5.2 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, unicode_literals,
print_function)
import os
import sys
from distutils import log
from distutils.errors import DistutilsSetupError
import setupdeps
log.set_verbosity(log.INFO)
setup_deps = [
setupdeps.Distro(),
setupdeps.SetupTools()
]
install_deps = [
# Core deps
setupdeps.LibMagic(),
setupdeps.PythonMagic(),
setupdeps.Six(),
setupdeps.ExifTool(),
setupdeps.AppDirs(),
# Image deps
setupdeps.PathLib(),
setupdeps.Pillow(),
setupdeps.Numpy(),
setupdeps.Dlib(),
setupdeps.ScikitImage(),
setupdeps.MagickWand(),
setupdeps.Wand(),
setupdeps.LibZBar(),
setupdeps.ZBar(),
setupdeps.JavaJRE(),
setupdeps.ZXing(),
setupdeps.PyColorName(),
# Audio video deps
setupdeps.FFProbe(),
]
def check_deps(deplist):
failed_deps = []
for dep in deplist:
try:
log_msg = dep.check()
log.info(dep.name + ' - ' + log_msg)
except setupdeps.CheckFailed as err:
log.info(dep.name + ' - ' + err.args[0])
failed_deps.append(dep)
if len(failed_deps) > 0:
msg = 'Some dependencies could not be installed automatically: '
msg += ", ".join(i.name for i in failed_deps)
for dep in failed_deps:
install_msg = dep.install_help_msg()
if install_msg:
msg += '\n* ' + install_msg
raise DistutilsSetupError(msg)
return deplist
def get_install_requires(deplist):
packages = []
for dep in check_deps(deplist):
packages += dep.get_install_requires()
return packages
def read_reqs(reqs_filename):
reqs = open(reqs_filename).read().strip().splitlines()
return list(i for i in reqs if not (i.startswith('#') or len(i) == 0))
if __name__ == '__main__':
log.info('Check and install dependencies required for setup:')
setup_packages = []
for dep in check_deps(setup_deps):
setup_packages += dep.get_setup_requires()
if setup_packages:
log.info('Some required packages required for file-metadata\'s setup '
'were not found: {0}.\nInstalling them with `pip` ...'
.format(", ".join(setup_packages)))
out = setupdeps.setup_install(setup_packages)
if out is not True:
raise DistutilsSetupError(
'Unable to install package(s) required by the setup script '
'using pip: {0}\nReport this issue to the maintainer.\n'
'Temporarily, this could be solved by running: '
'`python -m pip install {1}`.'
.format(", ".join(setup_packages), " ".join(setup_packages)))
log.info('Check dependencies required for using file-metadata:')
install_required = get_install_requires(install_deps)
log.info('Downloading 3rd party data files:')
for dep in install_deps:
data_msg = dep.get_data_files()
if data_msg:
log.info(dep.name + ' - ' + data_msg)
test_required = read_reqs('test-requirements.txt')
VERSION = open(os.path.join('file_metadata', 'VERSION')).read().strip()
if sys.version_info >= (3,): # mock is not required for python 3
test_required.remove('mock')
from setuptools import find_packages, setup
setup(name='file-metadata',
version=VERSION,
description='Helps to find structured metadata from a given file.',
author="DrTrigon",
author_email="dr.trigon@surfeu.ch",
maintainer="AbdealiJK",
maintainer_email='abdealikothari@gmail.com',
license="MIT",
url='https://github.com/AbdealiJK/file-metadata',
packages=find_packages(exclude=["build.*", "tests.*", "tests"]),
# Dependency management by pip
install_requires=install_required,
tests_require=test_required,
# Setuptools has a bug where they use isinstance(x, str) instead
# of basestring. Because of this we convert it to str for Py2.
package_data={str('file_metadata'): [str("VERSION"),
str("datafiles/*")]},
entry_points={
"console_scripts": [
("wikibot-filemeta-simple = "
"file_metadata.wikibot.simple_bot:main"),
("wikibot-filemeta-log = "
"file_metadata.wikibot.log_bot:main"),
("wikibot-filemeta-auto = "
"file_metadata.wikibot.auto_bot:main"),
("wikibot-filemeta-manual = "
"file_metadata.wikibot.manual_bot:main"),
("wikibot-create-config = "
"file_metadata.wikibot.generate_user_files:main")]},
# from http://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python :: Implementation :: CPython'])