setup.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. import os.path
  4. import warnings
  5. import sys
  6. try:
  7. from setuptools import setup, Command
  8. setuptools_available = True
  9. except ImportError:
  10. from distutils.core import setup, Command
  11. setuptools_available = False
  12. from distutils.spawn import spawn
  13. try:
  14. # This will create an exe that needs Microsoft Visual C++ 2008
  15. # Redistributable Package
  16. import py2exe
  17. except ImportError:
  18. if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
  19. print('Cannot import py2exe', file=sys.stderr)
  20. exit(1)
  21. py2exe_options = {
  22. 'bundle_files': 1,
  23. 'compressed': 1,
  24. 'optimize': 2,
  25. 'dist_dir': '.',
  26. 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
  27. }
  28. # Get the version from crawl_ouchn/version.py without importing the package
  29. exec(compile(open('crawl_ouchn/version.py').read(),
  30. 'crawl_ouchn/version.py', 'exec'))
  31. DESCRIPTION = 'ouchn video downloader'
  32. LONG_DESCRIPTION = 'downlaod videos from ouchn'
  33. py2exe_console = [{
  34. 'script': './main.py',
  35. 'dest_base': 'crawl_ouchn',
  36. 'version': __version__,
  37. 'description': DESCRIPTION,
  38. 'comments': LONG_DESCRIPTION,
  39. 'product_name': 'crawl_ouchn',
  40. 'product_version': __version__,
  41. }]
  42. py2exe_params = {
  43. 'console': py2exe_console,
  44. 'options': {'py2exe': py2exe_options},
  45. 'zipfile': None
  46. }
  47. if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
  48. params = py2exe_params
  49. else:
  50. files_spec = [
  51. ('etc/bash_completion.d', ['crawl_ouchn.bash-completion']),
  52. ('etc/fish/completions', ['crawl_ouchn.fish']),
  53. ('share/doc/crawl_ouchn', ['README.txt']),
  54. ('share/man/man1', ['crawl_ouchn.1'])
  55. ]
  56. root = os.path.dirname(os.path.abspath(__file__))
  57. data_files = []
  58. for dirname, files in files_spec:
  59. resfiles = []
  60. for fn in files:
  61. if not os.path.exists(fn):
  62. warnings.warn(
  63. 'Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn)
  64. else:
  65. resfiles.append(fn)
  66. data_files.append((dirname, resfiles))
  67. params = {
  68. 'data_files': data_files,
  69. }
  70. if setuptools_available:
  71. params['entry_points'] = {
  72. 'console_scripts': ['crawl_ouchn = crawl_ouchn:main']}
  73. else:
  74. params['scripts'] = ['bin/crawl_ouchn']
  75. class build_lazy_extractors(Command):
  76. description = 'Build the extractor lazy loading module'
  77. user_options = []
  78. def initialize_options(self):
  79. pass
  80. def finalize_options(self):
  81. pass
  82. def run(self):
  83. spawn(
  84. [sys.executable, 'devscripts/make_lazy_extractors.py',
  85. 'crawl_ouchn/extractor/lazy_extractors.py'],
  86. dry_run=self.dry_run,
  87. )
  88. setup(
  89. name='crawl_ouchn',
  90. version=__version__,
  91. description=DESCRIPTION,
  92. long_description=LONG_DESCRIPTION,
  93. url='https://github.com/jianboy/crawl-xuexi',
  94. author='jianboy',
  95. author_email='liuyuqi.gov@msn.cn',
  96. maintainer='jianboy',
  97. maintainer_email='liuyuqi.gov@msn.cn',
  98. license='Unlicense',
  99. packages=[
  100. 'crawl_ouchn',
  101. 'crawl_ouchn.postprocessor'],
  102. classifiers=[
  103. 'Topic :: Multimedia :: Video',
  104. 'Development Status :: 5 - Production/Stable',
  105. 'Environment :: Console',
  106. 'License :: Public Domain',
  107. 'Programming Language :: Python',
  108. 'Programming Language :: Python :: 2',
  109. 'Programming Language :: Python :: 2.6',
  110. 'Programming Language :: Python :: 2.7',
  111. 'Programming Language :: Python :: 3',
  112. 'Programming Language :: Python :: 3.2',
  113. 'Programming Language :: Python :: 3.3',
  114. 'Programming Language :: Python :: 3.4',
  115. 'Programming Language :: Python :: 3.5',
  116. 'Programming Language :: Python :: 3.6',
  117. 'Programming Language :: Python :: 3.7',
  118. 'Programming Language :: Python :: 3.8',
  119. 'Programming Language :: Python :: Implementation',
  120. 'Programming Language :: Python :: Implementation :: CPython',
  121. 'Programming Language :: Python :: Implementation :: IronPython',
  122. 'Programming Language :: setup.cfgPython :: Implementation :: Jython',
  123. 'Programming Language :: Python :: Implementation :: PyPy',
  124. ],
  125. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  126. **params
  127. )