UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor seanlittle
Visitor
434 Views
Registered: ‎11-06-2018

vivado tcl exec preserve environment

It seems to me that running external shell commands from Vivado is a little...quirky.

I need to preserve the PYTHONPATH variable that exists in the parent shell, but nothing I do seems to preserve that variable, or even allow me to redefine that variable when running a command using EXEC. Here is an example of what I'm trying to do:

puts $env(PYTHONPATH)
/cygdrive/c/work/prj/pylib

exec bash -c "echo \$PYTHONPATH"
<no output>

exec bash -c "PYTHONPATH=$env(PYTHONPATH); bash -c 'echo \$PYTHONPATH'"
<no output>

exec bash -c "echo $env(PYTHONPATH)"
/cygdrive/c/work/prj/pylib

exec bash -c "export PYTHONPATH=test && echo \$PYTHONPATH"
<no output>

exec bash -c "PYTHONPATH=test; bash -c 'echo \$PYTHONPATH'"
<no output>

What is going on here? I have tried *lots* of other permutations of these commands with the same results. I'd really appreciate any pointers.

0 Kudos
5 Replies
Scholar markcurry
Scholar
406 Views
Registered: ‎09-16-2009

Re: vivado tcl exec preserve environment

I can't offer much suggestions, other than pointing out the root cause of your problem likely is NOT vivado.

You're using Vivado, under cygwin running on a windows machine  Most of the quirks you've listed are because of those latter two items not Vivado.  

(Must... Resist... Windows bashing....)

I think your troubles are related to how a Windows Python exe is interacting with Cygwin, and where it sends STDERR/STDOUT.

Try a cygwin version of python perhaps?

Regards,

Mark

0 Kudos
Visitor seanlittle
Visitor
402 Views
Registered: ‎11-06-2018

Re: vivado tcl exec preserve environment

Thanks for the reply. Yes I would much rather be using Linux. That isn't an option for me right now, unfortuneately.

I am using the cygwin, and I am using the python installed by cygwin.

But that is different from the problem that I am seeing. I can't seem define a variable in bash that can then be immediately used. It doesn't matter what python executable I am using if I can't do that... Maybe I should try using "cmd" instead of "bash" and attempt a non-cygwin version of python?

0 Kudos
Scholar markcurry
Scholar
393 Views
Registered: ‎09-16-2009

Re: vivado tcl exec preserve environment

I am using the cygwin, and I am using the python installed by cygwin.

puts $env(PYTHONPATH)
/cygdrive/c/work/prj/pylib

This is NOT the cygwin version of python.  The cygwin version of python will show up as being under  /cygdrive/c/cygwin/...

Regards,

Mark

0 Kudos
Visitor seanlittle
Visitor
383 Views
Registered: ‎11-06-2018

Re: vivado tcl exec preserve environment

That is the value of the PYTHONPATH environmental variable I am attempting to preserve. This is the version of python I am using:

exec bash -c "which python3"
/usr/bin/python3

Thanks again.

0 Kudos
Visitor seanlittle
Visitor
257 Views
Registered: ‎11-06-2018

Re: vivado tcl exec preserve environment

As Mark implied, it seems the best way to get around this is to not use Vivado through cygwin. I was able to fix my python code so that it didn't need the PYTHONPATH env variable. But then the real problems started. Running python from Vivado TCL on cygwin breaks all the file paths. It is completely crazy. Neither the windows "c:/..." path syntax or the cygwin "/cygdrive/c/..." path syntax works. Python just fails to open files or directories complaining that the target doesn't exist. When they do. Seriously.

I was able to get things working by just not using cygwin. I'm posting here in to save some one else some time. Don't do this.

To some Xilinx guy who might care...Are there any plans to support cygwin? I have been quite successful using Altera/Intel Quartus through cygwin. Thanks.

0 Kudos