|
| 1 | +import os |
1 | 2 | import setuptools
|
2 | 3 |
|
3 | 4 | with open("README.md", "r") as readme_file:
|
4 | 5 | long_description = readme_file.read()
|
5 | 6 | with open("bitbot/VERSION", "r") as version_file:
|
6 | 7 | version = version_file.read().strip()
|
7 | 8 |
|
| 9 | +def list_modules(dirname): |
| 10 | + for (module_name, ext) in map(os.path.splitext, os.listdir(dirname)): |
| 11 | + if ext in ('', '.py') and not module_name.startswith('_'): |
| 12 | + yield module_name |
| 13 | + |
| 14 | +package_dir = { |
| 15 | + # Install bitbot's modules as a separate 'bitbot_modules' package |
| 16 | + 'bitbot_modules': 'modules', |
| 17 | +} |
| 18 | + |
| 19 | +for module_package in setuptools.find_packages('modules'): |
| 20 | + package_dir[f'bitbot_modules.{module_package}'] = \ |
| 21 | + f'modules/{module_package}' |
| 22 | + |
| 23 | +packages = setuptools.find_packages(exclude=['modules', 'modules.*']) |
| 24 | + |
| 25 | +for package in package_dir: |
| 26 | + packages.append(package) |
| 27 | + |
| 28 | +entry_points = { |
| 29 | + 'bitbot.core_modules': [ |
| 30 | + f'{module_name} = bitbot.core_modules.{module_name}:Module' |
| 31 | + for module_name in list_modules('bitbot/core_modules') |
| 32 | + ], |
| 33 | + 'bitbot.extra_modules': [ |
| 34 | + f'{module_name} = bitbot_modules.{module_name}:Module' |
| 35 | + for module_name in list_modules('modules') |
| 36 | + ], |
| 37 | +} |
| 38 | + |
8 | 39 | setuptools.setup(
|
9 | 40 | name="bitbot",
|
10 | 41 | version=version,
|
|
15 | 46 | long_description=long_description,
|
16 | 47 | long_description_content_type="text/markdown",
|
17 | 48 | url="https://github.com/jesopo/bitbot",
|
18 |
| - packages=setuptools.find_packages(), |
| 49 | + |
| 50 | + packages=packages, |
| 51 | + include_package_data=True, |
| 52 | + package_dir=package_dir, |
| 53 | + package_data={ |
| 54 | + '': ['VERSION'], |
| 55 | + }, |
| 56 | + |
| 57 | + entry_points=entry_points, |
| 58 | + |
| 59 | + # We need to read hashflags of modules; and currently this is done by |
| 60 | + # opening the modules' files. So it doesn't work in a zip, because |
| 61 | + # module files are then not available. |
| 62 | + zip_safe=False, |
| 63 | + |
19 | 64 | classifiers=[
|
20 | 65 | "Environment :: Console",
|
21 | 66 | "Environment :: No Input/Output (Daemon)",
|
|
0 commit comments