|
| 1 | +import glob |
1 | 2 | from setuptools import setup, find_packages # type: ignore
|
2 | 3 | from memoization.memoization import __version__ as memoization_version
|
3 | 4 |
|
4 |
| -with open('README.md', 'r', encoding='utf8') as f: |
5 |
| - long_description = f.read() |
| 5 | + |
| 6 | +def get_long_description(): |
| 7 | + with open('README.md', 'r', encoding='utf8') as f: |
| 8 | + return f.read() |
| 9 | + |
| 10 | + |
| 11 | +def get_package_data(): |
| 12 | + package_data = { |
| 13 | + 'memoization': ['py.typed', '*.pyi'] |
| 14 | + } |
| 15 | + # include all *.pyi stub files |
| 16 | + for filename in glob.iglob('memoization/**/*.pyi', recursive=True): |
| 17 | + parts = filename.split('/') |
| 18 | + package_name = '.'.join(parts[:-1]) |
| 19 | + pyi_name = parts[-1] |
| 20 | + if package_name not in package_data: |
| 21 | + package_data[package_name] = [pyi_name] |
| 22 | + else: |
| 23 | + package_data[package_name].append(pyi_name) |
| 24 | + return package_data |
| 25 | + |
6 | 26 |
|
7 | 27 | setup(
|
8 | 28 | name='memoization',
|
9 | 29 | version=memoization_version,
|
10 | 30 | description='A powerful caching library for Python, with TTL support and multiple algorithm options. '
|
11 | 31 | '(https://github.com/lonelyenvoy/python-memoization)',
|
12 |
| - long_description=long_description, |
| 32 | + long_description=get_long_description(), |
13 | 33 | long_description_content_type='text/markdown',
|
14 |
| - keywords='memoization memorization remember decorator cache caching function callable' |
| 34 | + keywords='memoization memorization remember decorator cache caching function callable ' |
15 | 35 | 'functional ttl limited capacity fast high-performance optimization',
|
16 | 36 | url='https://github.com/lonelyenvoy/python-memoization',
|
17 | 37 | author='lonelyenvoy',
|
18 | 38 | author_email='petrinchor@gmail.com',
|
19 | 39 | license='MIT',
|
20 | 40 | packages=find_packages(),
|
21 |
| - package_data={ |
22 |
| - 'memoization': ['py.typed'], |
23 |
| - }, |
| 41 | + package_data=get_package_data(), |
24 | 42 | exclude_package_data={
|
25 | 43 | '': ['examples.py', 'test.py']
|
26 | 44 | },
|
|
0 commit comments