-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup.py
executable file
·65 lines (41 loc) · 1.34 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
64
65
#!/usr/bin/env python
"""
Package build setup script.
Metadata and options are specified in `setup.cfg`.
Reference: https://setuptools.readthedocs.io/en/latest/setuptools.html
"""
import setuptools
from setuptools.command.develop import develop as BaseDevelop # noqa: N812
from setuptools.command.sdist import sdist as BaseSDist # noqa: N812
try:
from wheel.bdist_wheel import bdist_wheel as BaseBDistWheel # noqa: N812
except ImportError:
BaseBDistWheel = None
class CompileCatalogMixin:
"""
Compile MO files with Babel's ``compile_catalog`` command.
This happens after installing in development mode, or before building sdist
and wheel.
"""
# Note: Inspired by WTForms' setup.py.
def run(self):
is_develop = isinstance(self, Develop)
if not is_develop:
self.run_command("compile_catalog")
super().run()
if is_develop and not self.uninstall:
self.run_command("compile_catalog")
class Develop(CompileCatalogMixin, BaseDevelop):
pass
class SDist(CompileCatalogMixin, BaseSDist):
pass
cmd_classes = {
"develop": Develop,
"sdist": SDist,
}
if BaseBDistWheel:
class BDistWheel(CompileCatalogMixin, BaseBDistWheel):
pass
cmd_classes["bdist_wheel"] = BDistWheel
if __name__ == "__main__":
setuptools.setup(cmdclass=cmd_classes)