title: How to put a folder on PATH with Python?
body: <p>Given  I have a folder 'foo' with some .dll files which needs to be on PATH at runtime of my python script 'setup.py'
  Is it possible to put code inside my 'setup.py' script that will put 'foo' folder on PATH before executing the reset of the code which requires the .dll files to run?</p>
  
  <p>So far I have tried this:</p>
  
  <pre><code>import sys
  import os
  foo = os.path.abspath('dependencies/foo')
  if sys.path[1]!= foo:
      print('Adding foo to PATH:')
      sys.path.insert(1, foo)
      print sys.path
  else:
      print('foo is already on PATH!')
  
  import lib_which_requires_dll_from_foo
  ...
  </code></pre>
  
  <p>but it has no effect, although <code>sys.path</code> shows that 'foo' is on PATH - or am I mistaken and it's not that PATH which it should be on.</p>
  
  <p>My setup.py script works if I put 'foo' on PATH with <code>set PATH=C:\my_path_to\foo;%PATH%)</code></p>
  
  <p><strong>EDIT:</strong> Solution that I use now:</p>
  
  <pre><code>import os
  FOO = os.path.abspath('path_to_my/FOO')
  os.environ['PATH'] = FOO + ";" + os.environ['PATH']
  </code></pre>
  
  <p>I removed if condition because PATH is altered temporary only - not permanently, thus no need to check first.</p>
  
  <p>NOTE: that will propably work on Windows only</p>
  
  <p>Still appreciate further suggestions - preferably such that will work cross platfrom</p>