| 1 |
#!/usr/bin/env python3 |
| 2 |
import codecs |
| 3 |
import os |
| 4 |
import re |
| 5 |
|
| 6 |
import setuptools |
| 7 |
|
| 8 |
NAME = 'celery' |
| 9 |
|
| 10 |
# -*- Extras -*- |
| 11 |
|
| 12 |
EXTENSIONS = ( |
| 13 |
'arangodb', |
| 14 |
'auth', |
| 15 |
'azureblockblob', |
| 16 |
'brotli', |
| 17 |
'cassandra', |
| 18 |
'consul', |
| 19 |
'cosmosdbsql', |
| 20 |
'couchbase', |
| 21 |
'couchdb', |
| 22 |
'django', |
| 23 |
'dynamodb', |
| 24 |
'elasticsearch', |
| 25 |
'eventlet', |
| 26 |
'gevent', |
| 27 |
'gcs', |
| 28 |
'librabbitmq', |
| 29 |
'memcache', |
| 30 |
'mongodb', |
| 31 |
'msgpack', |
| 32 |
'pymemcache', |
| 33 |
'pydantic', |
| 34 |
'pyro', |
| 35 |
'pytest', |
| 36 |
'redis', |
| 37 |
's3', |
| 38 |
'slmq', |
| 39 |
'solar', |
| 40 |
'sqlalchemy', |
| 41 |
'sqs', |
| 42 |
'tblib', |
| 43 |
'yaml', |
| 44 |
'zookeeper', |
| 45 |
'zstd' |
| 46 |
) |
| 47 |
|
| 48 |
# -*- Distribution Meta -*- |
| 49 |
|
| 50 |
re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)') |
| 51 |
re_doc = re.compile(r'^"""(.+?)"""') |
| 52 |
|
| 53 |
|
| 54 |
def _add_default(m): |
| 55 |
attr_name, attr_value = m.groups() |
| 56 |
return ((attr_name, attr_value.strip("\"'")),) |
| 57 |
|
| 58 |
|
| 59 |
def _add_doc(m): |
| 60 |
return (('doc', m.groups()[0]),) |
| 61 |
|
| 62 |
|
| 63 |
def parse_dist_meta(): |
| 64 |
"""Extract metadata information from ``$dist/__init__.py``.""" |
| 65 |
pats = {re_meta: _add_default, re_doc: _add_doc} |
| 66 |
here = os.path.abspath(os.path.dirname(__file__)) |
| 67 |
with open(os.path.join(here, NAME, '__init__.py')) as meta_fh: |
| 68 |
distmeta = {} |
| 69 |
for line in meta_fh: |
| 70 |
if line.strip() == '# -eof meta-': |
| 71 |
break |
| 72 |
for pattern, handler in pats.items(): |
| 73 |
m = pattern.match(line.strip()) |
| 74 |
if m: |
| 75 |
distmeta.update(handler(m)) |
| 76 |
return distmeta |
| 77 |
|
| 78 |
# -*- Requirements -*- |
| 79 |
|
| 80 |
|
| 81 |
def _strip_comments(l): |
| 82 |
return l.split('#', 1)[0].strip() |
| 83 |
|
| 84 |
|
| 85 |
def _pip_requirement(req): |
| 86 |
if req.startswith('-r '): |
| 87 |
_, path = req.split() |
| 88 |
return reqs(*path.split('/')) |
| 89 |
return [req] |
| 90 |
|
| 91 |
|
| 92 |
def _reqs(*f): |
| 93 |
return [ |
| 94 |
_pip_requirement(r) for r in ( |
| 95 |
_strip_comments(l) for l in open( |
| 96 |
os.path.join(os.getcwd(), 'requirements', *f)).readlines() |
| 97 |
) if r] |
| 98 |
|
| 99 |
|
| 100 |
def reqs(*f): |
| 101 |
"""Parse requirement file. |
| 102 |
|
| 103 |
Example: |
| 104 |
reqs('default.txt') # requirements/default.txt |
| 105 |
reqs('extras', 'redis.txt') # requirements/extras/redis.txt |
| 106 |
Returns: |
| 107 |
List[str]: list of requirements specified in the file. |
| 108 |
""" |
| 109 |
return [req for subreq in _reqs(*f) for req in subreq] |
| 110 |
|
| 111 |
|
| 112 |
def extras(*p): |
| 113 |
"""Parse requirement in the requirements/extras/ directory.""" |
| 114 |
return reqs('extras', *p) |
| 115 |
|
| 116 |
|
| 117 |
def install_requires(): |
| 118 |
"""Get list of requirements required for installation.""" |
| 119 |
return reqs('default.txt') |
| 120 |
|
| 121 |
|
| 122 |
def extras_require(): |
| 123 |
"""Get map of all extra requirements.""" |
| 124 |
return {x: extras(x + '.txt') for x in EXTENSIONS} |
| 125 |
|
| 126 |
# -*- Long Description -*- |
| 127 |
|
| 128 |
|
| 129 |
def long_description(): |
| 130 |
try: |
| 131 |
return codecs.open('README.rst', 'r', 'utf-8').read() |
| 132 |
except OSError: |
| 133 |
return 'Long description error: Missing README.rst file' |
| 134 |
|
| 135 |
|
| 136 |
meta = parse_dist_meta() |
| 137 |
setuptools.setup( |
| 138 |
name=NAME, |
| 139 |
packages=setuptools.find_packages(exclude=['t', 't.*']), |
| 140 |
version=meta['version'], |
| 141 |
description=meta['doc'], |
| 142 |
long_description=long_description(), |
| 143 |
keywords=meta['keywords'], |
| 144 |
author=meta['author'], |
| 145 |
author_email=meta['contact'], |
| 146 |
url=meta['homepage'], |
| 147 |
license='BSD-3-Clause', |
| 148 |
platforms=['any'], |
| 149 |
install_requires=install_requires(), |
| 150 |
python_requires=">=3.9", |
| 151 |
tests_require=reqs('test.txt'), |
| 152 |
extras_require=extras_require(), |
| 153 |
include_package_data=True, |
| 154 |
entry_points={ |
| 155 |
'console_scripts': [ |
| 156 |
'celery = celery.__main__:main', |
| 157 |
] |
| 158 |
}, |
| 159 |
project_urls={ |
| 160 |
"Documentation": "https://docs.celeryq.dev/en/stable/", |
| 161 |
"Changelog": "https://docs.celeryq.dev/en/stable/changelog.html", |
| 162 |
"Code": "https://github.com/celery/celery", |
| 163 |
"Tracker": "https://github.com/celery/celery/issues", |
| 164 |
"Funding": "https://opencollective.com/celery" |
| 165 |
}, |
| 166 |
classifiers=[ |
| 167 |
"Development Status :: 5 - Production/Stable", |
| 168 |
"Topic :: System :: Distributed Computing", |
| 169 |
"Topic :: Software Development :: Object Brokering", |
| 170 |
"Framework :: Celery", |
| 171 |
"Programming Language :: Python", |
| 172 |
"Programming Language :: Python :: 3 :: Only", |
| 173 |
"Programming Language :: Python :: 3.9", |
| 174 |
"Programming Language :: Python :: 3.10", |
| 175 |
"Programming Language :: Python :: 3.11", |
| 176 |
"Programming Language :: Python :: 3.12", |
| 177 |
"Programming Language :: Python :: 3.13", |
| 178 |
"Programming Language :: Python :: Implementation :: CPython", |
| 179 |
"Programming Language :: Python :: Implementation :: PyPy", |
| 180 |
"Operating System :: OS Independent" |
| 181 |
] |
| 182 |
) |