Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cidl to Python 3 compatible #433

Merged

Conversation

mlouielu
Copy link
Contributor

@mlouielu mlouielu commented Dec 27, 2021

Summary of this Pull Request (PR)

Update cidl to Python 3 compatible.

Follow up for https://github.com/gwsystems/composite/pull/430/files#r753611216


Build failed when trying to do make init

SyntaxError: invalid syntax
  File "/home/louie/dev/composite/src/components/cidl/calculate_dependencies.py", line 193
    print output.strip()
          ^
SyntaxError: invalid syntax

Intent for your PR

Choose one (Mandatory):

  • This PR is for a code-review and is intended to get feedback, but not to be pulled yet.
  • This PR is mature, and ready to be integrated into the repo.

Reviewers (Mandatory):

@gparmer

Code Quality

As part of this pull request, I've considered the following:

Style:

No coding style bound for Python in SG.

Code Craftsmanship:

  • I've made an attempt to remove all redundant code
  • I've considered ways in which my changes might impact existing code, and cleaned it up
  • I've formatted the code in an effort to make it easier to read (proper error handling, function use, etc...)
  • I've commented appropriately where code is tricky
  • I agree that there is no "throw-away" code, and that code in this PR is of high quality

Testing

Testing with Python 2.7 & 3.9 result:

➜  cidl git:(update-cidl-to-python3-compatible) ✗ python2 /home/louie/dev/composite/src/components/cidl/calculate_dependencies.py /home/louie/dev/composite/src/components/lib/chan/ /home/louie/dev/composite/src/components/ incpaths
-I/home/louie/dev/composite/src/components/interface/evt/. -I/home/louie/dev/composite/src/components/interface/memmgr/. -I/home/louie/dev/composite/src/components/lib/stubs/. -I/home/louie/dev/composite/src/components/lib/ps/ps/ -I/home/louie/dev/composite/src/components/lib/crt/. -I/home/louie/dev/composite/src/components/lib/kernel/. -I/home/louie/dev/composite/src/components/lib/util/. -I/home/louie/dev/composite/src/components/interface/capmgr/. -I/home/louie/dev/composite/src/components/lib/chan/. -I/home/louie/dev/composite/src/components/interface/sched/. -I/home/louie/dev/composite/src/components/interface/chanmgr/. -I/home/louie/dev/composite/src/components/interface/init/. -I/home/louie/dev/composite/src/components/lib/component/. -I/home/louie/dev/composite/src/components/interface/chanmgr_evt/. -I/home/louie/dev/composite/src/components/lib/initargs/. -I/home/louie/dev/composite/src/components/lib/ck/include/ -I/home/louie/dev/composite/src/components/lib/sl/.
➜  cidl git:(update-cidl-to-python3-compatible) ✗ python /home/louie/dev/composite/src/components/cidl/calculate_dependencies.py /home/louie/dev/composite/src/components/lib/chan/ /home/louie/dev/composite/src/components/ incpaths
-I/home/louie/dev/composite/src/components/lib/initargs/. -I/home/louie/dev/composite/src/components/lib/chan/. -I/home/louie/dev/composite/src/components/lib/ps/ps/ -I/home/louie/dev/composite/src/components/interface/memmgr/. -I/home/louie/dev/composite/src/components/interface/capmgr/. -I/home/louie/dev/composite/src/components/lib/stubs/. -I/home/louie/dev/composite/src/components/interface/chanmgr_evt/. -I/home/louie/dev/composite/src/components/lib/component/. -I/home/louie/dev/composite/src/components/lib/kernel/. -I/home/louie/dev/composite/src/components/lib/crt/. -I/home/louie/dev/composite/src/components/lib/ck/include/ -I/home/louie/dev/composite/src/components/interface/evt/. -I/home/louie/dev/composite/src/components/interface/init/. -I/home/louie/dev/composite/src/components/interface/sched/. -I/home/louie/dev/composite/src/components/lib/util/. -I/home/louie/dev/composite/src/components/interface/chanmgr/. -I/home/louie/dev/composite/src/components/lib/sl/.
>>> s1 = set(s1.split())
>>> s2 = set(s2.split())
>>> s2 == s1
True

In Python 3, map/filter result return with their object, not list:

    >>> v = [1, 2, 3, 4, 5]
    >>> vf = filter(lambda x: x, v)
    >>> vf
    <filter object at 0x7fdcef6f0d90>

We can use `list(filter())` or list(map())` to get the result,
and this should be done in `makefile_deps(path)`, otherwise a
`copy.copy(map)` is meaningless:

    >>> vfc = copy.copy(vf)
    >>> vfc
    <filter object at 0x7fdcef6f06a0>
    >>> v[0] = 10000
    >>> list(vfc)
    [10000, 2, 3, 4, 5]
@gparmer
Copy link
Collaborator

gparmer commented Jan 3, 2022

This is amazing. I'm stuck in Python's past, so I appreciate updating this.

Do you know if the scripts in the doc/dev_manual directory need updating as well? I'm not at all asking you to do so, but I wonder if you have an intuition.

@gparmer gparmer merged commit efdca7d into gwsystems:loader Jan 3, 2022
@mlouielu
Copy link
Contributor Author

mlouielu commented Jan 4, 2022

Yes, they need to update too. This includes three problem that needs to be solved:

  1. Scripts in doc/dev_manual/resources/*.py update to Python 3 compatible
  2. Python 2 and Python 3 generate different order in dot file, both sys_graph dot and neato have effect by this:
Python 3 Python 2
py3 py2
  1. Need to use --pdf-engine=xelatex for GDB TUI Unicode in listings (for the box-drawing characters)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants