-
Notifications
You must be signed in to change notification settings - Fork 238
/
setup.py
147 lines (119 loc) · 4.56 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Upload (and download) files to Telegram up to 4 GiB using your account.
"""
import copy
import os
import glob
from itertools import chain
from setuptools import setup, find_packages
AUTHOR = "Nekmo"
EMAIL = 'contacto@nekmo.com'
URL = 'https://github.com/Nekmo/telegram-upload/'
PACKAGE_NAME = 'telegram-upload'
PACKAGE_DOWNLOAD_URL = 'https://github.com/Nekmo/telegram-upload/archive/master.zip'
MODULE = 'telegram_upload'
REQUIREMENT_FILE = 'requirements.txt'
STATUS_LEVEL = 5 # 1:Planning 2:Pre-Alpha 3:Alpha 4:Beta 5:Production/Stable 6:Mature 7:Inactive
KEYWORDS = ['telegram-upload', 'telegram', 'upload', 'video']
LICENSE = 'MIT license'
CLASSIFIERS = [ # https://github.com/github/choosealicense.com/tree/gh-pages/_licenses
'License :: OSI Approved :: MIT License',
# 'License :: OSI Approved :: BSD License',
# 'License :: OSI Approved :: ISC License (ISCL)',
# 'License :: OSI Approved :: Apache Software License',
# 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
] # https://pypi.python.org/pypi?%3Aaction=list_classifiers
NATURAL_LANGUAGE = 'English'
PLATFORMS = [
# 'universal',
'linux',
# 'macosx',
# 'solaris',
# 'irix',
# 'win'
# 'bsd'
# 'ios'
# 'android'
]
PYTHON_VERSIONS = ['3.7-3.9', '3.10', '3.11']
def read_requirement_file(path):
with open(path) as f:
return f.readlines()
def get_package_version(module_name):
return __import__(module_name).__version__
def get_packages(directory):
# Search modules and submodules to install (module, module.submodule, module.submodule2...)
packages_list = find_packages(directory)
# Prevent include symbolic links
for package in tuple(packages_list):
path = os.path.join(directory, package.replace('.', '/'))
if not os.path.exists(path) or os.path.islink(path):
packages_list.remove(package)
return packages_list
def get_python_versions(string_range):
if '-' not in string_range:
return [string_range]
return ['{0:.1f}'.format(version * 0.1) for version
in range(*[int(x * 10) + (1 * i) for i, x in enumerate(map(float, string_range.split('-')))])]
def get_python_classifiers(versions):
for version in range(2, 4):
if not next(iter(filter(lambda x: int(float(x)) != version, versions.copy())), False):
versions.add('{} :: Only'.format(version))
break
return ['Programming Language :: Python :: %s' % version for version in versions]
def get_platform_classifiers(platform):
parts = {
'linux': ('POSIX', 'Linux'),
'win': ('Microsoft', 'Windows'),
'solaris': ('POSIX', 'SunOS/Solaris'),
'aix': ('POSIX', 'Linux'),
'unix': ('Unix',),
'bsd': ('POSIX', 'BSD')
}[platform]
return ['Operating System :: {}'.format(' :: '.join(parts[:i+1]))
for i in range(len(parts))]
# paths
here = os.path.abspath(os.path.dirname(__file__))
readme = glob.glob('{}/{}*'.format(here, 'README'))[0]
scripts = [os.path.join('scripts', os.path.basename(script)) for script in glob.glob('{}/scripts/*'.format(here))]
# Package data
packages = get_packages(here)
modules = list(filter(lambda x: '.' not in x, packages))
module = MODULE if MODULE else modules[0]
python_versions = set(chain(*[get_python_versions(versions) for versions in PYTHON_VERSIONS])) - {2.8, 2.9}
status_name = ['Planning', 'Pre-Alpha', 'Alpha', 'Beta',
'Production/Stable', 'Mature', 'Inactive'][STATUS_LEVEL - 1]
# Classifiers
classifiers = copy.copy(CLASSIFIERS)
classifiers.extend(get_python_classifiers(python_versions))
classifiers.extend(chain(*[get_platform_classifiers(platform) for platform in PLATFORMS]))
classifiers.extend([
'Natural Language :: {}'.format(NATURAL_LANGUAGE),
'Development Status :: {} - {}'.format(STATUS_LEVEL, status_name),
])
setup(
name=PACKAGE_NAME,
version=get_package_version(module),
packages=packages,
provides=modules,
scripts=scripts,
include_package_data=True,
description=__doc__.replace('\n', ' '),
long_description=open(readme, 'r').read(),
keywords=KEYWORDS,
download_url=PACKAGE_DOWNLOAD_URL,
author=AUTHOR,
author_email=EMAIL,
url=URL,
classifiers=classifiers,
platforms=PLATFORMS,
install_requires=read_requirement_file(REQUIREMENT_FILE),
entry_points={
"console_scripts": [
"telegram-upload = telegram_upload.management:upload_cli",
"telegram-download = telegram_upload.management:download_cli",
],
},
zip_safe=False,
)