<div dir="ltr">Hi Markus, could isort be added as a dependency instead?  If I understand this commit right, when running libtbx.clean_clutter, if .isort.cfg is present and isort is not installed, pip is invoked to install isort.  l&#39;m nervous about pip being imported anywhere in our code, especially to install things when running code unrelated to installation.<div><br></div><div>It&#39;s important to keep installation of stuff separate from running of stuff.  Otherwise, it&#39;s impossible to keep dependencies straight.<br><div><br></div><div>-Aaron</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 26, 2017 at 2:29 AM, CCTBX Commit via DLS Jenkins <span dir="ltr">&lt;<a href="mailto:graeme.winter@gmail.com" target="_blank">graeme.winter@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><tt>Repository : ssh://<a href="http://g18-sc-serv-04.diamond.ac.uk/cctbx" target="_blank">g18-sc-serv-04.diamond.a<wbr>c.uk/cctbx</a><br>On branch  : master<br><br><hr><br><br>commit 612869130a6210d49a573a3cff0441<wbr>6a9de67808<br>Author: Markus Gerstel &lt;<a href="mailto:markus.gerstel@diamond.ac.uk" target="_blank">markus.gerstel@diamond.ac.uk</a>&gt;<br>Date:   Thu Oct 26 10:29:05 2017 +0100<br><br>    libtbx.clean_clutter runs isort in supported locations<br><br><br><hr><br><br>612869130a6210d49a573a3cff0441<wbr>6a9de67808<br> libtbx/command_line/clean_clut<wbr>ter.py | 26 ++++++++++++++++++++++++++<br> 1 file changed, 26 insertions(+)<br><br>diff --git a/libtbx/command_line/clean_cl<wbr>utter.py b/libtbx/command_line/clean_cl<wbr>utter.py<br>index d49bf4c25..8fc2e53c8 100644<br><tt style="color:#800">--- a/libtbx/command_line/clean_cl<wbr>utter.py</tt><br><tt style="color:#008">+++ b/libtbx/command_line/clean_cl<wbr>utter.py</tt><br>@@ -32,6 +32,24 @@ def clean_clutter_in(files, tabsize=8):<br>         os.remove(tmpname)<br>         raise<br> <br><tt style="color:#008">+def isort(path):</tt><br><tt style="color:#008">+  try:</tt><br><tt style="color:#008">+    import mock</tt><br><tt style="color:#008">+    from isort.main import main</tt><br><tt style="color:#008">+  except ImportError:</tt><br><tt style="color:#008">+    # Install package if necessary</tt><br><tt style="color:#008">+    import pip</tt><br><tt style="color:#008">+    pip.main([&#39;install&#39;, &#39;isort&#39;, &#39;mock&#39;])</tt><br><tt style="color:#008">+    import mock</tt><br><tt style="color:#008">+    from isort.main import main</tt><br><tt style="color:#008">+  with mock.patch.object(sys, &#39;argv&#39;, [&#39;isort&#39;, &#39;-y&#39;, &#39;-ac&#39;, &#39;-vb&#39;]):</tt><br><tt style="color:#008">+    oldcwd = os.getcwd()</tt><br><tt style="color:#008">+    try:</tt><br><tt style="color:#008">+      os.chdir(path)</tt><br><tt style="color:#008">+      main()</tt><br><tt style="color:#008">+    finally:</tt><br><tt style="color:#008">+      os.chdir(oldcwd)</tt><br><tt style="color:#008">+</tt><br> def run():<br>   opt_parser = (option_parser(<br>     usage=&quot;&quot;&quot;<br>@@ -60,6 +78,7 @@ by running svn commit.&quot;&quot;&quot;)<br>   if co.committing and files:<br>       opt_parser.show_help()<br>       exit(1)<br><tt style="color:#008">+  run_isort_in_path = False</tt><br>   if co.committing:<br>     try:<br>       files = list(subversion.marked_for_com<wbr>mit())<br>@@ -72,7 +91,14 @@ by running svn commit.&quot;&quot;&quot;)<br>       else: dir = files[0]<br>       files = [ c.path for c in libtbx.file_clutter.gather([di<wbr>r])<br>                 if c.is_cluttered(flag_x=False) ]<br><tt style="color:#008">+      if os.path.exists(os.path.join(di<wbr>r, &#39;.isort.cfg&#39;)):</tt><br><tt style="color:#008">+        run_isort_in_path = dir</tt><br>   clean_clutter_in(files, tabsize=co.tabsize)<br><tt style="color:#008">+  if run_isort_in_path:</tt><br><tt style="color:#008">+    try:</tt><br><tt style="color:#008">+      isort(run_isort_in_path<wbr>)</tt><br><tt style="color:#008">+    except Exception as e:</tt><br><tt style="color:#008">+      print(&quot;Did not run isort (%s)&quot; % str(e))</tt><br> <br> if (__name__ == &quot;__main__&quot;):<br>   import sys<br></tt></div></blockquote></div><br></div></div>