• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Python <-> Cadence using ipc not reading files

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 2213
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Python <-> Cadence using ipc not reading files

Ivangabs
Ivangabs over 1 year ago

Hello, I would like to ask for assistance.

To preface, I have a python code that simply reads a file (open("file.txt")).read()), and outputs the contents to another file.

When I run python using terminal (i.e. python <python_file>), the python code runs correctly.

But when i use ipcBeginProcess, the python code does run, but it does not read and write on the output file.

Anyone can help? Thanks

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    It works for me. Which IC version are you using (what does getVersion(t) return in the CIW)? I do see an issue if running (say) python v2 from IC23.1 that if I do:

    id=ipcBeginProcess("myPythonCommand")
    ipcWait(id)
    ipcReadProcess(id)

    I get:

    "Could not find platform independent libraries <prefix>\nCould not find platform dependent libraries <exec_prefix>\nConsider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n"

    If it's that, you could just run:

    d=ipcBeginProcess("runUserCmd myPythonCommand")
    ipcWait(id)
    ipcReadProcess(id)

    The runUserCmd restores the PATH and LD_LIBRARY_PATH etc back to what it was before Virtuoso started.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ivangabs
    Ivangabs over 1 year ago in reply to Andrew Beckett

    Thank you for the reply.

    I'm using ICADVM20.1-64b
    Python is 2.6.6.

    Also, I was already using ipcWait:
    ipcWait(ipcBeginProcess(strcat("python " x " " y ".temp") "" "" "" "" "CDS.log_py"))

    x is the python script
    y.temp is the input file.
    y.temp_temp is the copied contents from y.temp using python

    For some reason, when I run x in terminal, the y.temp_temp has contents.
    When ran using ipc, y.temp is not being read, and there is no output in y.temp_temp

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to Ivangabs

    I just threw together this simple python script:

    #!/usr/bin/env python
    import argparse
    parser = argparse.ArgumentParser(description='Simple file copier')
    parser.add_argument('inputFile', type=str,
                        help='Input filename')
    args = parser.parse_args()
    
    data=open(args.inputFile).read()
    newFile=open(args.inputFile+"_temp","w")
    newFile.write(data)
    newFile.close()
    

    and then this SKILL:

    x="readfile.py"
    y="file"
    ipcWait(ipcBeginProcess(strcat("python " x " " y ".temp") "" "" "" "" "CDS.log_py"))
    

    and file.temp_temp was created with the same contents as file.temp. Was anything in the CDS.log_py? If an error occurred, you should see it there (I forced an error, such as giving a file that didn't exist, and it reported this there).

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Ivangabs
    Ivangabs over 1 year ago in reply to Andrew Beckett

    This is my python code:

    import os
    import sys

    s = open(sys.argv[1]).read()
    print("Test Below")
    print(s)
    print(os.getcwd())
    print(sys.argv[1])

    sys.argv[1] should be y.temp. y.temp contents are:

    a 1
    b 2
    c 3
    d 4

    CDS.log_py contents are:

    Test Below

    <working_directory>
    <y.temp>

    Yes, s was not output. Items with <> are censored for privacy reasons, but these values were correct. It's just that s does not have any contents.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago in reply to Ivangabs

    I just tried your code, and it works for me (I'm using ICADVM20.1-64b.500.34 and python 2.7.5 but I'd be surprised if that mattered)

    Test Below
    a 1
    b 2
    c 3
    d 4

    /export/home/myuser/skill
    forum152.temp

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information