Repository navigation
Constrain prettyprinttree so PortTree.print() works again - #123
appleweiping wants to merge 2 commits into
Conversation
`PortTree.print()` passes `default_orientation` to `PrettyPrintTree`
(port_utils.py:483, set when either `default_opts` or `savetofile` is used).
PrettyPrintTree removed that argument in 2.0 and takes no `**kwargs`, so with
the current unconstrained requirement a fresh install resolves 2.0.2 and the
call raises:
TypeError: PrettyPrintTree.__init__() got an unexpected keyword argument
'default_orientation'
Pinning `<2` alone is not enough. 1.36.4 keeps the argument but does not
constrain its own `cmd2` dependency; cmd2 4.x moved `cmd2.ansi`, so
`from PrettyPrint import PrettyPrintTree` fails, `port_utils` falls through to
its no-op shim, and `print()` silently returns nothing instead of raising —
worse than the current loud failure. `cmd2<3` is what actually restores output.
Verified in clean virtualenvs:
- unconstrained -> PrettyPrintTree 2.0.2, TypeError as above
- `<2` only -> 1.36.4 + cmd2 4.2.3, ImportError -> silent no-op shim
- `<2` and `cmd2<3` -> 1.36.4 + cmd2 2.7.0, renders a tree as intended
Also drops `prettyprint`, an unrelated and unmaintained 2012 package that
nothing in the codebase imports. It is harmless but misleading next to
`prettyprinttree`, which is the one `port_utils` actually uses.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Housekeeping note: I have closed my earlier draft #118, which fixed the same import failure but pinned only #118 also contained a regression test that builds a component, calls |
|
Pushed f092508 to make the dependency fix self-checking.
Verification on Python 3.12 with the gdstk backend:
This leaves the PR with both the packaging fix and an automated regression guard. Please review the updated head. |
|
One remote CI note: the Unit tests, DRC, and Tutorial runs are held at action required with no jobs because the branch comes from a fork. The local Python 3.12 test suite is green as reported above. Maintainer approval is the only remaining CI step. |
PortTree.print()passesdefault_orientationtoPrettyPrintTree(port_utils.py:483, set wheneverdefault_optsorsavetofileis used). PrettyPrintTree removed that argument in 2.0 and accepts no**kwargs, so with the current unconstrained requirement a fresh install resolves 2.0.2 and the call raises:Pinning
<2alone is not enough, and is arguably worse. 1.36.4 keeps the argument but does not constrain its owncmd2dependency; cmd2 4.x movedcmd2.ansi, sofrom PrettyPrint import PrettyPrintTreefails,port_utilsfalls through to its no-op shim, andprint()silently returns nothing instead of raising.cmd2<3is what actually restores output.Verified in clean virtualenvs:
TypeErroras above<2only<2andcmd2<3This also drops
prettyprint, an unrelated and unmaintained 2012 package that nothing in the codebase imports. It installs without error, so it breaks nothing, but it is misleading sitting next toprettyprinttree, which is the packageport_utilsactually uses.I am aware
cmd2is a transitive dependency rather than something gLayout imports directly, so pinning it here is a judgement call — happy to drop that line if you would rather constrain it another way (or raise it upstream with PrettyPrintTree instead). Without it, though, the printer stays silently broken.Note:
pip install -e .fails on Python 3.14 in my environment becausenumpy<=1.24.0has no cp314 wheel and its sdist build fails; this happens identically on unmodifiedmainand is unrelated to this change. Verification above was on Python 3.11, wherepip install -e .succeeds andpytest tests --ignore=tests/test_cells_layout.pygives 25 passed.🤖 Generated with Claude Code