2013-01-21 20:42:57 +01:00
|
|
|
|
#!/usr/bin/env python
|
2013-03-11 10:40:09 +01:00
|
|
|
|
# vim:fileencoding=utf-8:noet
|
2014-08-31 20:55:26 +02:00
|
|
|
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
|
|
|
|
|
2012-12-13 15:43:38 +01:00
|
|
|
|
import os
|
2013-03-03 17:40:35 +01:00
|
|
|
|
import sys
|
2013-07-31 22:15:35 +02:00
|
|
|
|
import subprocess
|
2014-08-02 17:48:07 +02:00
|
|
|
|
import logging
|
2014-12-09 09:32:05 +01:00
|
|
|
|
import shlex
|
2012-12-13 15:43:38 +01:00
|
|
|
|
|
2015-02-14 23:04:58 +01:00
|
|
|
|
from traceback import print_exc
|
2012-12-13 15:43:38 +01:00
|
|
|
|
from setuptools import setup, find_packages
|
|
|
|
|
|
2014-08-31 20:55:26 +02:00
|
|
|
|
|
2013-07-31 22:15:35 +02:00
|
|
|
|
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
2012-12-13 15:43:38 +01:00
|
|
|
|
try:
|
2013-07-31 22:15:35 +02:00
|
|
|
|
README = open(os.path.join(CURRENT_DIR, 'README.rst'), 'rb').read().decode('utf-8')
|
2012-12-13 15:43:38 +01:00
|
|
|
|
except IOError:
|
|
|
|
|
README = ''
|
|
|
|
|
|
2013-07-31 22:15:35 +02:00
|
|
|
|
OLD_PYTHON = sys.version_info < (2, 7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compile_client():
|
|
|
|
|
'''Compile the C powerline-client script.'''
|
|
|
|
|
|
|
|
|
|
if hasattr(sys, 'getwindowsversion'):
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
else:
|
|
|
|
|
from distutils.ccompiler import new_compiler
|
|
|
|
|
compiler = new_compiler().compiler
|
2015-02-14 23:19:06 +01:00
|
|
|
|
cflags = os.environ.get('CFLAGS', str('-O3'))
|
2014-12-09 09:32:05 +01:00
|
|
|
|
# A normal split would do a split on each space which might be incorrect. The
|
|
|
|
|
# shlex will not split if a space occurs in an arguments value.
|
|
|
|
|
subprocess.check_call(compiler + shlex.split(cflags) + ['client/powerline.c', '-o', 'scripts/powerline'])
|
2013-07-31 22:15:35 +02:00
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
compile_client()
|
2014-08-02 17:48:07 +02:00
|
|
|
|
except Exception as e:
|
|
|
|
|
print('Compiling C version of powerline-client failed')
|
|
|
|
|
logging.exception(e)
|
2013-07-31 22:15:35 +02:00
|
|
|
|
# FIXME Catch more specific exceptions
|
|
|
|
|
import shutil
|
2014-08-02 17:48:07 +02:00
|
|
|
|
if hasattr(shutil, 'which'):
|
|
|
|
|
which = shutil.which
|
|
|
|
|
else:
|
|
|
|
|
sys.path.append(CURRENT_DIR)
|
2014-10-27 06:11:07 +01:00
|
|
|
|
from powerline.lib.shell import which
|
2014-08-02 17:48:07 +02:00
|
|
|
|
if which('socat') and which('sed') and which('sh'):
|
|
|
|
|
print('Using powerline.sh script instead of C version (requires socat, sed and sh)')
|
|
|
|
|
shutil.copyfile('client/powerline.sh', 'scripts/powerline')
|
|
|
|
|
can_use_scripts = True
|
|
|
|
|
else:
|
|
|
|
|
print('Using powerline.py script instead of C version')
|
|
|
|
|
shutil.copyfile('client/powerline.py', 'scripts/powerline')
|
|
|
|
|
can_use_scripts = True
|
|
|
|
|
else:
|
|
|
|
|
can_use_scripts = False
|
2013-03-03 17:40:35 +01:00
|
|
|
|
|
2014-10-18 22:05:51 +02:00
|
|
|
|
|
|
|
|
|
def get_version():
|
2016-07-13 23:43:25 +02:00
|
|
|
|
base_version = '2.5'
|
2015-02-14 23:04:58 +01:00
|
|
|
|
base_version += '.dev9999'
|
2014-10-18 22:05:51 +02:00
|
|
|
|
try:
|
2015-02-14 23:04:58 +01:00
|
|
|
|
return base_version + '+git.' + str(subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip())
|
|
|
|
|
except Exception:
|
|
|
|
|
print_exc()
|
|
|
|
|
return base_version
|
2014-10-18 22:05:51 +02:00
|
|
|
|
|
|
|
|
|
|
2013-02-20 13:47:54 +01:00
|
|
|
|
setup(
|
2014-09-04 06:46:29 +02:00
|
|
|
|
name='powerline-status',
|
2014-10-18 22:05:51 +02:00
|
|
|
|
version=get_version(),
|
2012-12-13 15:43:38 +01:00
|
|
|
|
description='The ultimate statusline/prompt utility.',
|
|
|
|
|
long_description=README,
|
2014-09-04 06:46:03 +02:00
|
|
|
|
classifiers=[
|
|
|
|
|
'Development Status :: 4 - Beta',
|
|
|
|
|
'Environment :: Console',
|
|
|
|
|
'Environment :: Plugins',
|
|
|
|
|
'Intended Audience :: End Users/Desktop',
|
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
|
'Natural Language :: English',
|
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
|
'Operating System :: POSIX',
|
|
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
|
'Programming Language :: Python :: 3.2',
|
|
|
|
|
'Programming Language :: Python :: 3.3',
|
|
|
|
|
'Programming Language :: Python :: 3.4',
|
|
|
|
|
'Programming Language :: Python :: Implementation :: CPython',
|
|
|
|
|
'Programming Language :: Python :: Implementation :: PyPy',
|
|
|
|
|
],
|
2014-12-07 14:08:24 +01:00
|
|
|
|
download_url='https://github.com/powerline/powerline/archive/develop.zip',
|
2013-08-20 13:07:56 +02:00
|
|
|
|
author='Kim Silkebaekken',
|
2012-12-13 15:43:38 +01:00
|
|
|
|
author_email='kim.silkebaekken+vim@gmail.com',
|
2014-12-07 14:08:24 +01:00
|
|
|
|
url='https://github.com/powerline/powerline',
|
2014-09-04 06:46:03 +02:00
|
|
|
|
license='MIT',
|
2014-09-20 15:48:15 +02:00
|
|
|
|
# XXX Python 3 doesn’t allow compiled C files to be included in the scripts
|
2013-11-22 17:23:56 +01:00
|
|
|
|
# list below. This is because Python 3 distutils tries to decode the file to
|
|
|
|
|
# ASCII, and fails when powerline-client is a binary.
|
|
|
|
|
#
|
|
|
|
|
# XXX Python 2 fucks up script contents*. Not using it to install scripts
|
|
|
|
|
# any longer.
|
|
|
|
|
# * Consider the following input:
|
|
|
|
|
# % alias hex1=$'hexdump -e \'"" 1/1 "%02X\n"\''
|
|
|
|
|
# % diff <(hex1 ./scripts/powerline) <(hex1 ~/.local/bin/powerline)
|
|
|
|
|
# This will show output like
|
|
|
|
|
# 375c375
|
|
|
|
|
# < 0D
|
|
|
|
|
# ---
|
|
|
|
|
# > 0A
|
|
|
|
|
# (repeated, with diff segment header numbers growing up).
|
|
|
|
|
#
|
|
|
|
|
# FIXME Current solution does not work with `pip install -e`. Still better
|
|
|
|
|
# then solution that is not working at all.
|
2013-01-17 09:25:56 +01:00
|
|
|
|
scripts=[
|
2013-03-09 13:16:00 +01:00
|
|
|
|
'scripts/powerline-lint',
|
2013-07-31 22:15:35 +02:00
|
|
|
|
'scripts/powerline-daemon',
|
|
|
|
|
'scripts/powerline-render',
|
2014-05-24 11:44:58 +02:00
|
|
|
|
'scripts/powerline-config',
|
2014-08-02 17:48:07 +02:00
|
|
|
|
] + (['scripts/powerline'] if can_use_scripts else []),
|
|
|
|
|
data_files=(None if can_use_scripts else (('bin', ['scripts/powerline']),)),
|
2012-12-13 15:43:38 +01:00
|
|
|
|
keywords='',
|
2013-03-10 12:13:23 +01:00
|
|
|
|
packages=find_packages(exclude=('tests', 'tests.*')),
|
2012-12-13 15:43:38 +01:00
|
|
|
|
include_package_data=True,
|
|
|
|
|
zip_safe=False,
|
2013-01-15 08:49:40 +01:00
|
|
|
|
install_requires=[],
|
2012-12-13 15:43:38 +01:00
|
|
|
|
extras_require={
|
2013-01-15 08:49:40 +01:00
|
|
|
|
'docs': [
|
|
|
|
|
'Sphinx',
|
2014-01-25 16:20:06 +01:00
|
|
|
|
'sphinx_rtd_theme',
|
2013-03-25 16:04:18 +01:00
|
|
|
|
],
|
|
|
|
|
},
|
2013-07-31 22:15:35 +02:00
|
|
|
|
test_suite='tests' if not OLD_PYTHON else None,
|
2013-03-25 16:04:18 +01:00
|
|
|
|
)
|