-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·74 lines (62 loc) · 2.48 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
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import re
import sys
from os import path
from subprocess import check_output
from setuptools import find_packages, setup
# Get the long description from the relevant file
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
def update_version():
try:
toks = check_output('git describe --tags --long --dirty',
universal_newlines=True,
shell=True).strip().split('-')
version = toks[0].strip('v') + '.' + toks[1]
last = check_output('git log -n 1',
universal_newlines=True,
shell=True)
date = re.search(r'^Date:\s+([^\s].*)$', last, re.MULTILINE).group(1)
commit = re.search(r'^commit\s+([^\s]{40})', last,
re.MULTILINE).group(1)
with open(path.join('slmtools', 'version.py'), 'w', newline='\n') as f:
f.write('#!/usr/bin/env python3\n')
f.write('# -*- coding: utf-8 -*-\n\n')
f.write(f"__version__ = '{version}'\n")
f.write(f"__date__ = '{date}'\n")
f.write(f"__commit__ = '{commit}'")
except Exception as e:
print(f'Cannot update version: {str(e)}', file=sys.stderr)
print('Is Git installed?', file=sys.stderr)
update_version()
def lookup_version():
with open(os.path.join('slmtools', 'version.py'), 'r') as f:
m = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M)
return m.group(1)
setup(
name='slmtools',
version=lookup_version(),
description='Spatial light modulator in Python',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/jacopoantonello/slmtools',
maintainer='The SLM Project Developers',
license='GPLv3+',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: Physics',
('License :: OSI Approved :: ' +
'GNU General Public License v3 or later (GPLv3+)'),
'Programming Language :: Python :: 3',
],
install_requires=[
'numpy', 'matplotlib', 'PyQt5', 'zernike', 'imageio', 'scikit-image'
],
packages=find_packages(exclude=['tests*', 'examples*']),
package_data={'slmtools.test': ['flat.png']},
python_requires='>=3.7',
)