-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
104 lines (87 loc) · 2.86 KB
/
setup.py
File metadata and controls
104 lines (87 loc) · 2.86 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import os
import re
import os.path
import errno
import subprocess
from setuptools import setup, Extension
def readme():
with open('README.rst', 'r') as readmefile:
return readmefile.read()
def gitversion():
with open(os.devnull, 'r') as devnull:
version = next(iter(subprocess.check_output(
['git', 'tag', '-l', '--points-at', 'HEAD'],
stdin=devnull).split('\n', 1)), '').strip()
if version:
match = re.search(r'\d+\.\d+(\.\d+(\.\d+)?)?', version)
version = match.group(0) if match else None
if not version:
version = subprocess.check_output(
['git', 'rev-parse', 'HEAD'], stdin=devnull).strip()[0:7]
return version
def version(filename):
try:
os.stat('.git')
except OSError as exc:
if exc.errno != errno.ENOENT:
raise
label = None
else:
label = gitversion()
while True:
try:
versionfile = open(filename, 'r')
except IOError as exc:
if label is None or exc.errno != errno.ENOENT:
raise
else:
with versionfile:
versionlabel = versionfile.readline().rstrip()
if label is None or label == versionlabel:
label = versionlabel
break
assert label
with open(filename, 'w') as versionfile:
versionfile.write('{}\n'.format(label))
break
return label
PKGNAME = 'keysafe'.lower()
PKGVERSION = version('VERSION.txt')
PKGGITREPO = 'https://github.com/earlchew/{}'.format(PKGNAME)
setup(
name=PKGNAME,
version=PKGVERSION,
description='Remember secrets for the duration of a login session',
long_description=readme(),
url=PKGGITREPO,
download_url='{}/archive/v{}.tar.gz'.format(PKGGITREPO, PKGVERSION),
author='Earl Chew',
author_email='earl_chew@yahoo.com',
license='BSD-2-Clause',
packages=[PKGNAME],
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: BSD License',
'Environment :: Console',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Topic :: Security',
'Topic :: System :: Systems Administration',
'Topic :: System :: Shells',
],
entry_points={
'console_scripts': [
'{pkgname} = {pkgname}.__main__:main'.format(pkgname=PKGNAME),
]},
package_dir={'' : 'lib'},
install_requires=['keyutils', 'cryptography'],
include_package_data=True,
ext_package=PKGNAME,
ext_modules=[Extension(
'lib{}'.format(PKGNAME),
['libkeysafe.c'],
define_macros=[
('_GNU_SOURCE', None),
('MODULE_NAME', PKGNAME.upper()),
('MODULE_name', PKGNAME)],
extra_compile_args=['-std=c99'])])