powerline/setup.py

83 lines
2.3 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# vim:fileencoding=utf-8:noet
2013-07-20 15:14:18 +02:00
from __future__ import unicode_literals
2012-12-13 15:43:38 +01:00
import os
import sys
import subprocess
2012-12-13 15:43:38 +01:00
from setuptools import setup, find_packages
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
2012-12-13 15:43:38 +01:00
try:
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 = ''
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
subprocess.check_call(compiler + ['-O3', 'client/powerline.c', '-o', 'scripts/powerline'])
try:
compile_client()
except Exception:
# FIXME Catch more specific exceptions
import shutil
print('Compiling C version of powerline-client failed, using Python version instead')
shutil.copyfile('client/powerline.py', 'scripts/powerline')
setup(
name='Powerline',
2012-12-17 15:24:42 +01:00
version='beta',
2012-12-13 15:43:38 +01:00
description='The ultimate statusline/prompt utility.',
long_description=README,
classifiers=[],
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',
url='https://github.com/Lokaltog/powerline',
# XXX Python 3 doesn't allow compiled C files to be included in the scripts
# 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=[
'scripts/powerline-lint',
'scripts/powerline-daemon',
'scripts/powerline-render',
'scripts/powerline-config',
],
data_files=[('bin', ['scripts/powerline'])],
2012-12-13 15:43:38 +01:00
keywords='',
packages=find_packages(exclude=('tests', 'tests.*')),
2012-12-13 15:43:38 +01:00
include_package_data=True,
zip_safe=False,
install_requires=[],
2012-12-13 15:43:38 +01:00
extras_require={
'docs': [
'Sphinx',
],
},
test_suite='tests' if not OLD_PYTHON else None,
)