]>
Commit | Line | Data |
---|---|---|
2f1765c4 | 1 | #!/usr/bin/env python |
dcdb292f | 2 | # coding: utf-8 |
2f1765c4 | 3 | |
01c62591 | 4 | from __future__ import print_function |
e646ffe7 | 5 | |
6c57e8a0 | 6 | import os.path |
6c57e8a0 | 7 | import warnings |
4efe62a0 | 8 | import sys |
cc51a7d4 | 9 | |
a32b573c | 10 | try: |
5a9858bf | 11 | from setuptools import setup, Command |
f4441536 | 12 | setuptools_available = True |
a32b573c | 13 | except ImportError: |
5a9858bf | 14 | from distutils.core import setup, Command |
369a759a | 15 | setuptools_available = False |
5a9858bf | 16 | from distutils.spawn import spawn |
a32b573c | 17 | |
fec89790 | 18 | try: |
131842bb RB |
19 | # This will create an exe that needs Microsoft Visual C++ 2008 |
20 | # Redistributable Package | |
fec89790 | 21 | import py2exe |
fec89790 FV |
22 | except ImportError: |
23 | if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe': | |
3d4b08df | 24 | print('Cannot import py2exe', file=sys.stderr) |
fec89790 FV |
25 | exit(1) |
26 | ||
cc51a7d4 | 27 | py2exe_options = { |
3d4b08df S |
28 | 'bundle_files': 1, |
29 | 'compressed': 1, | |
30 | 'optimize': 2, | |
31 | 'dist_dir': '.', | |
32 | 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'], | |
770234af | 33 | } |
d055fe4c | 34 | |
3d4b08df S |
35 | # Get the version from youtube_dl/version.py without importing the package |
36 | exec(compile(open('youtube_dl/version.py').read(), | |
37 | 'youtube_dl/version.py', 'exec')) | |
38 | ||
39 | DESCRIPTION = 'YouTube video downloader' | |
40 | LONG_DESCRIPTION = 'Command-line program to download videos from YouTube.com and other video sites' | |
41 | ||
cc51a7d4 | 42 | py2exe_console = [{ |
3d4b08df S |
43 | 'script': './youtube_dl/__main__.py', |
44 | 'dest_base': 'youtube-dl', | |
45 | 'version': __version__, | |
46 | 'description': DESCRIPTION, | |
47 | 'comments': LONG_DESCRIPTION, | |
48 | 'product_name': 'youtube-dl', | |
49 | 'product_version': __version__, | |
770234af | 50 | }] |
d055fe4c | 51 | |
fec89790 FV |
52 | py2exe_params = { |
53 | 'console': py2exe_console, | |
3d4b08df | 54 | 'options': {'py2exe': py2exe_options}, |
fec89790 FV |
55 | 'zipfile': None |
56 | } | |
770234af | 57 | |
fec89790 FV |
58 | if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe': |
59 | params = py2exe_params | |
60 | else: | |
6c57e8a0 PH |
61 | files_spec = [ |
62 | ('etc/bash_completion.d', ['youtube-dl.bash-completion']), | |
56d1912f | 63 | ('etc/fish/completions', ['youtube-dl.fish']), |
6c57e8a0 PH |
64 | ('share/doc/youtube_dl', ['README.txt']), |
65 | ('share/man/man1', ['youtube-dl.1']) | |
66 | ] | |
67 | root = os.path.dirname(os.path.abspath(__file__)) | |
68 | data_files = [] | |
69 | for dirname, files in files_spec: | |
70 | resfiles = [] | |
71 | for fn in files: | |
72 | if not os.path.exists(fn): | |
73 | warnings.warn('Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn) | |
74 | else: | |
75 | resfiles.append(fn) | |
76 | data_files.append((dirname, resfiles)) | |
77 | ||
fec89790 | 78 | params = { |
6c57e8a0 | 79 | 'data_files': data_files, |
a5741a3f | 80 | } |
f4441536 JMF |
81 | if setuptools_available: |
82 | params['entry_points'] = {'console_scripts': ['youtube-dl = youtube_dl:main']} | |
83 | else: | |
84 | params['scripts'] = ['bin/youtube-dl'] | |
a5741a3f | 85 | |
5a9858bf | 86 | class build_lazy_extractors(Command): |
3d4b08df | 87 | description = 'Build the extractor lazy loading module' |
5a9858bf JMF |
88 | user_options = [] |
89 | ||
90 | def initialize_options(self): | |
91 | pass | |
92 | ||
93 | def finalize_options(self): | |
94 | pass | |
95 | ||
96 | def run(self): | |
97 | spawn( | |
98 | [sys.executable, 'devscripts/make_lazy_extractors.py', 'youtube_dl/extractor/lazy_extractors.py'], | |
99 | dry_run=self.dry_run, | |
100 | ) | |
101 | ||
cc51a7d4 | 102 | setup( |
652e7768 RB |
103 | name='youtube_dl', |
104 | version=__version__, | |
3d4b08df S |
105 | description=DESCRIPTION, |
106 | long_description=LONG_DESCRIPTION, | |
652e7768 RB |
107 | url='https://github.com/rg3/youtube-dl', |
108 | author='Ricardo Garcia', | |
284acd57 | 109 | author_email='ytdl@yt-dl.org', |
0d427c83 S |
110 | maintainer='Sergey M.', |
111 | maintainer_email='dstftw@gmail.com', | |
56327689 PH |
112 | packages=[ |
113 | 'youtube_dl', | |
114 | 'youtube_dl.extractor', 'youtube_dl.downloader', | |
115 | 'youtube_dl.postprocessor'], | |
53e89361 | 116 | |
a5741a3f | 117 | # Provokes warning on most systems (why?!) |
652e7768 RB |
118 | # test_suite = 'nose.collector', |
119 | # test_requires = ['nosetest'], | |
770234af | 120 | |
652e7768 | 121 | classifiers=[ |
3d4b08df S |
122 | 'Topic :: Multimedia :: Video', |
123 | 'Development Status :: 5 - Production/Stable', | |
124 | 'Environment :: Console', | |
125 | 'License :: Public Domain', | |
126 | 'Programming Language :: Python :: 2.6', | |
127 | 'Programming Language :: Python :: 2.7', | |
128 | 'Programming Language :: Python :: 3', | |
129 | 'Programming Language :: Python :: 3.2', | |
130 | 'Programming Language :: Python :: 3.3', | |
131 | 'Programming Language :: Python :: 3.4', | |
132 | 'Programming Language :: Python :: 3.5', | |
139d8ac1 | 133 | 'Programming Language :: Python :: 3.6', |
a5741a3f FV |
134 | ], |
135 | ||
5a9858bf | 136 | cmdclass={'build_lazy_extractors': build_lazy_extractors}, |
fec89790 | 137 | **params |
cc51a7d4 | 138 | ) |