Skip to content

Commit fd2abc0

Browse files
robtaylorclaude
andcommitted
Minimize backward compatibility API surface
Replace wildcard import in chipflow_lib with explicit minimal API based on actual usage in chipflow-digital-ip and chipflow-examples repositories. Changes: - chipflow_lib/__init__.py: Only export ChipFlowError, __version__, and internal API functions (_parse_config, etc.) - chipflow_lib/platforms/__init__.py: Stub module exporting pin signatures and software build utilities used by dependent packages - chipflow_lib/steps/{board,sim,software}.py: Stub modules exporting step classes used by chipflow-examples - chipflow_lib/config.py: Stub module proxying to chipflow.config - tests/fixtures/mock.toml: Updated step references to use new module names All backward compatibility stubs now show deprecation warnings encouraging users to migrate to the new 'chipflow' package name. Tests: 37 passed, 4 skipped. All backward compatibility imports verified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 62987f9 commit fd2abc0

File tree

8 files changed

+151
-9
lines changed

8 files changed

+151
-9
lines changed

chipflow_lib/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
stacklevel=2
2121
)
2222

23-
# Re-export everything from chipflow
24-
from chipflow import * # noqa: F401, F403
25-
from chipflow import __version__, _parse_config, _get_cls_by_reference, _ensure_chipflow_root, _get_src_loc # noqa: F401
23+
# Re-export only the symbols actually used by chipflow-digital-ip and chipflow-examples
24+
# Top-level exports (used by chipflow-examples)
25+
from chipflow import ChipFlowError # noqa: F401
26+
from chipflow import __version__ # noqa: F401
2627

27-
# Maintain backward compatibility for submodules by making this a namespace package
28-
# When someone imports chipflow_lib.something, Python will look for chipflow.something
29-
__path__ = __import__('chipflow').__path__
28+
# Internal API (used by tests and CLI)
29+
from chipflow import _parse_config, _get_cls_by_reference, _ensure_chipflow_root, _get_src_loc # noqa: F401
30+
31+
# Note: Submodule imports (chipflow_lib.platforms, chipflow_lib.steps, chipflow_lib.config)
32+
# are handled by stub modules in their respective subdirectories

chipflow_lib/config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.config.
4+
5+
This module has been renamed to 'chipflow.config'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
import warnings
10+
11+
# Issue deprecation warning
12+
warnings.warn(
13+
"The 'chipflow_lib.config' module has been renamed to 'chipflow.config'. "
14+
"Please update your imports to use 'chipflow.config' instead. "
15+
"This compatibility shim will be removed in a future version.",
16+
DeprecationWarning,
17+
stacklevel=2
18+
)
19+
20+
# Re-export the entire config module (used by chipflow-examples via 'import chipflow_lib.config')
21+
from chipflow import config as _config
22+
import sys
23+
24+
# Make this module act as a proxy for chipflow.config
25+
sys.modules[__name__] = _config

chipflow_lib/platforms/__init__.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.platforms.
4+
5+
This module has been renamed to 'chipflow.platforms'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
import warnings
10+
11+
# Issue deprecation warning
12+
warnings.warn(
13+
"The 'chipflow_lib.platforms' module has been renamed to 'chipflow.platforms'. "
14+
"Please update your imports to use 'chipflow.platforms' instead. "
15+
"This compatibility shim will be removed in a future version.",
16+
DeprecationWarning,
17+
stacklevel=2
18+
)
19+
20+
# Re-export symbols used by chipflow-digital-ip and chipflow-examples
21+
from chipflow.platforms import ( # noqa: F401
22+
# Pin signatures (used by both repos)
23+
BidirIOSignature,
24+
GPIOSignature,
25+
I2CSignature,
26+
InputIOSignature,
27+
OutputIOSignature,
28+
QSPIFlashSignature,
29+
SPISignature,
30+
UARTSignature,
31+
32+
# Software driver support (used by both repos)
33+
SoftwareDriverSignature,
34+
35+
# Platform-specific configuration (used by chipflow-examples)
36+
Sky130DriveMode,
37+
38+
# Data attachment (used by chipflow-examples)
39+
attach_data,
40+
SoftwareBuild,
41+
)

chipflow_lib/steps/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.steps.
4+
5+
This module has been renamed to 'chipflow.steps'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
# Note: Individual step imports (BoardStep, SimStep, SoftwareStep) are handled
10+
# by their respective stub modules: board.py, sim.py, software.py

chipflow_lib/steps/board.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.steps.board.
4+
5+
This module has been renamed to 'chipflow.steps.board'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
import warnings
10+
11+
# Issue deprecation warning
12+
warnings.warn(
13+
"The 'chipflow_lib.steps.board' module has been renamed to 'chipflow.steps.board'. "
14+
"Please update your imports to use 'chipflow.steps.board' instead. "
15+
"This compatibility shim will be removed in a future version.",
16+
DeprecationWarning,
17+
stacklevel=2
18+
)
19+
20+
# Re-export BoardStep (used by chipflow-examples)
21+
from chipflow.steps.board import BoardStep # noqa: F401

chipflow_lib/steps/sim.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.steps.sim.
4+
5+
This module has been renamed to 'chipflow.steps.sim'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
import warnings
10+
11+
# Issue deprecation warning
12+
warnings.warn(
13+
"The 'chipflow_lib.steps.sim' module has been renamed to 'chipflow.steps.sim'. "
14+
"Please update your imports to use 'chipflow.steps.sim' instead. "
15+
"This compatibility shim will be removed in a future version.",
16+
DeprecationWarning,
17+
stacklevel=2
18+
)
19+
20+
# Re-export SimStep (used by chipflow-examples)
21+
from chipflow.steps.sim import SimStep # noqa: F401

chipflow_lib/steps/software.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
"""
3+
Backward compatibility module for chipflow_lib.steps.software.
4+
5+
This module has been renamed to 'chipflow.steps.software'. This compatibility layer
6+
will be maintained for some time but is deprecated. Please update your imports.
7+
"""
8+
9+
import warnings
10+
11+
# Issue deprecation warning
12+
warnings.warn(
13+
"The 'chipflow_lib.steps.software' module has been renamed to 'chipflow.steps.software'. "
14+
"Please update your imports to use 'chipflow.steps.software' instead. "
15+
"This compatibility shim will be removed in a future version.",
16+
DeprecationWarning,
17+
stacklevel=2
18+
)
19+
20+
# Re-export SoftwareStep (used by chipflow-examples)
21+
from chipflow.steps.software import SoftwareStep # noqa: F401

tests/fixtures/mock.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
project_name = "proj-name"
33

44
[chipflow.steps]
5-
silicon = "chipflow_lib.platform.silicon_step:SiliconStep"
6-
sim = "chipflow_lib.platform.sim_step:SimStep"
7-
software = "chipflow_lib.platform.software_step:SoftwareStep"
5+
silicon = "chipflow.platform.silicon_step:SiliconStep"
6+
sim = "chipflow.platform.sim_step:SimStep"
7+
software = "chipflow.platform.software_step:SoftwareStep"
88

99
[chipflow.silicon]
1010
process = "ihp_sg13g2"

0 commit comments

Comments
 (0)