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

Skip to content

Commit b9393a9

Browse files
committed
Pull in all the junk from Sentry to make it work correctly
1 parent 434c32f commit b9393a9

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include README.md
2+
global-exclude *~

setup.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,38 @@ class build_regexes(Command):
2121
description = 'build supporting regular expressions from uap-core'
2222
user_options = [
2323
('work-path=', 'w',
24-
'The working directory for source files. Defaults to .'),
24+
"The working directory for source files. Defaults to ."),
25+
('build-lib=', 'b',
26+
"directory for script runtime modules"),
27+
('inplace', 'i',
28+
"ignore build-lib and put compiled javascript files into the source " +
29+
"directory alongside your pure Python modules"),
30+
('force', 'f',
31+
"Force rebuilding of static content. Defaults to rebuilding on version "
32+
"change detection."),
2533
]
34+
boolean_options = ['force']
2635

2736
def initialize_options(self):
37+
self.build_lib = None
38+
self.force = None
2839
self.work_path = None
40+
self.inplace = None
2941

3042
def finalize_options(self):
43+
install = self.distribution.get_command_obj('install')
44+
sdist = self.distribution.get_command_obj('sdist')
45+
build_ext = self.distribution.get_command_obj('build_ext')
46+
47+
if self.inplace is None:
48+
self.inplace = (build_ext.inplace or install.finalized
49+
or sdist.finalized) and 1 or 0
50+
51+
if self.inplace:
52+
self.build_lib = '.'
53+
else:
54+
self.set_undefined_options('build',
55+
('build_lib', 'build_lib'))
3156
if self.work_path is None:
3257
self.work_path = os.path.realpath(os.path.join(os.path.dirname(__file__)))
3358

@@ -51,7 +76,7 @@ def force_bytes(text):
5176
return text.encode('utf8')
5277

5378
import yaml
54-
py_dest = os.path.join(work_path, 'ua_parser', '_regexes.py')
79+
py_dest = os.path.join(self.build_lib, 'ua_parser', '_regexes.py')
5580

5681
log.info('compiling regexes.yaml -> _regexes.py')
5782
with open(yaml_src, 'rb') as fp:
@@ -106,6 +131,15 @@ def force_bytes(text):
106131
fp.write(b']\n')
107132
fp.write(b'\n')
108133

134+
self.update_manifest()
135+
136+
def update_manifest(self):
137+
sdist = self.distribution.get_command_obj('sdist')
138+
if not sdist.finalized:
139+
return
140+
141+
sdist.filelist.files.append('ua_parser/_regexes.py')
142+
109143

110144
class develop(_develop):
111145
def run(self):
@@ -119,13 +153,20 @@ def run(self):
119153
_install.run(self)
120154

121155

156+
class build(_build):
157+
def run(self):
158+
self.run_command('build_regexes')
159+
_build.run(self)
160+
161+
122162
class sdist(_sdist):
123163
sub_commands = _sdist.sub_commands + [('build_regexes', None)]
124164

125165

126166
cmdclass = {
127-
'develop': develop,
128167
'sdist': sdist,
168+
'develop': develop,
169+
'build': build,
129170
'install': install,
130171
'build_regexes': build_regexes,
131172
}

0 commit comments

Comments
 (0)