|
1 | 1 | """Extensions to the 'distutils' for large or complex distributions"""
|
2 | 2 |
|
| 3 | +from abc import ABC, abstractmethod |
3 | 4 | import functools
|
4 | 5 | import os
|
5 | 6 | import re
|
@@ -117,7 +118,7 @@ def setup(**attrs):
|
117 | 118 | _Command = monkey.get_unpatched(distutils.core.Command)
|
118 | 119 |
|
119 | 120 |
|
120 |
| -class Command(_Command): |
| 121 | +class Command(_Command, ABC): |
121 | 122 | """
|
122 | 123 | Setuptools internal actions are organized using a *command design pattern*.
|
123 | 124 | This means that each action (or group of closely related actions) executed during
|
@@ -226,6 +227,33 @@ def reinitialize_command(self, command, reinit_subcommands=False, **kw):
|
226 | 227 | vars(cmd).update(kw)
|
227 | 228 | return cmd
|
228 | 229 |
|
| 230 | + @abstractmethod |
| 231 | + def initialize_options(self) -> None: |
| 232 | + """ |
| 233 | + Set or (reset) all options/attributes/caches used by the command |
| 234 | + to their default values. Note that these values may be overwritten during |
| 235 | + the build. |
| 236 | + """ |
| 237 | + raise NotImplementedError |
| 238 | + |
| 239 | + @abstractmethod |
| 240 | + def finalize_options(self) -> None: |
| 241 | + """ |
| 242 | + Set final values for all options/attributes used by the command. |
| 243 | + Most of the time, each option/attribute/cache should only be set if it does not |
| 244 | + have any value yet (e.g. ``if self.attr is None: self.attr = val``). |
| 245 | + """ |
| 246 | + raise NotImplementedError |
| 247 | + |
| 248 | + @abstractmethod |
| 249 | + def run(self) -> None: |
| 250 | + """ |
| 251 | + Execute the actions intended by the command. |
| 252 | + (Side effects **SHOULD** only take place when ``run`` is executed, |
| 253 | + for example, creating new files or writing to the terminal output). |
| 254 | + """ |
| 255 | + raise NotImplementedError |
| 256 | + |
229 | 257 |
|
230 | 258 | def _find_all_simple(path):
|
231 | 259 | """
|
|
0 commit comments