forked from ua-parser/uap-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
76 lines (67 loc) · 2.37 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
#!/usr/bin/env python
from setuptools import setup
from setuptools.command.develop import develop as _develop
from setuptools.command.sdist import sdist as _sdist
def install_regexes():
print('Copying regexes.yaml to package directory...')
import os
cwd = os.path.abspath(os.path.dirname(__file__))
yaml_src = os.path.join(cwd, 'uap-core', 'regexes.yaml')
if not os.path.exists(yaml_src):
raise RuntimeError(
'Unable to find regexes.yaml, should be at %r' % yaml_src)
print('Converting regexes.yaml to regexes.json...')
import json
import yaml
json_dest = os.path.join(cwd, 'ua_parser', 'regexes.json')
with open(yaml_src, 'rb') as fp:
regexes = yaml.safe_load(fp)
with open(json_dest, "w") as f:
json.dump(regexes, f)
class develop(_develop):
def run(self):
install_regexes()
_develop.run(self)
class sdist(_sdist):
def run(self):
install_regexes()
_sdist.run(self)
setup(
name='ua-parser',
version='0.5.0',
description="Python port of Browserscope's user agent parser",
author='PBS',
author_email='[email protected]',
packages=['ua_parser'],
package_dir={'': '.'},
license='LICENSE.txt',
zip_safe=False,
url='https://github.com/ua-parser/uap-python',
include_package_data=True,
package_data={'ua_parser': ['regexes.json']},
setup_requires=['pyyaml'],
install_requires=[],
cmdclass={
'develop': develop,
'sdist': sdist,
},
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
)