forked from ultrabug/py3status
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·109 lines (91 loc) · 3.17 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
"""
py3status
"""
import os
import sys
from setuptools import find_packages, setup
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.easy_install import _to_ascii, ScriptWriter
module_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'py3status')
sys.path.insert(0, module_path)
from version import version # noqa
sys.path.remove(module_path)
# setuptools causes scripts to run slowly see
# https://github.com/pypa/setuptools/issues/510
# We can make py3-cmd run much faster when installed via
# python setup install/develop
PY3_CMD_SCRIPT_TEXT = u"""{}
# -*- coding: utf-8 -*-
import re
import sys
from py3status.command import send_command
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(send_command())
"""
def install_py3_cmd(installer):
"""Attempt to overwrite /bin/py3-cmd with efficient version"""
py_cmd = ScriptWriter.get_header()
script_text = PY3_CMD_SCRIPT_TEXT.format(py_cmd)
try:
installer.write_script('py3-cmd', _to_ascii(script_text), 'b')
except AttributeError:
# building wheel etc
pass
class PostDevelopCommand(develop):
"""Post-installation for develop"""
def run(self):
develop.run(self)
install_py3_cmd(self)
class PostInstallCommand(install):
"""Post-installation for install"""
def run(self):
install.run(self)
install_py3_cmd(self)
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name='py3status',
version=version,
author='Ultrabug',
author_email='[email protected]',
description='py3status: an extensible i3status wrapper written in python',
long_description=read('README.rst'),
extras_require={'gevent': ['gevent >= 1.1']},
url='https://github.com/ultrabug/py3status',
download_url='https://github.com/ultrabug/py3status/tags',
license='BSD',
platforms='any',
packages=find_packages(),
include_package_data=True,
install_requires=[],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
entry_points={
'console_scripts': [
'py3status = py3status:main',
'py3-cmd = py3status.command:send_command',
]
},
classifiers=[
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules',
], )