Skip to content

Commit f5296fc

Browse files
committed
Make setup.py install and register modules, as well as VERSION.
1 parent 59df551 commit f5296fc

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

bitbot/core_modules/__init__.py

Whitespace-only changes.

bitbotd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ from bitbot import (
1515

1616
faulthandler.enable()
1717

18-
directory = os.path.dirname(os.path.realpath(__file__))
18+
directory = os.getcwd()
1919
home = os.path.expanduser("~")
2020
default_data = os.path.join(home, ".bitbot")
2121

modules/__init__.py

Whitespace-only changes.

setup.py

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
1+
import os
12
import setuptools
23

34
with open("README.md", "r") as readme_file:
45
long_description = readme_file.read()
56
with open("bitbot/VERSION", "r") as version_file:
67
version = version_file.read().strip()
78

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+
839
setuptools.setup(
940
name="bitbot",
1041
version=version,
@@ -15,7 +46,21 @@
1546
long_description=long_description,
1647
long_description_content_type="text/markdown",
1748
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+
1964
classifiers=[
2065
"Environment :: Console",
2166
"Environment :: No Input/Output (Daemon)",

0 commit comments

Comments
 (0)