2014-03-20 23:54:46 +00:00
|
|
|
#!/usr/bin/env python3
|
2014-10-27 18:16:32 +00:00
|
|
|
|
2014-03-22 12:33:21 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
except ImportError:
|
2015-02-07 21:09:05 +00:00
|
|
|
print('\nSetuptools was not found. Install setuptools for python 3.\n')
|
|
|
|
import sys
|
|
|
|
sys.exit(1)
|
2014-03-22 12:33:21 +00:00
|
|
|
|
2018-03-31 09:27:20 +00:00
|
|
|
import os
|
2018-03-31 09:29:00 +00:00
|
|
|
import subprocess
|
2018-03-31 09:29:41 +00:00
|
|
|
from tempfile import TemporaryFile
|
2011-09-09 16:46:42 +00:00
|
|
|
|
2018-03-31 09:27:20 +00:00
|
|
|
current_dir = os.path.dirname(__file__)
|
2011-09-09 16:46:42 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
def get_relative_dir(folder, stopper):
|
|
|
|
"""
|
|
|
|
Find the path from a directory to a pseudo-root in order to recreate
|
|
|
|
the filetree.
|
|
|
|
"""
|
|
|
|
acc = []
|
2018-03-31 09:27:20 +00:00
|
|
|
last = os.path.basename(folder)
|
2015-02-10 16:40:53 +00:00
|
|
|
while last != stopper:
|
|
|
|
acc.append(last)
|
2018-03-31 09:27:20 +00:00
|
|
|
folder = os.path.dirname(folder)
|
|
|
|
last = os.path.basename(folder)
|
|
|
|
return os.path.join(*acc[::-1]) if acc else ''
|
2013-05-29 13:32:25 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
def find_doc(before, path):
|
|
|
|
_files = []
|
2018-03-31 09:27:20 +00:00
|
|
|
stop = os.path.basename(path)
|
|
|
|
for root, dirs, files in os.walk(os.path.join(current_dir, 'doc', path)):
|
2015-02-10 16:40:53 +00:00
|
|
|
files_path = []
|
|
|
|
relative_root = get_relative_dir(root, stop)
|
|
|
|
for name in files:
|
2018-03-31 09:27:20 +00:00
|
|
|
files_path.append(os.path.join(root, name))
|
|
|
|
_files.append((os.path.join(before, relative_root), files_path))
|
2015-02-10 16:40:53 +00:00
|
|
|
return _files
|
|
|
|
|
2018-03-31 00:01:03 +00:00
|
|
|
def check_include(library_name, header):
|
|
|
|
command = [os.environ.get('PKG_CONFIG', 'pkg-config'), '--cflags', library_name]
|
|
|
|
try:
|
2018-03-31 09:29:00 +00:00
|
|
|
cflags = subprocess.check_output(command).decode('utf-8').split()
|
2018-03-31 00:01:03 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
print('pkg-config not found.')
|
|
|
|
return False
|
2018-03-31 09:29:00 +00:00
|
|
|
except subprocess.CalledProcessError:
|
2018-03-31 00:01:03 +00:00
|
|
|
# pkg-config already prints the missing libraries on stderr.
|
|
|
|
return False
|
|
|
|
command = [os.environ.get('CC', 'cc')] + cflags + ['-E', '-']
|
|
|
|
with TemporaryFile('w+') as c_file:
|
|
|
|
c_file.write('#include <%s>' % header)
|
|
|
|
c_file.seek(0)
|
|
|
|
try:
|
2018-03-31 09:29:00 +00:00
|
|
|
return subprocess.call(command, stdin=c_file, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0
|
2018-03-31 00:01:03 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
print('%s headers not found.' % library_name)
|
|
|
|
return False
|
|
|
|
|
|
|
|
if not check_include('python3', 'Python.h'):
|
|
|
|
import sys
|
2018-03-31 00:03:05 +00:00
|
|
|
sys.exit(2)
|
2018-03-31 00:01:03 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
module_poopt = Extension('poezio.poopt',
|
|
|
|
extra_compile_args=['-Wno-declaration-after-statement'],
|
2016-03-31 17:54:41 +00:00
|
|
|
sources=['poezio/pooptmodule.c'])
|
2013-05-29 13:32:25 +00:00
|
|
|
|
|
|
|
# Create a link to the config file (for packaging purposes)
|
2018-03-31 09:27:20 +00:00
|
|
|
if not os.path.exists(os.path.join(current_dir, 'poezio', 'default_config.cfg')):
|
|
|
|
os.link(os.path.join(current_dir, 'data', 'default_config.cfg'),
|
|
|
|
os.path.join(current_dir, 'poezio', 'default_config.cfg'))
|
2013-05-29 13:32:25 +00:00
|
|
|
|
2015-01-20 23:29:08 +00:00
|
|
|
# identify the git version
|
2018-03-31 09:27:20 +00:00
|
|
|
git_dir = os.path.join(current_dir, '.git')
|
|
|
|
if os.path.exists(git_dir):
|
2015-01-20 23:29:08 +00:00
|
|
|
try:
|
2015-01-21 13:18:19 +00:00
|
|
|
result = subprocess.Popen(['git', '--git-dir', git_dir, 'describe'],
|
2015-01-21 13:47:10 +00:00
|
|
|
stdout=subprocess.PIPE,
|
2015-01-21 13:18:19 +00:00
|
|
|
stderr=subprocess.DEVNULL)
|
2015-01-20 23:29:08 +00:00
|
|
|
result.wait()
|
|
|
|
data = result.stdout.read().decode('utf-8', errors='ignore')
|
|
|
|
version = '.dev' + data.split('-')[1]
|
|
|
|
except:
|
|
|
|
version = '.dev1'
|
|
|
|
else:
|
|
|
|
version = '.dev1'
|
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
with open('README.rst', encoding='utf-8') as readme_fd:
|
|
|
|
LONG_DESCRIPTION = readme_fd.read()
|
2013-05-26 18:07:12 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
setup(name="poezio",
|
2017-01-30 23:22:19 +00:00
|
|
|
version="1.0" + version,
|
2015-02-10 16:40:53 +00:00
|
|
|
description="A console XMPP client",
|
|
|
|
long_description=LONG_DESCRIPTION,
|
|
|
|
ext_modules=[module_poopt],
|
2016-03-09 17:03:02 +00:00
|
|
|
url='https://poez.io/',
|
2015-02-10 16:40:53 +00:00
|
|
|
license='zlib',
|
|
|
|
download_url='https://dev.louiz.org/projects/poezio/files',
|
2013-05-26 18:07:12 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
author='Florent Le Coz',
|
|
|
|
author_email='louiz@louiz.org',
|
2013-05-26 18:07:12 +00:00
|
|
|
|
2015-02-10 16:40:53 +00:00
|
|
|
maintainer='Mathieu Pasquet',
|
|
|
|
maintainer_email='mathieui@mathieui.net',
|
2014-03-20 23:54:46 +00:00
|
|
|
|
2016-08-31 02:17:17 +00:00
|
|
|
classifiers=['Development Status :: 5 - Production/Stable',
|
2015-02-10 16:40:53 +00:00
|
|
|
'Topic :: Communications :: Chat',
|
2017-04-10 00:21:51 +00:00
|
|
|
'Topic :: Internet :: XMPP',
|
2015-02-10 16:40:53 +00:00
|
|
|
'Environment :: Console :: Curses',
|
|
|
|
'Intended Audience :: End Users/Desktop',
|
|
|
|
'License :: OSI Approved :: zlib/libpng License',
|
|
|
|
'Natural Language :: English',
|
|
|
|
'Operating System :: Unix',
|
2018-08-13 20:33:44 +00:00
|
|
|
'Programming Language :: Python :: 3.7',
|
2017-02-13 18:03:12 +00:00
|
|
|
'Programming Language :: Python :: 3.6',
|
2016-08-31 02:17:17 +00:00
|
|
|
'Programming Language :: Python :: 3.5',
|
2015-02-10 16:40:53 +00:00
|
|
|
'Programming Language :: Python :: 3 :: Only'],
|
|
|
|
keywords=['jabber', 'xmpp', 'client', 'chat', 'im', 'console'],
|
|
|
|
packages=['poezio', 'poezio.core', 'poezio.tabs', 'poezio.windows',
|
2018-08-08 22:59:03 +00:00
|
|
|
'poezio_plugins', 'poezio_themes'],
|
2016-03-31 17:54:41 +00:00
|
|
|
package_dir={'poezio': 'poezio',
|
2015-02-10 16:40:53 +00:00
|
|
|
'poezio_plugins': 'plugins',
|
|
|
|
'poezio_themes': 'data/themes'},
|
|
|
|
package_data={'poezio': ['default_config.cfg']},
|
2018-08-08 22:59:03 +00:00
|
|
|
scripts=['scripts/poezio_logs'],
|
2016-07-02 23:59:05 +00:00
|
|
|
entry_points={'console_scripts': ['poezio = poezio.__main__:run']},
|
2016-10-28 15:24:39 +00:00
|
|
|
data_files=([('share/man/man1/', ['data/poezio.1',
|
|
|
|
'data/poezio_logs.1']),
|
2015-02-10 16:40:53 +00:00
|
|
|
('share/poezio/', ['README.rst', 'COPYING', 'CHANGELOG'])]
|
2015-02-10 20:18:09 +00:00
|
|
|
+ find_doc('share/doc/poezio/source', 'source')
|
|
|
|
+ find_doc('share/doc/poezio/html', 'build/html')),
|
2017-11-28 19:41:49 +00:00
|
|
|
install_requires=['slixmpp>=1.3.0', 'aiodns', 'pyasn1_modules', 'pyasn1'],
|
2015-02-10 16:40:53 +00:00
|
|
|
extras_require={'OTR plugin': 'python-potr>=1.0',
|
2017-11-14 23:44:26 +00:00
|
|
|
'Screen autoaway plugin': 'pyinotify==0.9.4',
|
|
|
|
'Avoiding cython': 'cffi'})
|
2013-05-29 13:32:25 +00:00
|
|
|
|
|
|
|
# Remove the link afterwards
|
2018-03-31 09:27:20 +00:00
|
|
|
if (os.path.exists(os.path.join(current_dir, 'poezio', 'default_config.cfg')) and
|
|
|
|
os.path.exists(os.path.join(current_dir, 'data', 'default_config.cfg'))):
|
2015-02-26 22:40:18 +00:00
|
|
|
|
2018-03-31 09:27:20 +00:00
|
|
|
os.unlink(os.path.join(current_dir, 'poezio', 'default_config.cfg'))
|
2013-05-29 13:32:25 +00:00
|
|
|
|