-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
163 lines (136 loc) · 5.8 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""Setup file for the project."""
# code inspired by https://github.com/navdeep-G/setup.py
import os
import pathlib
import subprocess
from pprint import pprint
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
# Package meta-data.
NAME = "modyn"
DESCRIPTION = "A platform for training on dynamic datasets."
URL = "https://github.com/eth-easl/dynamic_datasets_dsl"
URL_DOKU = "https://github.com/eth-easl/dynamic_datasets_dsl"
URL_GITHUB = "https://github.com/eth-easl/dynamic_datasets_dsl"
URL_ISSUES = "https://github.com/eth-easl/dynamic_datasets_dsl/issues"
EMAIL = "[email protected]"
AUTHOR = "See contributing.md"
REQUIRES_PYTHON = ">=3.9"
KEYWORDS = [""]
# TODO: What packages are required for this module to be executed?
REQUIRED = [""]
# What packages are optional?
# 'fancy feature': ['django'],}
EXTRAS: dict = {}
# The rest you shouldn't have to touch too much :)
# ------------------------------------------------
# Except, perhaps the License and Trove Classifiers!
# If you do change the License, remember to change the Trove Classifier for that!
here = os.path.abspath(os.path.dirname(__file__))
# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
try:
with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = "\n" + f.read()
except FileNotFoundError:
long_description = DESCRIPTION
# Load the package's _version.py module as a dictionary.
about: dict = {}
project_slug = "modyn"
EXTENSION_BUILD_DIR = pathlib.Path(here) / "libbuild"
def _get_env_variable(name: str, default: str = "OFF") -> str:
if name not in os.environ.keys():
return default
return os.environ[name]
class CMakeExtension(Extension):
def __init__(self, name: str, cmake_lists_dir: str = ".", sources: list = [], **kwa: dict) -> None:
Extension.__init__(self, name, sources=sources, **kwa)
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
class CMakeBuild(build_ext):
def copy_extensions_to_source(self) -> None:
pass
def build_extensions(self) -> None:
try:
subprocess.check_output(["cmake", "--version"])
except OSError:
raise RuntimeError("Cannot find CMake executable")
for ext in self.extensions:
cfg = _get_env_variable("MODYN_BUILDTYPE", "Release")
if cfg == "Asan" or cfg == "Tsan":
cfg = "Debug"
print(
"Warning! You set buildtype to Asan or Tsan. "
"This will be respected by the C++ components, "
"but not the C++ extensions of Modyn, since Python "
"breaks with sanitizers enabled. Using Debug instead."
)
print(f"Using build type {cfg} for Modyn.")
cmake_args = [
"-DCMAKE_BUILD_TYPE=%s" % cfg,
"-DMODYN_BUILD_PLAYGROUND=Off",
"-DMODYN_BUILD_TESTS=Off",
"-DMODYN_BUILD_STORAGE=Off",
"-DMODYN_TEST_COVERAGE=Off",
]
pprint(cmake_args)
if not os.path.exists(EXTENSION_BUILD_DIR):
os.makedirs(EXTENSION_BUILD_DIR)
# Config and build the extension
subprocess.check_call(["cmake", ext.cmake_lists_dir] + cmake_args, cwd=EXTENSION_BUILD_DIR)
subprocess.check_call(["cmake", "--build", ".", "--config", cfg], cwd=EXTENSION_BUILD_DIR)
# Where the magic happens:
setup(
name=NAME,
version="1.0.0",
description=DESCRIPTION,
long_description=long_description,
long_description_content_type="text/markdown",
author=AUTHOR,
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
project_urls={"Bug Tracker": URL_ISSUES, "Source Code": URL_GITHUB},
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*", "tests.*.*"]),
# If your package is a single module, use this instead of 'packages':
# py_modules=['mypackage'],
# entry_points is is required for testing the Python scripts
entry_points={
"console_scripts": [
"_modyn_supervisor=modyn.supervisor.entrypoint:main",
"_modyn_storage=modyn.storage.storage_entrypoint:main",
"_modyn_trainer_server=modyn.trainer_server.trainer_server_entrypoint:main",
"_modyn_selector=modyn.selector.selector_entrypoint:main",
"_modyn_metadata_processor=modyn.metadata_processor.metadata_processor_entrypoint:main",
"_modyn_model_storage=modyn.model_storage.model_storage_entrypoint:main",
"_modyn_evaluator=modyn.evaluator.evaluator_entrypoint:main",
"_modyn_client=modynclient.client.client_entrypoint:main",
"_modyn_analytics=analytics.app.app:main",
]
},
scripts=[
"modyn/supervisor/modyn-supervisor",
"modyn/trainer_server/modyn-trainer-server",
"modyn/selector/modyn-selector",
"modyn/metadata_processor/modyn-metadata-processor",
"modyn/model_storage/modyn-model-storage",
"modyn/evaluator/modyn-evaluator",
"modynclient/client/modyn-client",
],
install_requires=REQUIRED,
extras_require=EXTRAS,
include_package_data=True,
license="MIT",
keywords=KEYWORDS,
ext_modules=[
CMakeExtension("example_extension"),
CMakeExtension("trigger_sample_storage"),
CMakeExtension("local_storage_backend"),
],
cmdclass={"build_ext": CMakeBuild},
classifiers=[
# Trove classifiers
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: PyPy",
],
)