forked from tobie/ua-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
60 lines (54 loc) · 1.96 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
#!/usr/bin/env python
import os
import shutil
import sys
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
class install(_install):
def run(self):
# After installation:
# 1. Move regexes.yaml to directory where ua_parser is installed
# 2. Convert regexes.yaml to regexes.json
_install.run(self)
import json
import yaml
import ua_parser
INSTALLATION_DIR = os.path.dirname(ua_parser.__file__)
source_path = os.path.join(sys.prefix, 'data', 'regexes.yaml')
destination_path = os.path.join(INSTALLATION_DIR,
'regexes.yaml')
shutil.move(source_path, destination_path)
print 'Converting regexes.yaml to json...'
yaml_file = open(destination_path)
yaml = yaml.load(yaml_file)
yaml_file.close()
json_file = open(os.path.join(INSTALLATION_DIR, 'regexes.json'), 'w')
json_file.write(json.dumps(yaml))
json_file.close()
setup(
name='ua-parser',
version='0.3.1',
description="Python port of Browserscope's user agent parser",
author='PBS',
author_email='[email protected]',
packages=find_packages('py'),
package_dir={'': 'py'},
license='LICENSE.txt',
zip_safe=False,
url='https://github.com/tobie/ua-parser',
include_package_data=True,
package_data={'': ['README.markdown']},
data_files=[('data', ['regexes.yaml'])],
install_requires=['pyyaml'],
cmdclass={'install': install, 'develop': install},
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',
],
)