7
7
from setuptools .command .sdist import sdist as _sdist
8
8
9
9
10
+ def check_output (* args , ** kwargs ):
11
+ from subprocess import Popen
12
+ proc = Popen (* args , ** kwargs )
13
+ output , _ = proc .communicate ()
14
+ rv = proc .poll ()
15
+ assert rv == 0 , output
16
+
17
+
10
18
class build_regexes (Command ):
11
19
description = 'build supporting regular expressions from uap-core'
12
20
user_options = [
@@ -24,8 +32,7 @@ def finalize_options(self):
24
32
def run (self ):
25
33
work_path = self .work_path
26
34
if os .path .exists (os .path .join (work_path , '.git' )):
27
- from subprocess import check_output
28
- log .info ("initializing git submodules" )
35
+ log .info ('initializing git submodules' )
29
36
check_output (['git' , 'submodule' , 'init' ], cwd = work_path )
30
37
check_output (['git' , 'submodule' , 'update' ], cwd = work_path )
31
38
@@ -39,9 +46,10 @@ def force_bytes(text):
39
46
return text
40
47
return text .encode ('utf8' )
41
48
42
- log .info ('Converting regexes.yaml to _regexes.py...' )
43
49
import yaml
44
50
py_dest = os .path .join (work_path , 'ua_parser' , '_regexes.py' )
51
+
52
+ log .info ('Compiling regexes.yaml -> _regexes.py' )
45
53
with open (yaml_src , 'rb' ) as fp :
46
54
regexes = yaml .safe_load (fp )
47
55
with open (py_dest , 'wb' ) as fp :
0 commit comments