Release 2024.03.10
[yt-dlp3.git] / Makefile
blob9344003f8603e909c1a3e87318d6c9456ad36b15
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 pyproject.toml includes/artifacts
10 # intended use: when building a source distribution,
11 # make pypi-files && python3 -m build -sn .
12 pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
13 completions yt-dlp.1 pyproject.toml 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 *.lrc *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 *.mp4 \
21 *.mpg *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.ssa *.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
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
40 GNUTAR ?= tar
42 # set markdown input format to "markdown-smart" for pandoc version 2+ and to "markdown" for pandoc prior to version 2
43 PANDOC_VERSION_CMD = pandoc -v 2>/dev/null | head -n1 | cut -d' ' -f2 | head -c1
44 PANDOC_VERSION != $(PANDOC_VERSION_CMD)
45 PANDOC_VERSION ?= $(shell $(PANDOC_VERSION_CMD))
46 MARKDOWN_CMD = if [ "$(PANDOC_VERSION)" = "1" -o "$(PANDOC_VERSION)" = "0" ]; then echo markdown; else echo markdown-smart; fi
47 MARKDOWN != $(MARKDOWN_CMD)
48 MARKDOWN ?= $(shell $(MARKDOWN_CMD))
50 install: lazy-extractors yt-dlp yt-dlp.1 completions
51 mkdir -p $(DESTDIR)$(BINDIR)
52 install -m755 yt-dlp $(DESTDIR)$(BINDIR)/yt-dlp
53 mkdir -p $(DESTDIR)$(MANDIR)/man1
54 install -m644 yt-dlp.1 $(DESTDIR)$(MANDIR)/man1/yt-dlp.1
55 mkdir -p $(DESTDIR)$(SHAREDIR)/bash-completion/completions
56 install -m644 completions/bash/yt-dlp $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
57 mkdir -p $(DESTDIR)$(SHAREDIR)/zsh/site-functions
58 install -m644 completions/zsh/_yt-dlp $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
59 mkdir -p $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d
60 install -m644 completions/fish/yt-dlp.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish
62 uninstall:
63 rm -f $(DESTDIR)$(BINDIR)/yt-dlp
64 rm -f $(DESTDIR)$(MANDIR)/man1/yt-dlp.1
65 rm -f $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
66 rm -f $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
67 rm -f $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish
69 codetest:
70 flake8 .
72 test:
73 $(PYTHON) -m pytest
74 $(MAKE) codetest
76 offlinetest: codetest
77 $(PYTHON) -m pytest -k "not download"
79 CODE_FOLDERS_CMD = find yt_dlp -type f -name '__init__.py' | sed 's,/__init__.py,,' | grep -v '/__' | sort
80 CODE_FOLDERS != $(CODE_FOLDERS_CMD)
81 CODE_FOLDERS ?= $(shell $(CODE_FOLDERS_CMD))
82 CODE_FILES_CMD = for f in $(CODE_FOLDERS) ; do echo "$$f" | sed 's,$$,/*.py,' ; done
83 CODE_FILES != $(CODE_FILES_CMD)
84 CODE_FILES ?= $(shell $(CODE_FILES_CMD))
85 yt-dlp: $(CODE_FILES)
86 mkdir -p zip
87 for d in $(CODE_FOLDERS) ; do \
88 mkdir -p zip/$$d ;\
89 cp -pPR $$d/*.py zip/$$d/ ;\
90 done
91 (cd zip && touch -t 200001010101 $(CODE_FILES))
92 mv zip/yt_dlp/__main__.py zip/
93 (cd zip && zip -q ../yt-dlp $(CODE_FILES) __main__.py)
94 rm -rf zip
95 echo '#!$(PYTHON)' > yt-dlp
96 cat yt-dlp.zip >> yt-dlp
97 rm yt-dlp.zip
98 chmod a+x yt-dlp
100 README.md: $(CODE_FILES) devscripts/make_readme.py
101 COLUMNS=80 $(PYTHON) yt_dlp/__main__.py --ignore-config --help | $(PYTHON) devscripts/make_readme.py
103 CONTRIBUTING.md: README.md devscripts/make_contributing.py
104 $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md
106 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
107 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml .github/ISSUE_TEMPLATE/1_broken_site.yml
108 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.yml .github/ISSUE_TEMPLATE/2_site_support_request.yml
109 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.yml .github/ISSUE_TEMPLATE/3_site_feature_request.yml
110 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/4_bug_report.yml .github/ISSUE_TEMPLATE/4_bug_report.yml
111 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml .github/ISSUE_TEMPLATE/5_feature_request.yml
112 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/6_question.yml .github/ISSUE_TEMPLATE/6_question.yml
114 supportedsites:
115 $(PYTHON) devscripts/make_supportedsites.py supportedsites.md
117 README.txt: README.md
118 pandoc -f $(MARKDOWN) -t plain README.md -o README.txt
120 yt-dlp.1: README.md devscripts/prepare_manpage.py
121 $(PYTHON) devscripts/prepare_manpage.py yt-dlp.1.temp.md
122 pandoc -s -f $(MARKDOWN) -t man yt-dlp.1.temp.md -o yt-dlp.1
123 rm -f yt-dlp.1.temp.md
125 completions/bash/yt-dlp: $(CODE_FILES) devscripts/bash-completion.in
126 mkdir -p completions/bash
127 $(PYTHON) devscripts/bash-completion.py
129 completions/zsh/_yt-dlp: $(CODE_FILES) devscripts/zsh-completion.in
130 mkdir -p completions/zsh
131 $(PYTHON) devscripts/zsh-completion.py
133 completions/fish/yt-dlp.fish: $(CODE_FILES) devscripts/fish-completion.in
134 mkdir -p completions/fish
135 $(PYTHON) devscripts/fish-completion.py
137 _EXTRACTOR_FILES_CMD = find yt_dlp/extractor -name '*.py' -and -not -name 'lazy_extractors.py'
138 _EXTRACTOR_FILES != $(_EXTRACTOR_FILES_CMD)
139 _EXTRACTOR_FILES ?= $(shell $(_EXTRACTOR_FILES_CMD))
140 yt_dlp/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES)
141 $(PYTHON) devscripts/make_lazy_extractors.py $@
143 yt-dlp.tar.gz: all
144 @$(GNUTAR) -czf yt-dlp.tar.gz --transform "s|^|yt-dlp/|" --owner 0 --group 0 \
145 --exclude '*.DS_Store' \
146 --exclude '*.kate-swp' \
147 --exclude '*.pyc' \
148 --exclude '*.pyo' \
149 --exclude '*~' \
150 --exclude '__pycache__' \
151 --exclude '.pytest_cache' \
152 --exclude '.git' \
153 -- \
154 README.md supportedsites.md Changelog.md LICENSE \
155 CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
156 Makefile yt-dlp.1 README.txt completions .gitignore \
157 setup.cfg yt-dlp yt_dlp pyproject.toml devscripts test
159 AUTHORS:
160 git shortlog -s -n HEAD | cut -f2 | sort > AUTHORS