Red-DiscordBot/setup.py
Will d69fd63da7 [V3 Everything] Package bot and write setup scripts (#964)
Ya'll are gonna hate me.

* Initial modifications

* Add initial setup.py

* working setup py help

* Modify setup file to package stuff

* Move a bunch of shit and fix imports

* Fix or skip tests

* Must add init files for find_packages to work

* Move main to scripts folder and rename

* Add shebangs

* Copy over translation files

* WORKING PIP INSTALL

* add dependency information

* Hardcoded version for now, will need to figure out a better way to do this

* OKAY ITS FINALLY FUCKING WORKING

* Add this guy

* Fix stuff

* Change readme to rst

* Remove double sentry opt in

* Oopsie

* Fix this thing

* Aaaand fix test

* Aaaand fix test

* Fix core cog importing and default cog install path

* Adjust readme

* change instance name from optional to required

* Ayyy let's do more dependency injection
2017-09-08 23:14:32 -04:00

112 lines
3.1 KiB
Python

from distutils.core import setup
from pathlib import Path
from subprocess import run, PIPE
from setuptools import find_packages
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()
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="{}.{}.{}a13".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']
},
python_requires='>=3.5',
setup_requires=get_requirements(),
install_requires=get_requirements(),
dependency_links=[
'https://github.com/Rapptz/discord.py/tarball/rewrite#egg=discord.py-1.0'
],
extras_require={
'test': ['pytest>=3', 'pytest-asyncio'],
'mongo': ['pymongo', 'motor'],
'docs': ['sphinx', 'sphinxcontrib-asyncio', 'sphinx_rtd_theme']
}
)