2014-08-16 20:37:29 +00:00
|
|
|
#!/usr/bin/env python3
|
2011-06-18 21:32:09 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2011-08-12 23:47:58 +00:00
|
|
|
# Copyright (C) 2007-2011 Nathanael C. Fritz
|
2011-06-18 21:32:09 +00:00
|
|
|
# All Rights Reserved
|
|
|
|
#
|
2011-08-25 04:54:36 +00:00
|
|
|
# This software is licensed as described in the README.rst and LICENSE
|
|
|
|
# file, which you should have received as part of this distribution.
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2016-10-05 19:28:11 +00:00
|
|
|
import os
|
2014-08-19 10:59:09 +00:00
|
|
|
from pathlib import Path
|
2016-12-25 12:28:51 +00:00
|
|
|
from subprocess import call, DEVNULL, check_output, CalledProcessError
|
2016-10-05 19:28:11 +00:00
|
|
|
from tempfile import TemporaryFile
|
2011-11-08 15:01:16 +00:00
|
|
|
try:
|
2014-08-19 10:59:09 +00:00
|
|
|
from setuptools import setup
|
2011-11-08 15:01:16 +00:00
|
|
|
except ImportError:
|
2014-08-19 10:59:09 +00:00
|
|
|
from distutils.core import setup
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2014-08-20 19:55:36 +00:00
|
|
|
from run_tests import TestCommand
|
2014-07-17 12:19:04 +00:00
|
|
|
from slixmpp.version import __version__
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2014-08-19 10:59:09 +00:00
|
|
|
VERSION = __version__
|
2019-02-10 14:18:07 +00:00
|
|
|
DESCRIPTION = ('Slixmpp is an elegant Python library for XMPP (aka Jabber).')
|
2014-08-19 10:59:09 +00:00
|
|
|
with open('README.rst', encoding='utf8') as readme:
|
|
|
|
LONG_DESCRIPTION = readme.read()
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2014-08-19 10:59:09 +00:00
|
|
|
CLASSIFIERS = [
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Programming Language :: Python',
|
2018-08-08 21:42:22 +00:00
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-05-01 13:13:19 +00:00
|
|
|
'Programming Language :: Python :: 3.8',
|
2020-11-27 17:34:31 +00:00
|
|
|
'Programming Language :: Python :: 3.9',
|
2017-04-10 00:22:43 +00:00
|
|
|
'Topic :: Internet :: XMPP',
|
2014-08-19 10:59:09 +00:00
|
|
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
|
|
]
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2014-08-19 10:59:09 +00:00
|
|
|
packages = [str(mod.parent) for mod in Path('slixmpp').rglob('__init__.py')]
|
2011-06-18 21:32:09 +00:00
|
|
|
|
2016-12-25 12:28:51 +00:00
|
|
|
def check_include(library_name, header):
|
|
|
|
command = [os.environ.get('PKG_CONFIG', 'pkg-config'), '--cflags', library_name]
|
|
|
|
try:
|
|
|
|
cflags = check_output(command).decode('utf-8').split()
|
|
|
|
except FileNotFoundError:
|
|
|
|
print('pkg-config not found.')
|
|
|
|
return False
|
|
|
|
except CalledProcessError:
|
|
|
|
# pkg-config already prints the missing libraries on stderr.
|
|
|
|
return False
|
|
|
|
command = [os.environ.get('CC', 'cc')] + cflags + ['-E', '-']
|
2016-10-05 19:28:11 +00:00
|
|
|
with TemporaryFile('w+') as c_file:
|
|
|
|
c_file.write('#include <%s>' % header)
|
|
|
|
c_file.seek(0)
|
|
|
|
try:
|
|
|
|
return call(command, stdin=c_file, stdout=DEVNULL, stderr=DEVNULL) == 0
|
|
|
|
except FileNotFoundError:
|
2016-12-25 12:28:51 +00:00
|
|
|
print('%s headers not found.' % library_name)
|
2016-10-05 19:28:11 +00:00
|
|
|
return False
|
|
|
|
|
2016-12-25 12:28:51 +00:00
|
|
|
HAS_PYTHON_HEADERS = check_include('python3', 'Python.h')
|
|
|
|
HAS_STRINGPREP_HEADERS = check_include('libidn', 'stringprep.h')
|
|
|
|
|
2016-10-05 19:28:11 +00:00
|
|
|
ext_modules = None
|
2016-12-25 12:28:51 +00:00
|
|
|
if HAS_PYTHON_HEADERS and HAS_STRINGPREP_HEADERS:
|
2016-10-05 19:28:11 +00:00
|
|
|
try:
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
except ImportError:
|
|
|
|
print('Cython not found, falling back to the slow stringprep module.')
|
|
|
|
else:
|
|
|
|
ext_modules = cythonize('slixmpp/stringprep.pyx')
|
|
|
|
else:
|
2016-12-25 12:28:51 +00:00
|
|
|
print('Falling back to the slow stringprep module.')
|
2016-10-05 19:28:11 +00:00
|
|
|
|
2011-06-18 21:32:09 +00:00
|
|
|
setup(
|
2014-08-19 10:59:09 +00:00
|
|
|
name="slixmpp",
|
|
|
|
version=VERSION,
|
|
|
|
description=DESCRIPTION,
|
|
|
|
long_description=LONG_DESCRIPTION,
|
|
|
|
author='Florent Le Coz',
|
|
|
|
author_email='louiz@louiz.org',
|
2019-02-12 10:26:04 +00:00
|
|
|
url='https://lab.louiz.org/poezio/slixmpp',
|
2014-08-19 10:59:09 +00:00
|
|
|
license='MIT',
|
|
|
|
platforms=['any'],
|
|
|
|
packages=packages,
|
2015-06-12 00:36:56 +00:00
|
|
|
ext_modules=ext_modules,
|
2020-12-12 15:30:34 +00:00
|
|
|
install_requires=['aiodns>=1.0', 'pyasn1', 'pyasn1_modules'],
|
|
|
|
extras_require={
|
|
|
|
'XEP-0363': ['aiohttp'],
|
|
|
|
'XEP-0444 compliance': ['emoji'],
|
|
|
|
},
|
2014-08-19 10:59:09 +00:00
|
|
|
classifiers=CLASSIFIERS,
|
|
|
|
cmdclass={'test': TestCommand}
|
2011-08-12 23:47:58 +00:00
|
|
|
)
|