BDPotentiometer 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {bdpotentiometer-0.3.0/src/BDPotentiometer.egg-info → bdpotentiometer-0.4.0}/PKG-INFO +59 -19
  2. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/README.md +53 -13
  3. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/pyproject.toml +5 -5
  4. bdpotentiometer-0.4.0/src/BDPotentiometer/__init__.py +15 -0
  5. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/digital_wiper.py +2 -1
  6. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/mcp4xxx/mcp4xx1.py +2 -1
  7. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/mcp4xxx/mcp4xx2.py +2 -1
  8. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/mcp4xxx/mcp4xxx.py +7 -2
  9. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0/src/BDPotentiometer.egg-info}/PKG-INFO +59 -19
  10. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer.egg-info/SOURCES.txt +0 -8
  11. bdpotentiometer-0.4.0/src/BDPotentiometer.egg-info/requires.txt +25 -0
  12. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/tests/test_backward_compatibility.py +27 -65
  13. bdpotentiometer-0.4.0/tests/test_optional_backends.py +62 -0
  14. bdpotentiometer-0.3.0/src/BDPotentiometer/__gpiozero_helpers.py +0 -160
  15. bdpotentiometer-0.3.0/src/BDPotentiometer/__init__.py +0 -62
  16. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/__init__.py +0 -58
  17. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/base.py +0 -72
  18. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/fake.py +0 -96
  19. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/gpiozero_spi.py +0 -122
  20. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/selection.py +0 -82
  21. bdpotentiometer-0.3.0/src/BDPotentiometer/transport/spidev_spi.py +0 -114
  22. bdpotentiometer-0.3.0/src/BDPotentiometer.egg-info/requires.txt +0 -25
  23. bdpotentiometer-0.3.0/tests/test_gpiozero_helpers.py +0 -174
  24. bdpotentiometer-0.3.0/tests/test_optional_backends.py +0 -145
  25. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/LICENSE +0 -0
  26. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/setup.cfg +0 -0
  27. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/__helpers.py +0 -0
  28. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/__logger.py +0 -0
  29. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/digital_potentiometer.py +0 -0
  30. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/mcp4xxx/__init__.py +0 -0
  31. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/potentiometer.py +0 -0
  32. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer/py.typed +0 -0
  33. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer.egg-info/dependency_links.txt +0 -0
  34. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/src/BDPotentiometer.egg-info/top_level.txt +0 -0
  35. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/tests/test_logger.py +0 -0
  36. {bdpotentiometer-0.3.0 → bdpotentiometer-0.4.0}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BDPotentiometer
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: BD Digital Potentiometer
5
5
  Author-email: Anton Bondarenko <bond.anton@gmail.com>
6
6
  License: MIT License
@@ -36,18 +36,18 @@ Classifier: Operating System :: OS Independent
36
36
  Requires-Python: >=3.10
37
37
  Description-Content-Type: text/markdown
38
38
  License-File: LICENSE
39
+ Requires-Dist: scietex.hal.spi<1.0.0,>=0.1.0
39
40
  Provides-Extra: gpiozero
40
- Requires-Dist: gpiozero>=1.6.2; extra == "gpiozero"
41
+ Requires-Dist: scietex.hal.spi[gpiozero]; extra == "gpiozero"
41
42
  Provides-Extra: spi
42
- Requires-Dist: spidev>=3.6; extra == "spi"
43
+ Requires-Dist: scietex.hal.spi[spi]; extra == "spi"
43
44
  Provides-Extra: dev
44
- Requires-Dist: gpiozero>=1.6.2; extra == "dev"
45
- Requires-Dist: spidev>=3.6; extra == "dev"
45
+ Requires-Dist: scietex.hal.spi[gpiozero,spi]; extra == "dev"
46
46
  Requires-Dist: numpy; extra == "dev"
47
47
  Provides-Extra: docs
48
48
  Requires-Dist: sphinx; extra == "docs"
49
49
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
50
- Requires-Dist: gpiozero>=1.6.2; extra == "docs"
50
+ Requires-Dist: scietex.hal.spi[gpiozero]; extra == "docs"
51
51
  Requires-Dist: numpy; extra == "docs"
52
52
  Provides-Extra: test
53
53
  Requires-Dist: pytest; extra == "test"
@@ -75,14 +75,15 @@ The bare package installs the core library only: the model classes and
75
75
  $ pip install BDPotentiometer
76
76
  ```
77
77
 
78
- The default hardware backend is spidev; the `spi` extra installs it:
78
+ The default hardware backend is spidev; the transport package's `spi` extra
79
+ installs it:
79
80
  ```shell
80
- $ pip install 'BDPotentiometer[spi]'
81
+ $ pip install 'scietex.hal.spi[spi]'
81
82
  ```
82
83
 
83
84
  The optional gpiozero backend needs its own extra:
84
85
  ```shell
85
- $ pip install 'BDPotentiometer[gpiozero]'
86
+ $ pip install 'scietex.hal.spi[gpiozero]'
86
87
  ```
87
88
 
88
89
  ## Usage
@@ -111,20 +112,22 @@ or `spi=`; doing so raises `TypeError`.
111
112
 
112
113
  ## Transports
113
114
 
114
- SPI access goes through a transport object passed with `transport=`:
115
+ The transport layer lives in the `scietex.hal.spi` distribution
116
+ (https://github.com/bond-anton/scietex.hal.spi). SPI access goes through a
117
+ transport object passed with `transport=`:
115
118
 
116
119
  * `SpiDevTransport` (default) opens `/dev/spidev<bus>.<device>` through
117
- `spidev`; needs the `spi` extra. `port=` maps to the bus, `device=` to the
118
- chip-select line.
120
+ `spidev`; needs `scietex.hal.spi[spi]`. `port=` maps to the bus, `device=` to
121
+ the chip-select line.
119
122
  * `GpiozeroSpiTransport` (optional) wraps gpiozero hardware SPI; passing
120
123
  `clock_pin=`, `mosi_pin=`, `miso_pin=`, or `select_pin=` builds one, and it
121
- needs the `gpiozero` extra.
124
+ needs `scietex.hal.spi[gpiozero]`.
122
125
  * `FakeSpiTransport` replays scripted responses, so code can run without
123
126
  hardware or extras.
124
127
 
125
128
  ```python
126
129
  from BDPotentiometer.mcp4xxx import MCP4231
127
- from BDPotentiometer.transport import SpiDevTransport
130
+ from scietex.hal.spi import SpiDevTransport
128
131
 
129
132
 
130
133
  my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
@@ -133,7 +136,8 @@ my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
133
136
  For tests, the fake backend needs no extra:
134
137
 
135
138
  ```python
136
- from BDPotentiometer.transport import FakeSpiTransport
139
+ from BDPotentiometer.mcp4xxx import MCP4231
140
+ from scietex.hal.spi import FakeSpiTransport
137
141
 
138
142
 
139
143
  my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
@@ -144,10 +148,46 @@ my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
144
148
  `spidev.SpiDev` or a gpiozero SPI object), and `.close()` / `.closed` release
145
149
  and report the underlying transport.
146
150
 
147
- `from BDPotentiometer import *` follows `__all__`, which includes
148
- `GpiozeroSpiTransport`. That name is resolved lazily, so a star import without
149
- the `gpiozero` extra raises `AttributeError`; import the names you need
150
- explicitly when the optional backend may be absent.
151
+ Transports are owned by whoever constructs them: a device closes only a
152
+ transport it built itself from backend keywords, and leaves a transport passed
153
+ with `transport=` or `spi=` open.
154
+
155
+ `from BDPotentiometer import *` follows `__all__`, which lists only the model
156
+ classes: `DigitalPotentiometerDevice`, `DigitalWiper`, `Potentiometer`, and
157
+ `SpiDigitalWiper`. Import transports and transport exceptions from
158
+ `scietex.hal.spi`.
159
+
160
+ ## Upgrading to 0.4.0
161
+
162
+ 0.4.0 moves the transport layer out of this package into the published
163
+ `scietex.hal.spi` 0.1.0 distribution.
164
+
165
+ Breaking changes:
166
+
167
+ * `BDPotentiometer.transport` is gone; `scietex.hal.spi` replaces it.
168
+ * These names are no longer importable from `BDPotentiometer`: `SpiTransport`,
169
+ `SpiDevTransport`, `FakeSpiTransport`, `I2cTransport`, `TransportError`,
170
+ `TransportClosed`, `is_spi_transport`, `fix_gpiozero_dual_cs_spi`, and
171
+ `GpiozeroSpiTransport`.
172
+ * `__all__` now lists only `DigitalPotentiometerDevice`, `DigitalWiper`,
173
+ `Potentiometer`, and `SpiDigitalWiper`.
174
+ * The `ImportError` for a missing backend now names `scietex.hal.spi[spi]` or
175
+ `scietex.hal.spi[gpiozero]` instead of the `BDPotentiometer` extras.
176
+
177
+ Migration:
178
+
179
+ ```python
180
+ # before
181
+ from BDPotentiometer.transport import SpiDevTransport
182
+
183
+ # after
184
+ from scietex.hal.spi import SpiDevTransport
185
+ ```
186
+
187
+ Install the matching transport extra, for example
188
+ `pip install 'scietex.hal.spi[spi]'`. Device constructors, the
189
+ `transport=`/`spi=`/pin keywords, `.close()`, `.closed`, `.transport`, and
190
+ `.spi` are unchanged.
151
191
 
152
192
  Please see the [examples](examples) directory for more usage examples.
153
193
 
@@ -16,14 +16,15 @@ The bare package installs the core library only: the model classes and
16
16
  $ pip install BDPotentiometer
17
17
  ```
18
18
 
19
- The default hardware backend is spidev; the `spi` extra installs it:
19
+ The default hardware backend is spidev; the transport package's `spi` extra
20
+ installs it:
20
21
  ```shell
21
- $ pip install 'BDPotentiometer[spi]'
22
+ $ pip install 'scietex.hal.spi[spi]'
22
23
  ```
23
24
 
24
25
  The optional gpiozero backend needs its own extra:
25
26
  ```shell
26
- $ pip install 'BDPotentiometer[gpiozero]'
27
+ $ pip install 'scietex.hal.spi[gpiozero]'
27
28
  ```
28
29
 
29
30
  ## Usage
@@ -52,20 +53,22 @@ or `spi=`; doing so raises `TypeError`.
52
53
 
53
54
  ## Transports
54
55
 
55
- SPI access goes through a transport object passed with `transport=`:
56
+ The transport layer lives in the `scietex.hal.spi` distribution
57
+ (https://github.com/bond-anton/scietex.hal.spi). SPI access goes through a
58
+ transport object passed with `transport=`:
56
59
 
57
60
  * `SpiDevTransport` (default) opens `/dev/spidev<bus>.<device>` through
58
- `spidev`; needs the `spi` extra. `port=` maps to the bus, `device=` to the
59
- chip-select line.
61
+ `spidev`; needs `scietex.hal.spi[spi]`. `port=` maps to the bus, `device=` to
62
+ the chip-select line.
60
63
  * `GpiozeroSpiTransport` (optional) wraps gpiozero hardware SPI; passing
61
64
  `clock_pin=`, `mosi_pin=`, `miso_pin=`, or `select_pin=` builds one, and it
62
- needs the `gpiozero` extra.
65
+ needs `scietex.hal.spi[gpiozero]`.
63
66
  * `FakeSpiTransport` replays scripted responses, so code can run without
64
67
  hardware or extras.
65
68
 
66
69
  ```python
67
70
  from BDPotentiometer.mcp4xxx import MCP4231
68
- from BDPotentiometer.transport import SpiDevTransport
71
+ from scietex.hal.spi import SpiDevTransport
69
72
 
70
73
 
71
74
  my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
@@ -74,7 +77,8 @@ my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
74
77
  For tests, the fake backend needs no extra:
75
78
 
76
79
  ```python
77
- from BDPotentiometer.transport import FakeSpiTransport
80
+ from BDPotentiometer.mcp4xxx import MCP4231
81
+ from scietex.hal.spi import FakeSpiTransport
78
82
 
79
83
 
80
84
  my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
@@ -85,10 +89,46 @@ my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
85
89
  `spidev.SpiDev` or a gpiozero SPI object), and `.close()` / `.closed` release
86
90
  and report the underlying transport.
87
91
 
88
- `from BDPotentiometer import *` follows `__all__`, which includes
89
- `GpiozeroSpiTransport`. That name is resolved lazily, so a star import without
90
- the `gpiozero` extra raises `AttributeError`; import the names you need
91
- explicitly when the optional backend may be absent.
92
+ Transports are owned by whoever constructs them: a device closes only a
93
+ transport it built itself from backend keywords, and leaves a transport passed
94
+ with `transport=` or `spi=` open.
95
+
96
+ `from BDPotentiometer import *` follows `__all__`, which lists only the model
97
+ classes: `DigitalPotentiometerDevice`, `DigitalWiper`, `Potentiometer`, and
98
+ `SpiDigitalWiper`. Import transports and transport exceptions from
99
+ `scietex.hal.spi`.
100
+
101
+ ## Upgrading to 0.4.0
102
+
103
+ 0.4.0 moves the transport layer out of this package into the published
104
+ `scietex.hal.spi` 0.1.0 distribution.
105
+
106
+ Breaking changes:
107
+
108
+ * `BDPotentiometer.transport` is gone; `scietex.hal.spi` replaces it.
109
+ * These names are no longer importable from `BDPotentiometer`: `SpiTransport`,
110
+ `SpiDevTransport`, `FakeSpiTransport`, `I2cTransport`, `TransportError`,
111
+ `TransportClosed`, `is_spi_transport`, `fix_gpiozero_dual_cs_spi`, and
112
+ `GpiozeroSpiTransport`.
113
+ * `__all__` now lists only `DigitalPotentiometerDevice`, `DigitalWiper`,
114
+ `Potentiometer`, and `SpiDigitalWiper`.
115
+ * The `ImportError` for a missing backend now names `scietex.hal.spi[spi]` or
116
+ `scietex.hal.spi[gpiozero]` instead of the `BDPotentiometer` extras.
117
+
118
+ Migration:
119
+
120
+ ```python
121
+ # before
122
+ from BDPotentiometer.transport import SpiDevTransport
123
+
124
+ # after
125
+ from scietex.hal.spi import SpiDevTransport
126
+ ```
127
+
128
+ Install the matching transport extra, for example
129
+ `pip install 'scietex.hal.spi[spi]'`. Device constructors, the
130
+ `transport=`/`spi=`/pin keywords, `.close()`, `.closed`, `.transport`, and
131
+ `.spi` are unchanged.
92
132
 
93
133
  Please see the [examples](examples) directory for more usage examples.
94
134
 
@@ -20,7 +20,7 @@ classifiers = [
20
20
  "Operating System :: OS Independent",
21
21
  ]
22
22
  requires-python = ">=3.10"
23
- dependencies = []
23
+ dependencies = ["scietex.hal.spi >= 0.1.0, < 1.0.0"]
24
24
 
25
25
  [project.urls]
26
26
  "Homepage" = "https://github.com/bond-anton/BDPotentiometer"
@@ -28,10 +28,10 @@ dependencies = []
28
28
  "Documentation" = "https://bdpotentiometer.readthedocs.io"
29
29
 
30
30
  [project.optional-dependencies]
31
- gpiozero = ["gpiozero>=1.6.2"]
32
- spi = ["spidev>=3.6"]
33
- dev = ["gpiozero>=1.6.2", "spidev>=3.6", "numpy"]
34
- docs = ["sphinx", "sphinx_rtd_theme", "gpiozero>=1.6.2", "numpy"]
31
+ gpiozero = ["scietex.hal.spi[gpiozero]"]
32
+ spi = ["scietex.hal.spi[spi]"]
33
+ dev = ["scietex.hal.spi[spi,gpiozero]", "numpy"]
34
+ docs = ["sphinx", "sphinx_rtd_theme", "scietex.hal.spi[gpiozero]", "numpy"]
35
35
  test = ["pytest", "numpy"]
36
36
  lint = ["ruff==0.17.4", "ty==0.0.99"]
37
37
 
@@ -0,0 +1,15 @@
1
+ """Digital potentiometer and wiper models with pluggable bus transports."""
2
+
3
+ __version__ = "0.4.0"
4
+
5
+
6
+ from .digital_potentiometer import DigitalPotentiometerDevice
7
+ from .digital_wiper import DigitalWiper, SpiDigitalWiper
8
+ from .potentiometer import Potentiometer
9
+
10
+ __all__ = [
11
+ "DigitalPotentiometerDevice",
12
+ "DigitalWiper",
13
+ "Potentiometer",
14
+ "SpiDigitalWiper",
15
+ ]
@@ -3,6 +3,8 @@
3
3
  from copy import deepcopy
4
4
  from typing import cast
5
5
 
6
+ from scietex.hal.spi import SpiTransport, is_spi_transport
7
+
6
8
  from .__helpers import (
7
9
  check_bool,
8
10
  check_integer,
@@ -12,7 +14,6 @@ from .__helpers import (
12
14
  )
13
15
  from .__logger import get_logger
14
16
  from .potentiometer import Potentiometer
15
- from .transport.base import SpiTransport, is_spi_transport
16
17
 
17
18
 
18
19
  class DigitalWiper:
@@ -2,9 +2,10 @@
2
2
 
3
3
  from typing import Any
4
4
 
5
+ from scietex.hal.spi import SpiTransport
6
+
5
7
  from .. import DigitalPotentiometerDevice
6
8
  from ..__helpers import check_integer
7
- from ..transport.base import SpiTransport
8
9
  from .mcp4xxx import MCP4xxx, MCP4xxxPotentiometer, MCP4xxxWiper
9
10
 
10
11
 
@@ -2,9 +2,10 @@
2
2
 
3
3
  from typing import Any
4
4
 
5
+ from scietex.hal.spi import SpiTransport
6
+
5
7
  from .. import DigitalPotentiometerDevice
6
8
  from ..__helpers import check_integer
7
- from ..transport.base import SpiTransport
8
9
  from .mcp4xxx import MCP4xxx, MCP4xxxPotentiometer, MCP4xxxWiper
9
10
 
10
11
 
@@ -3,10 +3,15 @@
3
3
  from contextlib import suppress
4
4
  from typing import Any
5
5
 
6
+ from scietex.hal.spi import (
7
+ GPIOZERO_SPI_ARGS,
8
+ SpiTransport,
9
+ build_default_transport,
10
+ is_spi_transport,
11
+ )
12
+
6
13
  from .. import Potentiometer, SpiDigitalWiper
7
14
  from ..__helpers import check_bool, check_integer, clamp
8
- from ..transport.base import SpiTransport, is_spi_transport
9
- from ..transport.selection import GPIOZERO_SPI_ARGS, build_default_transport
10
15
 
11
16
  #: Supported `r_ab` values in ohms for MCP4XXX devices.
12
17
  resistance_list: tuple[float, ...] = (5e3, 10e3, 50e3, 100e3)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: BDPotentiometer
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: BD Digital Potentiometer
5
5
  Author-email: Anton Bondarenko <bond.anton@gmail.com>
6
6
  License: MIT License
@@ -36,18 +36,18 @@ Classifier: Operating System :: OS Independent
36
36
  Requires-Python: >=3.10
37
37
  Description-Content-Type: text/markdown
38
38
  License-File: LICENSE
39
+ Requires-Dist: scietex.hal.spi<1.0.0,>=0.1.0
39
40
  Provides-Extra: gpiozero
40
- Requires-Dist: gpiozero>=1.6.2; extra == "gpiozero"
41
+ Requires-Dist: scietex.hal.spi[gpiozero]; extra == "gpiozero"
41
42
  Provides-Extra: spi
42
- Requires-Dist: spidev>=3.6; extra == "spi"
43
+ Requires-Dist: scietex.hal.spi[spi]; extra == "spi"
43
44
  Provides-Extra: dev
44
- Requires-Dist: gpiozero>=1.6.2; extra == "dev"
45
- Requires-Dist: spidev>=3.6; extra == "dev"
45
+ Requires-Dist: scietex.hal.spi[gpiozero,spi]; extra == "dev"
46
46
  Requires-Dist: numpy; extra == "dev"
47
47
  Provides-Extra: docs
48
48
  Requires-Dist: sphinx; extra == "docs"
49
49
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
50
- Requires-Dist: gpiozero>=1.6.2; extra == "docs"
50
+ Requires-Dist: scietex.hal.spi[gpiozero]; extra == "docs"
51
51
  Requires-Dist: numpy; extra == "docs"
52
52
  Provides-Extra: test
53
53
  Requires-Dist: pytest; extra == "test"
@@ -75,14 +75,15 @@ The bare package installs the core library only: the model classes and
75
75
  $ pip install BDPotentiometer
76
76
  ```
77
77
 
78
- The default hardware backend is spidev; the `spi` extra installs it:
78
+ The default hardware backend is spidev; the transport package's `spi` extra
79
+ installs it:
79
80
  ```shell
80
- $ pip install 'BDPotentiometer[spi]'
81
+ $ pip install 'scietex.hal.spi[spi]'
81
82
  ```
82
83
 
83
84
  The optional gpiozero backend needs its own extra:
84
85
  ```shell
85
- $ pip install 'BDPotentiometer[gpiozero]'
86
+ $ pip install 'scietex.hal.spi[gpiozero]'
86
87
  ```
87
88
 
88
89
  ## Usage
@@ -111,20 +112,22 @@ or `spi=`; doing so raises `TypeError`.
111
112
 
112
113
  ## Transports
113
114
 
114
- SPI access goes through a transport object passed with `transport=`:
115
+ The transport layer lives in the `scietex.hal.spi` distribution
116
+ (https://github.com/bond-anton/scietex.hal.spi). SPI access goes through a
117
+ transport object passed with `transport=`:
115
118
 
116
119
  * `SpiDevTransport` (default) opens `/dev/spidev<bus>.<device>` through
117
- `spidev`; needs the `spi` extra. `port=` maps to the bus, `device=` to the
118
- chip-select line.
120
+ `spidev`; needs `scietex.hal.spi[spi]`. `port=` maps to the bus, `device=` to
121
+ the chip-select line.
119
122
  * `GpiozeroSpiTransport` (optional) wraps gpiozero hardware SPI; passing
120
123
  `clock_pin=`, `mosi_pin=`, `miso_pin=`, or `select_pin=` builds one, and it
121
- needs the `gpiozero` extra.
124
+ needs `scietex.hal.spi[gpiozero]`.
122
125
  * `FakeSpiTransport` replays scripted responses, so code can run without
123
126
  hardware or extras.
124
127
 
125
128
  ```python
126
129
  from BDPotentiometer.mcp4xxx import MCP4231
127
- from BDPotentiometer.transport import SpiDevTransport
130
+ from scietex.hal.spi import SpiDevTransport
128
131
 
129
132
 
130
133
  my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
@@ -133,7 +136,8 @@ my_pot = MCP4231(r_ab=10e3, transport=SpiDevTransport(bus=0, device=0))
133
136
  For tests, the fake backend needs no extra:
134
137
 
135
138
  ```python
136
- from BDPotentiometer.transport import FakeSpiTransport
139
+ from BDPotentiometer.mcp4xxx import MCP4231
140
+ from scietex.hal.spi import FakeSpiTransport
137
141
 
138
142
 
139
143
  my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
@@ -144,10 +148,46 @@ my_pot = MCP4231(r_ab=10e3, transport=FakeSpiTransport(default=[0, 0]))
144
148
  `spidev.SpiDev` or a gpiozero SPI object), and `.close()` / `.closed` release
145
149
  and report the underlying transport.
146
150
 
147
- `from BDPotentiometer import *` follows `__all__`, which includes
148
- `GpiozeroSpiTransport`. That name is resolved lazily, so a star import without
149
- the `gpiozero` extra raises `AttributeError`; import the names you need
150
- explicitly when the optional backend may be absent.
151
+ Transports are owned by whoever constructs them: a device closes only a
152
+ transport it built itself from backend keywords, and leaves a transport passed
153
+ with `transport=` or `spi=` open.
154
+
155
+ `from BDPotentiometer import *` follows `__all__`, which lists only the model
156
+ classes: `DigitalPotentiometerDevice`, `DigitalWiper`, `Potentiometer`, and
157
+ `SpiDigitalWiper`. Import transports and transport exceptions from
158
+ `scietex.hal.spi`.
159
+
160
+ ## Upgrading to 0.4.0
161
+
162
+ 0.4.0 moves the transport layer out of this package into the published
163
+ `scietex.hal.spi` 0.1.0 distribution.
164
+
165
+ Breaking changes:
166
+
167
+ * `BDPotentiometer.transport` is gone; `scietex.hal.spi` replaces it.
168
+ * These names are no longer importable from `BDPotentiometer`: `SpiTransport`,
169
+ `SpiDevTransport`, `FakeSpiTransport`, `I2cTransport`, `TransportError`,
170
+ `TransportClosed`, `is_spi_transport`, `fix_gpiozero_dual_cs_spi`, and
171
+ `GpiozeroSpiTransport`.
172
+ * `__all__` now lists only `DigitalPotentiometerDevice`, `DigitalWiper`,
173
+ `Potentiometer`, and `SpiDigitalWiper`.
174
+ * The `ImportError` for a missing backend now names `scietex.hal.spi[spi]` or
175
+ `scietex.hal.spi[gpiozero]` instead of the `BDPotentiometer` extras.
176
+
177
+ Migration:
178
+
179
+ ```python
180
+ # before
181
+ from BDPotentiometer.transport import SpiDevTransport
182
+
183
+ # after
184
+ from scietex.hal.spi import SpiDevTransport
185
+ ```
186
+
187
+ Install the matching transport extra, for example
188
+ `pip install 'scietex.hal.spi[spi]'`. Device constructors, the
189
+ `transport=`/`spi=`/pin keywords, `.close()`, `.closed`, `.transport`, and
190
+ `.spi` are unchanged.
151
191
 
152
192
  Please see the [examples](examples) directory for more usage examples.
153
193
 
@@ -1,7 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
- src/BDPotentiometer/__gpiozero_helpers.py
5
4
  src/BDPotentiometer/__helpers.py
6
5
  src/BDPotentiometer/__init__.py
7
6
  src/BDPotentiometer/__logger.py
@@ -18,14 +17,7 @@ src/BDPotentiometer/mcp4xxx/__init__.py
18
17
  src/BDPotentiometer/mcp4xxx/mcp4xx1.py
19
18
  src/BDPotentiometer/mcp4xxx/mcp4xx2.py
20
19
  src/BDPotentiometer/mcp4xxx/mcp4xxx.py
21
- src/BDPotentiometer/transport/__init__.py
22
- src/BDPotentiometer/transport/base.py
23
- src/BDPotentiometer/transport/fake.py
24
- src/BDPotentiometer/transport/gpiozero_spi.py
25
- src/BDPotentiometer/transport/selection.py
26
- src/BDPotentiometer/transport/spidev_spi.py
27
20
  tests/test_backward_compatibility.py
28
- tests/test_gpiozero_helpers.py
29
21
  tests/test_logger.py
30
22
  tests/test_optional_backends.py
31
23
  tests/test_version.py
@@ -0,0 +1,25 @@
1
+ scietex.hal.spi<1.0.0,>=0.1.0
2
+
3
+ [dev]
4
+ scietex.hal.spi[gpiozero,spi]
5
+ numpy
6
+
7
+ [docs]
8
+ sphinx
9
+ sphinx_rtd_theme
10
+ scietex.hal.spi[gpiozero]
11
+ numpy
12
+
13
+ [gpiozero]
14
+ scietex.hal.spi[gpiozero]
15
+
16
+ [lint]
17
+ ruff==0.17.4
18
+ ty==0.0.99
19
+
20
+ [spi]
21
+ scietex.hal.spi[spi]
22
+
23
+ [test]
24
+ pytest
25
+ numpy