-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
49 lines (38 loc) · 1.35 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
import distutils
import os.path
from setuptools import setup
from setuptools.command.install import install as _install
PTH = (
'try:\n'
' import blursed\n'
'except ImportError:\n'
' pass\n'
'else:\n'
' blursed.register()\n'
)
class install(_install):
def initialize_options(self):
_install.initialize_options(self)
# Use this prefix to get loaded as early as possible
name = 'aaaaaaa_' + (self.distribution.metadata.name or 'blursed')
contents = 'import sys; exec({!r})\n'.format(PTH)
self.extra_path = (name, contents)
def finalize_options(self):
_install.finalize_options(self)
install_suffix = os.path.relpath(
self.install_lib, self.install_libbase,
)
if install_suffix == '.':
distutils.log.info('skipping install of .pth during easy-install')
elif install_suffix == self.extra_path[1]:
self.install_lib = self.install_libbase
distutils.log.info(
"will install .pth to '%s.pth'",
os.path.join(self.install_lib, self.extra_path[0]),
)
else:
raise AssertionError(
'unexpected install_suffix',
self.install_lib, self.install_libbase, install_suffix,
)
setup(cmdclass={'install': install})