-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
executable file
·45 lines (33 loc) · 1.01 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
#!/usr/bin/env python3
"""
This file is a workaround for non-fully-clean ReadTheDocs environment
FYI: The docs building will be failed when config structure was changed, because the previous config was present and
this application will not overwrite it.
Please use package.sh scripts for setup.
"""
import os
import shutil
import sys
OBSOLETED_LIST = [
'config/config.yml',
]
def is_run_on_read_the_docs() -> bool:
return os.environ.get('READTHEDOCS', None) == 'True'
def cleanup(paths: list):
for path in paths:
if os.path.isdir(path):
print(' * Removing directory {!r}/...'.format(path))
shutil.rmtree(path)
elif os.path.isfile(path):
print(' * Removing file {!r}...'.format(path))
os.remove(path)
def main():
if not is_run_on_read_the_docs():
print(__doc__, file=sys.stderr)
return 1
print('Cleanup workspace')
cleanup(OBSOLETED_LIST)
print('Done')
return 0
if __name__ == '__main__':
sys.exit(main())