forked from tobie/ua-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
63 lines (58 loc) · 1.95 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
#!/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
import shutil
cwd = os.path.abspath(os.path.dirname(__file__))
yaml_src = os.path.join(cwd, 'regexes.yaml')
if not os.path.exists(yaml_src):
raise RuntimeError(
'Unable to find regexes.yaml, should be at %r' % yaml_src)
yaml_dest = os.path.join(cwd, 'py', 'ua_parser', 'regexes.yaml')
shutil.copy2(yaml_src, yaml_dest)
print('Converting regexes.yaml to regexes.json...')
import json
import yaml
json_dest = yaml_dest.replace('.yaml', '.json')
regexes = yaml.load(open(yaml_dest))
json.dump(regexes, open(json_dest, 'w'))
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.3.4',
description="Python port of Browserscope's user agent parser",
author='PBS',
author_email='[email protected]',
packages=['ua_parser'],
package_dir={'': 'py'},
license='LICENSE.txt',
zip_safe=False,
url='https://github.com/tobie/ua-parser',
include_package_data=True,
package_data={'ua_parser': ['regexes.yaml', 'regexes.json']},
# install_requires=['pyyaml'],
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',
],
)