Release 2023.12.30
[yt-dlp.git] / Makefile
blobc85b24c13eda4114f7e9d097d3ef8b1a29e64961
1 all: lazy-extractors yt-dlp doc pypi-files
2 clean: clean-test clean-dist
3 clean-all: clean clean-cache
4 completions: completion-bash completion-fish completion-zsh
5 doc: README.md CONTRIBUTING.md issuetemplates supportedsites
6 ot: offlinetest
7 tar: yt-dlp.tar.gz
9 # Keep this list in sync with MANIFEST.in
10 # intended use: when building a source distribution,
11 # make pypi-files && python setup.py sdist
12 pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
13 completions yt-dlp.1 requirements.txt setup.cfg devscripts/* test/*
15 .PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites
17 clean-test:
18 rm -rf test/testdata/sigs/player-*.js tmp/ *.annotations.xml *.aria2 *.description *.dump *.frag \
19 *.frag.aria2 *.frag.urls *.info.json *.live_chat.json *.meta *.part* *.tmp *.temp *.unknown_video *.ytdl \
20 *.3gp *.ape *.ass *.avi *.desktop *.f4v *.flac *.flv *.gif *.jpeg *.jpg *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 \
21 *.mp4 *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.swf *.swp *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp
22 clean-dist:
23 rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \
24 yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS .mailmap
25 clean-cache:
26 find . \( \
27 -type d -name .pytest_cache -o -type d -name __pycache__ -o -name "*.pyc" -o -name "*.class" \
28 \) -prune -exec rm -rf {} \;
30 completion-bash: completions/bash/yt-dlp
31 completion-fish: completions/fish/yt-dlp.fish
32 completion-zsh: completions/zsh/_yt-dlp
33 lazy-extractors: yt_dlp/extractor/lazy_extractors.py
35 PREFIX ?= /usr/local
36 BINDIR ?= $(PREFIX)/bin
37 MANDIR ?= $(PREFIX)/man
38 SHAREDIR ?= $(PREFIX)/share
39 PYTHON ?= /usr/bin/env python3
41 # set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
42 SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
44 # set markdown input format to "markdown-smart" for pandoc version 2 and to "markdown" for pandoc prior to version 2
45 MARKDOWN = $(shell if [ `pandoc -v | head -n1 | cut -d" " -f2 | head -c1` = "2" ]; then echo markdown-smart; else echo markdown; fi)
47 install: lazy-extractors yt-dlp yt-dlp.1 completions
48 mkdir -p $(DESTDIR)$(BINDIR)
49 install -m755 yt-dlp $(DESTDIR)$(BINDIR)/yt-dlp
50 mkdir -p $(DESTDIR)$(MANDIR)/man1
51 install -m644 yt-dlp.1 $(DESTDIR)$(MANDIR)/man1/yt-dlp.1
52 mkdir -p $(DESTDIR)$(SHAREDIR)/bash-completion/completions
53 install -m644 completions/bash/yt-dlp $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
54 mkdir -p $(DESTDIR)$(SHAREDIR)/zsh/site-functions
55 install -m644 completions/zsh/_yt-dlp $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
56 mkdir -p $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d
57 install -m644 completions/fish/yt-dlp.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish
59 uninstall:
60 rm -f $(DESTDIR)$(BINDIR)/yt-dlp
61 rm -f $(DESTDIR)$(MANDIR)/man1/yt-dlp.1
62 rm -f $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
63 rm -f $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
64 rm -f $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish
66 codetest:
67 flake8 .
69 test:
70 $(PYTHON) -m pytest
71 $(MAKE) codetest
73 offlinetest: codetest
74 $(PYTHON) -m pytest -k "not download"
76 # XXX: This is hard to maintain
77 CODE_FOLDERS = yt_dlp yt_dlp/downloader yt_dlp/extractor yt_dlp/postprocessor yt_dlp/compat yt_dlp/compat/urllib yt_dlp/utils yt_dlp/dependencies yt_dlp/networking
78 yt-dlp: yt_dlp/*.py yt_dlp/*/*.py
79 mkdir -p zip
80 for d in $(CODE_FOLDERS) ; do \
81 mkdir -p zip/$$d ;\
82 cp -pPR $$d/*.py zip/$$d/ ;\
83 done
84 touch -t 200001010101 zip/yt_dlp/*.py zip/yt_dlp/*/*.py
85 mv zip/yt_dlp/__main__.py zip/
86 cd zip ; zip -q ../yt-dlp yt_dlp/*.py yt_dlp/*/*.py __main__.py
87 rm -rf zip
88 echo '#!$(PYTHON)' > yt-dlp
89 cat yt-dlp.zip >> yt-dlp
90 rm yt-dlp.zip
91 chmod a+x yt-dlp
93 README.md: yt_dlp/*.py yt_dlp/*/*.py devscripts/make_readme.py
94 COLUMNS=80 $(PYTHON) yt_dlp/__main__.py --ignore-config --help | $(PYTHON) devscripts/make_readme.py
96 CONTRIBUTING.md: README.md devscripts/make_contributing.py
97 $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md
99 issuetemplates: devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.yml .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.yml .github/ISSUE_TEMPLATE_tmpl/4_bug_report.yml .github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml yt_dlp/version.py
100 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml .github/ISSUE_TEMPLATE/1_broken_site.yml
101 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.yml .github/ISSUE_TEMPLATE/2_site_support_request.yml
102 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.yml .github/ISSUE_TEMPLATE/3_site_feature_request.yml
103 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/4_bug_report.yml .github/ISSUE_TEMPLATE/4_bug_report.yml
104 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml .github/ISSUE_TEMPLATE/5_feature_request.yml
105 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/6_question.yml .github/ISSUE_TEMPLATE/6_question.yml
107 supportedsites:
108 $(PYTHON) devscripts/make_supportedsites.py supportedsites.md
110 README.txt: README.md
111 pandoc -f $(MARKDOWN) -t plain README.md -o README.txt
113 yt-dlp.1: README.md devscripts/prepare_manpage.py
114 $(PYTHON) devscripts/prepare_manpage.py yt-dlp.1.temp.md
115 pandoc -s -f $(MARKDOWN) -t man yt-dlp.1.temp.md -o yt-dlp.1
116 rm -f yt-dlp.1.temp.md
118 completions/bash/yt-dlp: yt_dlp/*.py yt_dlp/*/*.py devscripts/bash-completion.in
119 mkdir -p completions/bash
120 $(PYTHON) devscripts/bash-completion.py
122 completions/zsh/_yt-dlp: yt_dlp/*.py yt_dlp/*/*.py devscripts/zsh-completion.in
123 mkdir -p completions/zsh
124 $(PYTHON) devscripts/zsh-completion.py
126 completions/fish/yt-dlp.fish: yt_dlp/*.py yt_dlp/*/*.py devscripts/fish-completion.in
127 mkdir -p completions/fish
128 $(PYTHON) devscripts/fish-completion.py
130 _EXTRACTOR_FILES = $(shell find yt_dlp/extractor -name '*.py' -and -not -name 'lazy_extractors.py')
131 yt_dlp/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES)
132 $(PYTHON) devscripts/make_lazy_extractors.py $@
134 yt-dlp.tar.gz: all
135 @tar -czf yt-dlp.tar.gz --transform "s|^|yt-dlp/|" --owner 0 --group 0 \
136 --exclude '*.DS_Store' \
137 --exclude '*.kate-swp' \
138 --exclude '*.pyc' \
139 --exclude '*.pyo' \
140 --exclude '*~' \
141 --exclude '__pycache__' \
142 --exclude '.pytest_cache' \
143 --exclude '.git' \
144 -- \
145 README.md supportedsites.md Changelog.md LICENSE \
146 CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
147 Makefile MANIFEST.in yt-dlp.1 README.txt completions \
148 setup.py setup.cfg yt-dlp yt_dlp requirements.txt \
149 devscripts test
151 AUTHORS: .mailmap
152 git shortlog -s -n | cut -f2 | sort > AUTHORS
154 .mailmap:
155 git shortlog -s -e -n | awk '!(out[$$NF]++) { $$1="";sub(/^[ \t]+/,""); print}' > .mailmap