]>
Commit | Line | Data |
---|---|---|
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 | |
8 | ||
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/* | |
14 | ||
15 | .PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites | |
16 | ||
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 | |
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 {} \; | |
29 | ||
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 | |
34 | ||
35 | PREFIX ?= /usr/local | |
36 | BINDIR ?= $(PREFIX)/bin | |
37 | MANDIR ?= $(PREFIX)/man | |
38 | SHAREDIR ?= $(PREFIX)/share | |
39 | PYTHON ?= /usr/bin/env python3 | |
40 | ||
41 | # $(shell) and $(error) are no-ops in BSD Make and the != variable assignment operator is not supported by GNU Make <4.0 | |
42 | VERSION_CHECK != echo supported | |
43 | VERSION_CHECK ?= $(error GNU Make 4+ or BSD Make is required) | |
44 | CHECK_VERSION := $(VERSION_CHECK) | |
45 | ||
46 | # set markdown input format to "markdown-smart" for pandoc version 2+ and to "markdown" for pandoc prior to version 2 | |
47 | MARKDOWN != if [ "`pandoc -v | head -n1 | cut -d' ' -f2 | head -c1`" -ge "2" ]; then echo markdown-smart; else echo markdown; fi | |
48 | ||
49 | install: lazy-extractors yt-dlp yt-dlp.1 completions | |
50 | mkdir -p $(DESTDIR)$(BINDIR) | |
51 | install -m755 yt-dlp $(DESTDIR)$(BINDIR)/yt-dlp | |
52 | mkdir -p $(DESTDIR)$(MANDIR)/man1 | |
53 | install -m644 yt-dlp.1 $(DESTDIR)$(MANDIR)/man1/yt-dlp.1 | |
54 | mkdir -p $(DESTDIR)$(SHAREDIR)/bash-completion/completions | |
55 | install -m644 completions/bash/yt-dlp $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp | |
56 | mkdir -p $(DESTDIR)$(SHAREDIR)/zsh/site-functions | |
57 | install -m644 completions/zsh/_yt-dlp $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp | |
58 | mkdir -p $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d | |
59 | install -m644 completions/fish/yt-dlp.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish | |
60 | ||
61 | uninstall: | |
62 | rm -f $(DESTDIR)$(BINDIR)/yt-dlp | |
63 | rm -f $(DESTDIR)$(MANDIR)/man1/yt-dlp.1 | |
64 | rm -f $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp | |
65 | rm -f $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp | |
66 | rm -f $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish | |
67 | ||
68 | codetest: | |
69 | flake8 . | |
70 | ||
71 | test: | |
72 | $(PYTHON) -m pytest | |
73 | $(MAKE) codetest | |
74 | ||
75 | offlinetest: codetest | |
76 | $(PYTHON) -m pytest -k "not download" | |
77 | ||
78 | CODE_FOLDERS != find yt_dlp -type f -name '__init__.py' -exec dirname {} \+ | grep -v '/__' | sort | |
79 | CODE_FILES != for f in $(CODE_FOLDERS) ; do echo "$$f" | sed 's,$$,/*.py,' ; done | |
80 | yt-dlp: $(CODE_FILES) | |
81 | mkdir -p zip | |
82 | for d in $(CODE_FOLDERS) ; do \ | |
83 | mkdir -p zip/$$d ;\ | |
84 | cp -pPR $$d/*.py zip/$$d/ ;\ | |
85 | done | |
86 | (cd zip && touch -t 200001010101 $(CODE_FILES)) | |
87 | mv zip/yt_dlp/__main__.py zip/ | |
88 | (cd zip && zip -q ../yt-dlp $(CODE_FILES) __main__.py) | |
89 | rm -rf zip | |
90 | echo '#!$(PYTHON)' > yt-dlp | |
91 | cat yt-dlp.zip >> yt-dlp | |
92 | rm yt-dlp.zip | |
93 | chmod a+x yt-dlp | |
94 | ||
95 | README.md: $(CODE_FILES) devscripts/make_readme.py | |
96 | COLUMNS=80 $(PYTHON) yt_dlp/__main__.py --ignore-config --help | $(PYTHON) devscripts/make_readme.py | |
97 | ||
98 | CONTRIBUTING.md: README.md devscripts/make_contributing.py | |
99 | $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md | |
100 | ||
101 | 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 | |
102 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml .github/ISSUE_TEMPLATE/1_broken_site.yml | |
103 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.yml .github/ISSUE_TEMPLATE/2_site_support_request.yml | |
104 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.yml .github/ISSUE_TEMPLATE/3_site_feature_request.yml | |
105 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/4_bug_report.yml .github/ISSUE_TEMPLATE/4_bug_report.yml | |
106 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml .github/ISSUE_TEMPLATE/5_feature_request.yml | |
107 | $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/6_question.yml .github/ISSUE_TEMPLATE/6_question.yml | |
108 | ||
109 | supportedsites: | |
110 | $(PYTHON) devscripts/make_supportedsites.py supportedsites.md | |
111 | ||
112 | README.txt: README.md | |
113 | pandoc -f $(MARKDOWN) -t plain README.md -o README.txt | |
114 | ||
115 | yt-dlp.1: README.md devscripts/prepare_manpage.py | |
116 | $(PYTHON) devscripts/prepare_manpage.py yt-dlp.1.temp.md | |
117 | pandoc -s -f $(MARKDOWN) -t man yt-dlp.1.temp.md -o yt-dlp.1 | |
118 | rm -f yt-dlp.1.temp.md | |
119 | ||
120 | completions/bash/yt-dlp: $(CODE_FILES) devscripts/bash-completion.in | |
121 | mkdir -p completions/bash | |
122 | $(PYTHON) devscripts/bash-completion.py | |
123 | ||
124 | completions/zsh/_yt-dlp: $(CODE_FILES) devscripts/zsh-completion.in | |
125 | mkdir -p completions/zsh | |
126 | $(PYTHON) devscripts/zsh-completion.py | |
127 | ||
128 | completions/fish/yt-dlp.fish: $(CODE_FILES) devscripts/fish-completion.in | |
129 | mkdir -p completions/fish | |
130 | $(PYTHON) devscripts/fish-completion.py | |
131 | ||
132 | _EXTRACTOR_FILES != find yt_dlp/extractor -name '*.py' -and -not -name 'lazy_extractors.py' | |
133 | yt_dlp/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES) | |
134 | $(PYTHON) devscripts/make_lazy_extractors.py $@ | |
135 | ||
136 | yt-dlp.tar.gz: all | |
137 | @tar -czf yt-dlp.tar.gz --transform "s|^|yt-dlp/|" --owner 0 --group 0 \ | |
138 | --exclude '*.DS_Store' \ | |
139 | --exclude '*.kate-swp' \ | |
140 | --exclude '*.pyc' \ | |
141 | --exclude '*.pyo' \ | |
142 | --exclude '*~' \ | |
143 | --exclude '__pycache__' \ | |
144 | --exclude '.pytest_cache' \ | |
145 | --exclude '.git' \ | |
146 | --exclude '__pyinstaller' \ | |
147 | -- \ | |
148 | README.md supportedsites.md Changelog.md LICENSE \ | |
149 | CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \ | |
150 | Makefile yt-dlp.1 README.txt completions .gitignore \ | |
151 | setup.cfg yt-dlp yt_dlp pyproject.toml devscripts test | |
152 | ||
153 | AUTHORS: | |
154 | git shortlog -s -n HEAD | cut -f2 | sort > AUTHORS |