forked from python-otr/pure-python-otr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
126 lines (108 loc) · 4.75 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
# Copyright 2011 Kjell Braden <[email protected]>
#
# This file is part of the python-potr library.
#
# python-potr is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# python-potr is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
from distutils.command.install import install
from distutils.command.install_lib import install_lib
from distutils.core import setup
from distutils.sysconfig import get_config_vars
import os.path
class gajimpath_install(install):
user_options = install.user_options + [
('gajim-dir=', None,
"gajim directory to install plugin to [default: $PREFIX/share/gajim]"),
]
def initialize_options(self):
install.initialize_options(self)
self.gajim_dir = None
class checked_install_lib(install_lib):
def __init__(self, dist):
install_lib.__init__(self, dist)
self.packages = dist.packages
def initialize_options(self):
install_lib.initialize_options(self)
self.data_prefix = None
self.gajim_dir = None
def finalize_options(self):
install_lib.finalize_options(self)
self.set_undefined_options('install',
('install_data', 'data_prefix'),
('gajim_dir', 'gajim_dir'),
)
# prepapre gajim directory paths
if self.gajim_dir is None:
self.gajim_dir = os.path.join(self.data_prefix,
os.path.normpath('share/gajim'))
else:
self.gajim_dir = os.path.expanduser(self.gajim_dir)
self.gajim_plugin_dir = os.path.join(self.gajim_dir,
os.path.normpath('plugins/gotr'))
def run(self):
""" checks for a valid pycrypto version before running the install
process, prints a warning if none was found """
try:
import Crypto
if Crypto.version_info < (2,1):
print('\n**** WARNING: ****\nYou seem to have pyCrypto < 2.1 '
'installed. python-potr will need at least pyCrypto 2.1 to run\n\n')
except:
print('\n**** WARNING: ****\nYou don\'t seem to have pyCrypto '
'installed. python-potr will need at least pyCrypto 2.1 to run\n\n')
install_lib.run(self)
def install(self):
""" overwrites the default install handler, which installs everything
from build.
Instead, we regularly install potr packages and redirect the gotr
package to the gajim plugins directory, if there is a gajim directory in
the current $PREFIX """
outfiles = []
if os.path.isdir(self.build_dir):
for package in self.packages:
packagedir = os.path.join(*list(package.split('.')))
if package == 'gotr':
if os.path.isdir(self.gajim_dir):
outfiles += self.copy_tree(
os.path.join(self.build_dir, 'gotr'),
self.gajim_plugin_dir)
else:
outfiles += self.copy_tree(
os.path.join(self.build_dir, packagedir),
os.path.join(self.install_dir, packagedir))
else:
self.warn("'%s' does not exist -- no Python modules to install" %
self.build_dir)
return
return outfiles
setup(
name='python-potr',
version='1.0.0b5',
description='pure Python Off-The-Record encryption',
author='Kjell Braden',
author_email='[email protected]',
url='http://python-otr.pentabarf.de',
packages=['potr', 'potr.compatcrypto', 'gotr'],
package_dir={'potr':'src/potr', 'gotr':'src/gajim-plugin/gotr'},
package_data={'gotr':['*.ini', '*.ui']},
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
'Programming Language :: Python :: 2',
'Topic :: Communications :: Chat',
'Topic :: Security :: Cryptography',
],
cmdclass={'install_lib':checked_install_lib, 'install':gajimpath_install},
)