<div class="gmail_quote">On Wed, Nov 21, 2012 at 7:50 PM, Philipp Hagemeister <span dir="ltr"><<a href="mailto:phihag@phihag.de" target="_blank">phihag@phihag.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 11/21/2012 04:27 AM, Nick Coghlan wrote:<br>
> Or install them all in a single directory, add a __main__.py file to that<br>
> directory and then just pass that directory name on the command line<br>
> instead of a script name. The directory will be added as sys.path[0] and<br>
> the __main__.py file will be executed as the main module (If your<br>
> additional application dependencies are all pure Python files, you can even<br>
> zip up that directory and pass that on the command line instead).<br>
</div>I'm well-aware of that approach, but didn't apply it to dependencies,<br>
and am still not sure how to. Can you describe how a hypothetical<br>
helloworld application with one dependency would look like? And wouldn't<br>
one sacrifice the ability to seamlessly import from the application's<br>
code itself.<br></blockquote><div><br>One directory containing:<br><br>  runthis/<br>       __main__.py<br>           (with content as described for your main.py)<br>       lxml<br>       myapp<br><br>Execute "python runthis" (via a +x shell script if you prefer). Note the lack of -m: you're executing the directory contents, not a package. You can also bundle it all into a zip file, but that only works if you don't need C extension support (since zipimport can't handle the necessary step of extracting the shared libraries out to separate files so the OS can load them.<br>
<br>Cheers,<br>Nick.<br><br></div></div>-- <br>Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>   |   Brisbane, Australia<br>