Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. all: hypervideo doc pypi-files
  2. clean: clean-test clean-dist clean-cache
  3. completions: completion-bash completion-fish completion-zsh
  4. doc: README.md CONTRIBUTING.md
  5. ot: offlinetest
  6. tar: hypervideo.tar.gz
  7. # Keep this list in sync with MANIFEST.in
  8. # intended use: when building a source distribution,
  9. # make pypi-files && python setup.py sdist
  10. pypi-files: AUTHORS Changelog.md LICENSE README.md completions devscripts/* test/*
  11. .PHONY: all clean install test tar pypi-files completions ot offlinetest codetest
  12. clean-test:
  13. rm -rf *.3gp *.annotations.xml *.ape *.avi *.description *.dump *.flac *.flv *.frag *.frag.aria2 *.frag.urls \
  14. *.info.json *.jpeg *.jpg *.live_chat.json *.m4a *.m4v *.mkv *.mp3 *.mp4 *.ogg *.opus *.part* *.png *.sbv *.srt \
  15. *.swf *.swp *.ttml *.vtt *.wav *.webm *.webp *.ytdl test/testdata/player-*.js
  16. clean-dist:
  17. rm -rf MANIFEST build/ dist/ .coverage cover/ hypervideo.tar.gz completions/ hypervideo_dl/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp hypervideo hypervideo.exe hypervideo_dl.egg-info/ AUTHORS .mailmap
  18. clean-cache:
  19. find . -name "*.pyc" -o -name "*.class" -delete
  20. completion-bash: completions/bash/hypervideo
  21. completion-fish: completions/fish/hypervideo.fish
  22. completion-zsh: completions/zsh/_hypervideo
  23. lazy-extractors: hypervideo_dl/extractor/lazy_extractors.py
  24. PREFIX ?= /usr/local
  25. DESTDIR ?= .
  26. BINDIR ?= $(PREFIX)/bin
  27. MANDIR ?= $(PREFIX)/man
  28. SHAREDIR ?= $(PREFIX)/share
  29. PYTHON ?= /usr/bin/env python3
  30. # set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
  31. SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
  32. install: hypervideo completions
  33. install -Dm755 hypervideo $(DESTDIR)$(BINDIR)
  34. install -Dm644 completions/bash/hypervideo $(DESTDIR)$(SHAREDIR)/bash-completion/completions/hypervideo
  35. install -Dm644 completions/zsh/_hypervideo $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_hypervideo
  36. install -Dm644 completions/fish/hypervideo.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/hypervideo.fish
  37. codetest:
  38. flake8 .
  39. test:
  40. $(PYTHON) -m pytest
  41. $(MAKE) codetest
  42. offlinetest: codetest
  43. $(PYTHON) -m pytest -k "not download"
  44. hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py
  45. mkdir -p zip
  46. for d in hypervideo_dl hypervideo_dl/downloader hypervideo_dl/extractor hypervideo_dl/postprocessor ; do \
  47. mkdir -p zip/$$d ;\
  48. cp -pPR $$d/*.py zip/$$d/ ;\
  49. done
  50. touch -t 200001010101 zip/hypervideo_dl/*.py zip/hypervideo_dl/*/*.py
  51. mv zip/hypervideo_dl/__main__.py zip/
  52. cd zip ; zip -q ../hypervideo hypervideo_dl/*.py hypervideo_dl/*/*.py __main__.py
  53. rm -rf zip
  54. echo '#!$(PYTHON)' > hypervideo
  55. cat hypervideo.zip >> hypervideo
  56. rm hypervideo.zip
  57. chmod a+x hypervideo
  58. README.md: hypervideo_dl/*.py hypervideo_dl/*/*.py
  59. COLUMNS=80 $(PYTHON) hypervideo_dl/__main__.py --help | $(PYTHON) devscripts/make_readme.py
  60. CONTRIBUTING.md: README.md
  61. $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md
  62. completions/bash/hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/bash-completion.in
  63. mkdir -p completions/bash
  64. $(PYTHON) devscripts/bash-completion.py
  65. completions/zsh/_hypervideo: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/zsh-completion.in
  66. mkdir -p completions/zsh
  67. $(PYTHON) devscripts/zsh-completion.py
  68. completions/fish/hypervideo.fish: hypervideo_dl/*.py hypervideo_dl/*/*.py devscripts/fish-completion.in
  69. mkdir -p completions/fish
  70. $(PYTHON) devscripts/fish-completion.py
  71. _EXTRACTOR_FILES = $(shell find hypervideo_dl/extractor -iname '*.py' -and -not -iname 'lazy_extractors.py')
  72. hypervideo_dl/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES)
  73. $(PYTHON) devscripts/make_lazy_extractors.py $@
  74. hypervideo.tar.gz: all
  75. @tar -czf $(DESTDIR)/hypervideo.tar.gz --transform "s|^|hypervideo/|" --owner 0 --group 0 \
  76. --exclude '*.DS_Store' \
  77. --exclude '*.kate-swp' \
  78. --exclude '*.pyc' \
  79. --exclude '*.pyo' \
  80. --exclude '*~' \
  81. --exclude '__pycache__' \
  82. --exclude '.pytest_cache' \
  83. --exclude '.git' \
  84. -- \
  85. bin README.md Changelog.md LICENSE \
  86. CONTRIBUTING.md CONTRIBUTORS AUTHORS \
  87. Makefile MANIFEST.in README.md completions \
  88. setup.py setup.cfg hypervideo hypervideo_dl requirements.txt \
  89. devscripts test
  90. AUTHORS: .mailmap
  91. git shortlog -s -n | cut -f2 | sort > AUTHORS
  92. .mailmap:
  93. git shortlog -s -e -n | awk '!(out[$$NF]++) { $$1="";sub(/^[ \t]+/,""); print}' > .mailmap