]>
Commit | Line | Data |
---|---|---|
2f1765c4 FV |
1 | #!/usr/bin/env python |
2 | # -*- coding: utf-8 -*- | |
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': | |
24 | print("Cannot import py2exe", file=sys.stderr) | |
25 | exit(1) | |
26 | ||
cc51a7d4 | 27 | py2exe_options = { |
770234af FV |
28 | "bundle_files": 1, |
29 | "compressed": 1, | |
30 | "optimize": 2, | |
31 | "dist_dir": '.', | |
dae69640 | 32 | "dll_excludes": ['w9xpopen.exe', 'crypt32.dll'], |
770234af | 33 | } |
d055fe4c | 34 | |
cc51a7d4 | 35 | py2exe_console = [{ |
a5741a3f | 36 | "script": "./youtube_dl/__main__.py", |
770234af FV |
37 | "dest_base": "youtube-dl", |
38 | }] | |
d055fe4c | 39 | |
fec89790 FV |
40 | py2exe_params = { |
41 | 'console': py2exe_console, | |
d055fe4c | 42 | 'options': {"py2exe": py2exe_options}, |
fec89790 FV |
43 | 'zipfile': None |
44 | } | |
770234af | 45 | |
fec89790 FV |
46 | if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe': |
47 | params = py2exe_params | |
48 | else: | |
6c57e8a0 PH |
49 | files_spec = [ |
50 | ('etc/bash_completion.d', ['youtube-dl.bash-completion']), | |
56d1912f | 51 | ('etc/fish/completions', ['youtube-dl.fish']), |
6c57e8a0 PH |
52 | ('share/doc/youtube_dl', ['README.txt']), |
53 | ('share/man/man1', ['youtube-dl.1']) | |
54 | ] | |
55 | root = os.path.dirname(os.path.abspath(__file__)) | |
56 | data_files = [] | |
57 | for dirname, files in files_spec: | |
58 | resfiles = [] | |
59 | for fn in files: | |
60 | if not os.path.exists(fn): | |
61 | warnings.warn('Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn) | |
62 | else: | |
63 | resfiles.append(fn) | |
64 | data_files.append((dirname, resfiles)) | |
65 | ||
fec89790 | 66 | params = { |
6c57e8a0 | 67 | 'data_files': data_files, |
a5741a3f | 68 | } |
f4441536 JMF |
69 | if setuptools_available: |
70 | params['entry_points'] = {'console_scripts': ['youtube-dl = youtube_dl:main']} | |
71 | else: | |
72 | params['scripts'] = ['bin/youtube-dl'] | |
a5741a3f | 73 | |
5a9858bf JMF |
74 | class build_lazy_extractors(Command): |
75 | description = "Build the extractor lazy loading module" | |
76 | user_options = [] | |
77 | ||
78 | def initialize_options(self): | |
79 | pass | |
80 | ||
81 | def finalize_options(self): | |
82 | pass | |
83 | ||
84 | def run(self): | |
85 | spawn( | |
86 | [sys.executable, 'devscripts/make_lazy_extractors.py', 'youtube_dl/extractor/lazy_extractors.py'], | |
87 | dry_run=self.dry_run, | |
88 | ) | |
89 | ||
a5741a3f | 90 | # Get the version from youtube_dl/version.py without importing the package |
d055fe4c RB |
91 | exec(compile(open('youtube_dl/version.py').read(), |
92 | 'youtube_dl/version.py', 'exec')) | |
87bec4c7 | 93 | |
cc51a7d4 | 94 | setup( |
652e7768 RB |
95 | name='youtube_dl', |
96 | version=__version__, | |
97 | description='YouTube video downloader', | |
98 | long_description='Small command-line program to download videos from' | |
99 | ' YouTube.com and other video sites.', | |
100 | url='https://github.com/rg3/youtube-dl', | |
101 | author='Ricardo Garcia', | |
284acd57 | 102 | author_email='ytdl@yt-dl.org', |
652e7768 RB |
103 | maintainer='Philipp Hagemeister', |
104 | maintainer_email='phihag@phihag.de', | |
56327689 PH |
105 | packages=[ |
106 | 'youtube_dl', | |
107 | 'youtube_dl.extractor', 'youtube_dl.downloader', | |
108 | 'youtube_dl.postprocessor'], | |
53e89361 | 109 | |
a5741a3f | 110 | # Provokes warning on most systems (why?!) |
652e7768 RB |
111 | # test_suite = 'nose.collector', |
112 | # test_requires = ['nosetest'], | |
770234af | 113 | |
652e7768 | 114 | classifiers=[ |
2f1765c4 FV |
115 | "Topic :: Multimedia :: Video", |
116 | "Development Status :: 5 - Production/Stable", | |
117 | "Environment :: Console", | |
118 | "License :: Public Domain", | |
119 | "Programming Language :: Python :: 2.6", | |
120 | "Programming Language :: Python :: 2.7", | |
121 | "Programming Language :: Python :: 3", | |
a03aaaed PH |
122 | "Programming Language :: Python :: 3.2", |
123 | "Programming Language :: Python :: 3.3", | |
124 | "Programming Language :: Python :: 3.4", | |
a5741a3f FV |
125 | ], |
126 | ||
5a9858bf | 127 | cmdclass={'build_lazy_extractors': build_lazy_extractors}, |
fec89790 | 128 | **params |
cc51a7d4 | 129 | ) |