<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 19, 2015 at 4:12 PM, salil GK <span dir="ltr"><<a href="mailto:gksalil@gmail.com" target="_blank">gksalil@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>  I will provide more details about what I need to achieve </div><div><br></div><div><div style="font-size:12.8000001907349px">I need to create a package for a tool that I create. Actually the tool that I created is a wrapper over ovftool which is provided by VMWare. ovftool install binary is provided as a bundle hence there is no package installed in the system ( `dpkg -l`  will not list ovftool package ). ovftool will be installed in /usr/bin/ location. </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">   While creating the package I need to check if ovftool is available in the system and the version is 4.1.0. If it is not compatible, I need to fail the package installation with proper message. So how do I write setup.py for achieving the same.</div></div></div></blockquote><div><br></div><div>you can put arbitrary python code in setup.py. so before you call setup() in the file, put something like:</div><div><br></div><div><font face="monospace, monospace">import subprocess</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">try:</font></div><font face="monospace, monospace">    version = subprocess.check_output(['/usr/bin/</font><span style="font-size:12.8000001907349px"><font face="monospace, monospace">ovftool'</font></span><font face="monospace, monospace">,'--version'])</font></div><font face="monospace, monospace">except subprocess.CalledProcessError:</font></div><div class="gmail_extra"><font face="monospace, monospace">    print "ovftool is not properly installed"</font></div><div class="gmail_extra"><font face="monospace, monospace">    raise<br></font><div class="gmail_quote"><font face="monospace, monospace">if not is_this_the_right_version(version):<br>    raise ValueError("ovftool is not the right version")</font><div><br></div><div><br></div><div>of course, you'd probably want better error messages, etc, but hopefully you get the idea.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks</div><div style="font-size:12.8000001907349px">Salil</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 May 2015 at 07:54, salil GK <span dir="ltr"><<a href="mailto:gksalil@gmail.com" target="_blank">gksalil@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hello<span class=""><div><br></div><div>   I was trying to create my package for distribution. I have a requirement that I need to check if one particular command is available in the system ( this command is not installed through a package - but a bundle is installed to get the command in the system ). I am using Ubuntu 14.04</div><div><br></div></span><div>Thanks in advance</div><span><font color="#888888"><div>Salil</div></font></span></div>
</blockquote></div><br></div>
<br>_______________________________________________<br>
Distutils-SIG maillist  -  <a href="mailto:Distutils-SIG@python.org">Distutils-SIG@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/distutils-sig" target="_blank">https://mail.python.org/mailman/listinfo/distutils-sig</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>