-
Notifications
You must be signed in to change notification settings - Fork 257
Python2 code in source #288
Description
Describe the bug
In the process of packaging OpenRAM for GNU Guix we stumble over parts of your codebase containing ancient and sometimes faulty Python 2 code. The Guix package build process fails byte-compiling the Python sources, which is why we actually find it.
I was able to /patch/ the sources before the build starts to byte-compile but this does not really solve the problem: as much as we want to distribute OpenRAM with GNU Guix would not want to ship broken code. Are there plans to remove and/or update the relevant parts in the codebase?
AFAICT the modules with broken Python 2 Code are:
- compiler/gdsMill/pyx/box.py
- compiler/gdsMill/pyx/deformer.py
- compiler/gdsMill/pyx/dvifile.py
- compiler/gdsMill/sram_examples/cell6tDemo.py
- compiler/gdsMill/sram_examples/newcell.py
- compiler/gdsMill/pyx/connector.py
- compiler/gdsMill/pyx/epsfile.py
- compiler/gdsMill/pyx/font/afm.py
- compiler/gdsMill/pyx/graph/axis/tick.py
Is it possible that the whole compiler/gdsMill part of the codebase has gone defunct and is now bit-rot? Are there plans to either exclude this module or update/fix the code anytime soon?
Also, there is a SyntaxError lurking in:
- compiler/modules/multibank.py (something with opening parens and closing brackets and vice-versa)
Version
The one tagged v1.2.48.
To Reproduce
Try to byte-compile the whole project with a modern Python (3) interpreter.
Expected behavior
It should be possible to byte-compile the whole project without issues.
Logs
phase `sanity-check' succeeded after 0.2 seconds
starting phase `compile-bytecode'
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/box.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/box.py", line 145
linevectors = map(lambda (p1, p2), self=self, a=a, dx=dx, dy=dy, alignlinevector=alignlinevector:
^^^^^^^^
SyntaxError: Lambda expression parameters cannot be parenthesized
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/connector.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/connector.py", line 262
raise NotImplementedError, "Please specify exactly two angles or lengths"
^
SyntaxError: invalid syntax
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/deformer.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/deformer.py", line 138
print "fallback with exact zero value"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/document.py'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/dvifile.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/dvifile.py", line 105
self.width_index = int((word & 0xFF000000L) >> 24) #make sign-safe
^
SyntaxError: invalid hexadecimal literal
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/epsfile.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/epsfile.py", line 322
raise IOError, "cannot open EPS file '%s'" % self.filename
^
SyntaxError: invalid syntax
Listing '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/__init__.py'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/afm.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/afm.py", line 368
def _processline_kernpairs(self, line, (direction, i)):
^^^^^^^^^^^^^^
SyntaxError: Function parameters cannot be parenthesized
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/encoding.py'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/t1code.py'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/t1font.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/font/t1font.py", line 818
y = ((code.pop(0)*256l+code.pop(0))*256+code.pop(0))*256+code.pop(0)
^
SyntaxError: invalid decimal literal
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/graph/axis/texter.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/graph/axis/texter.py", line 146
mantissamin=tick.rational((1, 1)), mantissamax=tick.rational((10L, 1)),
^
SyntaxError: invalid decimal literal
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/graph/axis/tick.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/pyx/graph/axis/tick.py", line 54
self.denom = 10L ** len(commaparts[1])
^
SyntaxError: invalid decimal literal
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/sram_examples/cell6tDemo.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/sram_examples/cell6tDemo.py", line 85
print "LIB: %s" , gds_file_in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/sram_examples/fillerDemo.py'...
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/sram_examples/newcell.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/gdsMill/sram_examples/newcell.py", line 98
print "LIB: %s" % gds_file_in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
[...]
Compiling '/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/modules/multibank.py'...
*** File "/gnu/store/qdl5yx3s2ly94zh8i33apqrb8nw700wb-openram-1.2.48/lib/python3.11/site-packages/openram/compiler/modules/multibank.py", line 163
self.m2_gap = max(2*drc("pwell_to_nwell"] + drc["well_enclose_active"),
^
SyntaxError: closing parenthesis ']' does not match opening parenthesis '('
[...]
Please note that there are more errors than are show in the log, for the byte-compiler aborts the compilation of a file as soon as it hits an Exception. When we fix one others from the same file can emerge.
Additional context
Add any other context about the problem here.