Skip to content

Commit 2831906

Browse files
Renamed AbstractComponent as ComponentBase.
1 parent a7cf58d commit 2831906

16 files changed

+68
-47
lines changed

doc/sysroot.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,25 @@ The full set of command line options is:
123123
Writing A Component Plugin
124124
--------------------------
125125

126-
TODO - describe the API
126+
A component plugin is a Python module that defines a sub-class of
127+
:py:class:`pyqtdeploy.ComponentBase`. The sub-class must re-implement the
128+
:py:meth:`~pyqtdeploy.ComponentBase.build` method and may also
129+
re-implement the :py:meth:`~pyqtdeploy.ComponentBase.configure` method. It
130+
should also include a class attribute called
131+
:py:attr:`~pyqtdeploy.ComponentBase.options` which is a sequence of
132+
:py:class:`pyqtdeploy.ComponentOption` instances that describe each of the
133+
component's configurable options.
134+
135+
.. py:module:: pyqtdeploy
136+
137+
.. py:class:: ComponentBase
138+
139+
.. py:attribute:: options
140+
141+
.. py:method:: build(sysroot)
142+
143+
.. py:method:: configure(sysroot)
144+
145+
.. py:class:: ComponentOption(name, type, required=False, default=None, values=None, help=None)
146+
147+
.. py:class:: Sysroot

pyqtdeploy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
from .version import PYQTDEPLOY_RELEASE
3434

3535

36-
# These are for the component plugins.
37-
from .sysroot import AbstractComponent, ComponentOption
36+
# These are for component plugins.
37+
from .sysroot import ComponentBase, ComponentOption

pyqtdeploy/sysroot/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
# POSSIBILITY OF SUCH DAMAGE.
2525

2626

27-
# Publish the component API.
28-
from .abstract_component import AbstractComponent, ComponentOption
27+
# Publish the sub-package's API.
28+
from .component import ComponentBase, ComponentOption
2929
from .sysroot import Sysroot

pyqtdeploy/sysroot/abstract_component.py renamed to pyqtdeploy/sysroot/component.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@
2727
from abc import ABC, abstractmethod
2828

2929

30+
class ComponentBase(ABC):
31+
""" The base class for the implementation of a component plugin. """
32+
33+
# A sequence of ComponentOption instances describing the options that can
34+
# be specified for the component in the specification file. These are made
35+
# available as attributes of the plugin instance.
36+
options = []
37+
38+
@abstractmethod
39+
def build(self, sysroot):
40+
""" Build the component. """
41+
42+
def configure(self, sysroot):
43+
""" Complete the configuration of the component. """
44+
45+
3046
class ComponentOption:
3147
""" Encapsulate an option for the component in the specification file. """
3248

@@ -57,19 +73,3 @@ def _format_value(self, value):
5773
value = "'" + value + "'"
5874

5975
return value
60-
61-
62-
class AbstractComponent(ABC):
63-
""" The base class for the implementation of a component plugin. """
64-
65-
# A sequence of ComponentOption instances describing the options that can
66-
# be specified for the component in the specification file. These are made
67-
# available as attributes of the plugin instance.
68-
options = []
69-
70-
@abstractmethod
71-
def build(self, sysroot, debug):
72-
""" Build the component. """
73-
74-
def configure(self, sysroot):
75-
""" Complete the configuration of the component. """

pyqtdeploy/sysroot/plugins/openssl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import os
2929
import sys
3030

31-
from ... import AbstractComponent, ComponentOption
31+
from ... import ComponentBase, ComponentOption
3232

3333

34-
class OpenSSLComponent(AbstractComponent):
34+
class OpenSSLComponent(ComponentBase):
3535
""" The OpenSSL component. """
3636

3737
# The component options.

pyqtdeploy/sysroot/plugins/pip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
# POSSIBILITY OF SUCH DAMAGE.
2525

2626

27-
from ... import AbstractComponent, ComponentOption
27+
from ... import ComponentBase, ComponentOption
2828

2929

30-
class pipComponent(AbstractComponent):
30+
class pipComponent(ComponentBase):
3131
""" The pip meta-component. """
3232

3333
# The component options.

pyqtdeploy/sysroot/plugins/pyqt3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class PyQt3DComponent(AbstractComponent):
32+
class PyQt3DComponent(ComponentBase):
3333
""" The PyQt3D component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/pyqt5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class PyQt5Component(AbstractComponent):
32+
class PyQt5Component(ComponentBase):
3333
""" The PyQt5 component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/pyqtchart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class PyQtChartComponent(AbstractComponent):
32+
class PyQtChartComponent(ComponentBase):
3333
""" The PyQtChart component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/pyqtdatavisualization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class PyQtDataVisualizationComponent(AbstractComponent):
32+
class PyQtDataVisualizationComponent(ComponentBase):
3333
""" The PyQtDataVisualization component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/pyqtpurchasing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class PyQtPurchasingComponent(AbstractComponent):
32+
class PyQtPurchasingComponent(ComponentBase):
3333
""" The PyQtPurchasing component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/python/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
import shutil
2929
import sys
3030

31-
from .... import AbstractComponent, ComponentOption
31+
from .... import ComponentBase, ComponentOption
3232

3333
from .configure_python import configure_python
3434

3535

36-
class PythonComponent(AbstractComponent):
36+
class PythonComponent(ComponentBase):
3737
""" The host and target Python component. """
3838

3939
# The component options.

pyqtdeploy/sysroot/plugins/qscintilla.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class QScintillaComponent(AbstractComponent):
32+
class QScintillaComponent(ComponentBase):
3333
""" The QScintilla component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/plugins/qt5.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
import os
2828
import sys
2929

30-
from ... import AbstractComponent, ComponentOption
30+
from ... import ComponentBase, ComponentOption
3131

3232

33-
class Qt5Component(AbstractComponent):
33+
class Qt5Component(ComponentBase):
3434
""" The Qt5 component. """
3535

3636
# The component options.

pyqtdeploy/sysroot/plugins/sip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
import os
2828

29-
from ... import AbstractComponent, ComponentOption
29+
from ... import ComponentBase, ComponentOption
3030

3131

32-
class SIPComponent(AbstractComponent):
32+
class SIPComponent(ComponentBase):
3333
""" The SIP component. """
3434

3535
# The component options.

pyqtdeploy/sysroot/specification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from collections import OrderedDict
3333

3434
from ..user_exception import UserException
35-
from .abstract_component import AbstractComponent
35+
from .component import ComponentBase
3636

3737

3838
class Specification:
@@ -114,7 +114,7 @@ def __init__(self, spec_file, plugin_dirs, target):
114114
self._parse_options(config, options, component,
115115
spec_file)
116116

117-
if cls is AbstractComponent:
117+
if cls is ComponentBase:
118118
break
119119

120120
unused = config.keys()
@@ -198,7 +198,7 @@ def _plugin_from_module(self, fq_name, plugin_module):
198198

199199
for component_type in plugin_module.__dict__.values():
200200
if isinstance(component_type, type):
201-
if issubclass(component_type, AbstractComponent):
201+
if issubclass(component_type, ComponentBase):
202202
# Make sure the type is defined in the plugin and not
203203
# imported by it. Allow for a plugin implemented as a
204204
# sub-package.
@@ -287,7 +287,7 @@ def show_options(self, components, message_handler):
287287
if widths[1] < name_len:
288288
widths[1] = name_len
289289

290-
if cls is AbstractComponent:
290+
if cls is ComponentBase:
291291
break
292292

293293
options[component.name] = component_options

0 commit comments

Comments
 (0)