Makefile 4.5 KB

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