-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
84 lines (70 loc) · 2.38 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
"""A demo of reliable pth installation, with a dash of troll."""
from distutils import log
from setuptools import setup
from setuptools.command.install import install as orig_install
PTH = '''\
from sys import stderr
stderr.write(%r)
'''
DOC = __doc__
class Install(orig_install):
"""
default semantics for install.extra_path cause all installed modules to go
into a directory whose name is equal to the contents of the .pth file.
All that was necessary was to remove that one behavior to get what you'd
generally want.
"""
def initialize_options(self):
orig_install.initialize_options(self)
name = self.distribution.metadata.name
contents = PTH % open('ohai.dat').read()
contents = 'import sys; exec(%r)\n' % contents
self.extra_path = (name, contents)
def finalize_options(self):
orig_install.finalize_options(self)
from os.path import relpath, join
install_suffix = relpath(self.install_lib, self.install_libbase)
if install_suffix == '.':
log.info('skipping install of .pth during easy-install')
elif install_suffix == self.extra_path[1]:
self.install_lib = self.install_libbase
log.info(
"will install .pth to '%s.pth'",
join(self.install_lib, self.extra_path[0]),
)
else:
raise AssertionError(
'unexpeceted install_suffix',
self.install_lib, self.install_libbase, install_suffix,
)
def main():
"""the entry point"""
from textwrap import dedent
setup(
name='ohai',
version='1!0',
url="https://github.com/bukzor/ohai",
license="MIT",
author="Buck Evan",
author_email="[email protected]",
description=DOC,
long_description=dedent(Install.__doc__),
zip_safe=False,
classifiers=[
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'License :: OSI Approved :: MIT License',
],
cmdclass={
'install': Install,
},
options={
'bdist_wheel': {
'universal': 1,
},
},
)
if __name__ == '__main__':
exit(main())