getting version from git or failing
[youtube-dl] / setup.py
1 from distutils.core import setup
2 import sys
3 try:
4     import py2exe
5 except ImportError:
6     sys.stderr.write("Cannot import py2exe")
7 import os
8 import subprocess
9
10 """The p2exe option will create an exe that needs Microsoft Visual C++ 2008 Redistributable Package.
11     python setup.py py2exe
12    You can also build a zip executable with
13     python setup.py bdist --format=zip
14
15
16 """
17
18 # If run without args, build executables
19 if len(sys.argv) == 1:
20     sys.argv.append("py2exe")
21
22 # os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) # conflict with wine-py2exe.sh
23 #sys.path.append('./youtube_dl')
24
25 options = {
26     "bundle_files": 1,
27     "compressed": 1,
28     "optimize": 2,
29     "dist_dir": '.',
30     "dll_excludes": ['w9xpopen.exe']
31 }
32
33 console = [{
34     "script":"./youtube_dl/__main__.py",
35     "dest_base": "youtube-dl",
36 }]
37
38 init_file = open('./youtube_dl/__init__.py')
39
40 try:
41     version = subprocess.checkoutput(["git", "describe", "--abbrev=0", "--tags"])
42 except:
43     version = ''
44
45 setup(name='youtube-dl',
46       version=version,
47       description='Small command-line program to download videos from YouTube.com and other video sites',
48       url='https://github.com/rg3/youtube-dl',
49       packages=['youtube_dl'],
50
51       console = console,
52       options = {"py2exe": options},
53       zipfile = None,
54 )
55
56 import shutil
57 shutil.rmtree("build")
58