Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fc0eb4

Browse files
committed
Fix setup.py install and recommend this to install manually
1 parent 707a357 commit 5fc0eb4

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ test: clean
1010

1111
clean:
1212
@find . -name '*.pyc' -delete
13-
@rm -rf tmp\
14-
ua_parser.egg-info\
15-
dist\
16-
build
13+
@rm -rf tmp \
14+
ua_parser.egg-info \
15+
dist \
16+
build \
17+
ua_parser/_regexes.py
1718

1819
.PHONY: all test clean

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ pip install ua-parser
1616
### Manual install
1717
In the top-level directory run:
1818
```
19-
$ make
19+
$ python setup.py install
2020
```
2121

2222
##Getting Started
@@ -52,9 +52,9 @@ $ make
5252
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
5353
>>> parsed_string = user_agent_parser.ParseUserAgent(ua_string)
5454
>>> pp.pprint(parsed_string)
55-
{ 'family': 'Chrome',
56-
'major': '41',
57-
'minor': '0',
55+
{ 'family': 'Chrome',
56+
'major': '41',
57+
'minor': '0',
5858
'patch': '2272'}
5959
```
6060

@@ -84,13 +84,13 @@ $ make
8484
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
8585
>>> parsed_string = user_agent_parser.ParseDevice(ua_string)
8686
>>> pp.pprint(parsed_string)
87-
{ 'brand': None,
88-
'family': 'Other',
87+
{ 'brand': None,
88+
'family': 'Other',
8989
'model': None}
9090
```
9191

9292

9393
## Copyright
9494

95-
Copyright 2008 Google Inc. See ua_parser/LICENSE for more information
95+
Copyright 2008 Google Inc. See ua_parser/LICENSE for more information
9696

setup.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import os
33
from distutils import log
44
from distutils.core import Command
5+
from distutils.command.build import build as _build
56
from setuptools import setup
67
from setuptools.command.develop import develop as _develop
78
from setuptools.command.sdist import sdist as _sdist
9+
from setuptools.command.install import install as _install
810

911

1012
def check_output(*args, **kwargs):
@@ -49,7 +51,7 @@ def force_bytes(text):
4951
import yaml
5052
py_dest = os.path.join(work_path, 'ua_parser', '_regexes.py')
5153

52-
log.info('Compiling regexes.yaml -> _regexes.py')
54+
log.info('compiling regexes.yaml -> _regexes.py')
5355
with open(yaml_src, 'rb') as fp:
5456
regexes = yaml.safe_load(fp)
5557
with open(py_dest, 'wb') as fp:
@@ -109,13 +111,27 @@ def run(self):
109111
_develop.run(self)
110112

111113

114+
class build(_build):
115+
def run(self):
116+
self.run_command('build_regexes')
117+
_build.run(self)
118+
119+
120+
class install(_install):
121+
def run(self):
122+
self.run_command('build_regexes')
123+
_install.run(self)
124+
125+
112126
class sdist(_sdist):
113127
sub_commands = _sdist.sub_commands + [('build_regexes', None)]
114128

115129

116130
cmdclass = {
117131
'develop': develop,
132+
'build': build,
118133
'sdist': sdist,
134+
'install': install,
119135
'build_regexes': build_regexes,
120136
}
121137

0 commit comments

Comments
 (0)