Make __main__ work in all scenarios with relative imports
authorPhilipp Hagemeister <phihag@phihag.de>
Wed, 28 Nov 2012 02:55:35 +0000 (03:55 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Wed, 28 Nov 2012 02:55:35 +0000 (03:55 +0100)
Makefile
__main__.py [new file with mode: 0755]
youtube_dl/__main__.py

index aea9671486c46d5d071112b05aab958897d8ace3..c4937a51221649ce667dc738aa49217e1729f157 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ test:
 # TODO un-phony README.md and youtube-dl.bash_completion by reading from .in files and generating from them
 
 youtube-dl: youtube_dl/*.py
-       zip --quiet --junk-paths youtube-dl youtube_dl/*.py
+       zip --quiet youtube-dl __main__.py youtube_dl/*.py
        echo '#!/usr/bin/env python' > youtube-dl
        cat youtube-dl.zip >> youtube-dl
        rm youtube-dl.zip
diff --git a/__main__.py b/__main__.py
new file mode 100755 (executable)
index 0000000..fc3cc8a
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import youtube_dl
+
+if __name__ == '__main__':
+    youtube_dl.main()
index 8c12bfb6477ff7f7626937ff373757539870baeb..ccc782bec162084147bfebbcbb8eb6bee86c191a 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
-# -*- coding: utf-8 -*-
+
+# Execute with python -m youtube_dl
 
 import youtube_dl