Red-DiscordBot/setup.py
palmtree5 648a1a1893
[V3 Launcher] add launcher (#1110)
* [V3 Launcher] add launcher

* [V3 Launcher] move extras selection to its own function

* Add distro to requirements

* [V3 Launcher] platform.linux_distribution -> distro.linux_distribution

* [V3 Launcher] add methods of setting cli flags to be passed

* [V3 Launcher] pass remaining args not known to launcher's argument parser to redbot

* [V3 Launcher] handle KeyboardInterrupt in launcher

* [V3 Launcher] undo something that would break stuff

* [V3 Launcher] remove co-owners from interactive mode redbot cli flag selection

* [V3 Launcher] clarify the disable console interaction option
2017-12-03 22:09:22 -09:00

128 lines
3.4 KiB
Python

from distutils.core import setup
from pathlib import Path
from subprocess import run, PIPE
import os
from setuptools import find_packages
IS_TRAVIS = 'TRAVIS' in os.environ
dep_links = ['https://github.com/Rapptz/discord.py/tarball/rewrite#egg=discord.py-1.0']
if IS_TRAVIS:
dep_links = []
def get_package_list():
core = find_packages(include=['redbot', 'redbot.*'])
return core
def get_requirements():
with open('requirements.txt') as f:
requirements = f.read().splitlines()
if IS_TRAVIS:
requirements.remove('git+https://github.com/Rapptz/discord.py.git@rewrite#egg=discord.py[voice]')
else:
requirements.append('discord.py>=1.0.0a0') # Because RTD
return requirements
def get_version():
try:
p = run(
"git describe --abbrev=0 --tags".split(),
stdout=PIPE
)
except FileNotFoundError:
# No git
return 3, 0, 0
if p.returncode != 0:
return 3, 0, 0
stdout = p.stdout.strip().decode()
if stdout.startswith("v"):
numbers = stdout[1:].split('.')
args = [0, 0, 0]
for i in range(3):
try:
args[i] = int(numbers[i])
except (IndexError, ValueError):
args[i] = 0
return args
return 3, 0, 0
def find_locale_folders():
"""
Ignore this tomfoolery in the desire for automation. It works, that's
all you gotta know. Don't fuck with this unless you really know what
you're doing, otherwise we lose all translations.
"""
def glob_locale_files(path: Path):
msgs = path.glob("*.po")
parents = path.parents
return [str(m.relative_to(parents[0])) for m in msgs]
ret = {
'redbot.core': glob_locale_files(Path('redbot/core/locales'))
}
cogs_path = Path('redbot/cogs')
for cog_folder in cogs_path.iterdir():
locales_folder = cog_folder / 'locales'
if not locales_folder.is_dir():
continue
pkg_name = str(cog_folder).replace('/', '.')
ret[pkg_name] = glob_locale_files(locales_folder)
return ret
setup(
name='Red-DiscordBot',
version="{}.{}.{}b3".format(*get_version()),
packages=get_package_list(),
package_data=find_locale_folders(),
url='https://github.com/Cog-Creators/Red-DiscordBot',
license='GPLv3',
author='Cog-Creators',
author_email='',
description='A highly customizable Discord bot',
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: AsyncIO',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Communications :: Chat',
'Topic :: Documentation :: Sphinx'
],
entry_points={
'console_scripts': [
'redbot=redbot.__main__:main',
'redbot-setup=redbot.setup:basic_setup',
'redbot-launcher=redbot.launcher:main'
]
},
python_requires='>=3.5',
setup_requires=get_requirements(),
install_requires=get_requirements(),
dependency_links=dep_links,
extras_require={
'test': [
'pytest>=3', 'pytest-asyncio'
],
'mongo': ['motor'],
'docs': ['sphinx', 'sphinxcontrib-asyncio', 'sphinx_rtd_theme'],
'voice': ['PyNaCl']
}
)