forked from QIB-Sheffield/dbdicom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
63 lines (45 loc) · 1.9 KB
/
manage.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
import os
import sys
import venv
def distribute():
"""Create new version on PyPI
IMPORTANT! First increment your version number in pyproject.toml:
- Increment the MAJOR version when you make incompatible API changes.
- Increment the MINOR version when you add functionality in a backwards compatible manner.
- Increment the PATCH version when you make backwards compatible bug fixes.
You need: PyPI username and password.
You need to type in the PyPI password rather than copy-pasting.
"""
install()
os.system(activate() + ' && ' + 'pip install --upgrade build')
os.system(activate() + ' && ' + 'python -m build')
os.system(activate() + ' && ' + 'pip install --upgrade twine')
os.system(activate() + ' && ' + 'twine upload dist/*')
def document():
"""Generate documentation"""
install()
path = os.path.abspath(os.path.dirname(__file__))
path = os.path.join(path, 'docs')
if not os.path.isdir(path):
os.mkdir(path)
print('Generating documentation..')
os.system(activate() + ' && ' + 'pdoc --html -f -c sort_identifiers=False --output-dir ' + str(path) + ' dbdicom')
def activate():
"""Active virtual environment"""
venv_dir = os.path.join(os.getcwd(), ".venv")
os.makedirs(venv_dir, exist_ok=True)
venv.create(venv_dir, with_pip=True)
windows = (sys.platform == "win32") or (sys.platform == "win64") or (os.name == 'nt')
if windows:
return os.path.join(venv_dir, "Scripts", "activate")
else: # MacOS and Linux
return '. "' + os.path.join(venv_dir, "bin", "activate")
def install():
"""Install requirements to a virtual environment"""
print('Creating virtual environment..')
os.system('py -3 -m venv .venv')
print('Installing requirements..')
os.system(activate() + ' && ' + 'py -m pip install -r requirements.txt')
if __name__ == '__main__':
#install()
distribute()