]> jfr.im git - yt-dlp.git/blame - Makefile
Don't create console for subprocesses on Windows (#1261)
[yt-dlp.git] / Makefile
CommitLineData
bd9ed423 1all: yt-dlp doc pypi-files
da7f321e 2clean: clean-test clean-dist clean-cache
3completions: completion-bash completion-fish completion-zsh
a26c99ac 4doc: README.md CONTRIBUTING.md issuetemplates supportedsites
da7f321e 5ot: offlinetest
6tar: yt-dlp.tar.gz
7
8# Keep this list in sync with MANIFEST.in
9# intended use: when building a source distribution,
10# make pypi-files && python setup.py sdist
11pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites completions yt-dlp.1 devscripts/* test/*
298f597b 12
da7f321e 13.PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites
4618f3da 14
da7f321e 15clean-test:
40b18348
ÁS
16 rm -rf *.3gp *.annotations.xml *.ape *.avi *.description *.dump *.flac *.flv *.frag *.frag.aria2 *.frag.urls \
17 *.info.json *.jpeg *.jpg *.live_chat.json *.m4a *.m4v *.mkv *.mp3 *.mp4 *.ogg *.opus *.part* *.png *.sbv *.srt \
18 *.swf *.swp *.ttml *.vtt *.wav *.webm *.webp *.ytdl test/testdata/player-*.js
da7f321e 19clean-dist:
20 rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS .mailmap
21clean-cache:
22 find . -name "*.pyc" -o -name "*.class" -delete
23
24completion-bash: completions/bash/yt-dlp
25completion-fish: completions/fish/yt-dlp.fish
26completion-zsh: completions/zsh/_yt-dlp
27lazy-extractors: yt_dlp/extractor/lazy_extractors.py
4618f3da 28
df866e7f 29PREFIX ?= /usr/local
ed64ce59 30DESTDIR ?= .
df866e7f 31BINDIR ?= $(PREFIX)/bin
32MANDIR ?= $(PREFIX)/man
24f7fb5e 33SHAREDIR ?= $(PREFIX)/share
65156eba 34# make_supportedsites.py doesnot work correctly in python2
35PYTHON ?= /usr/bin/env python3
e79e8b7d 36
5738240e 37# set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local
8204c733 38SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
5738240e 39
af751350
S
40# set markdown input format to "markdown-smart" for pandoc version 2 and to "markdown" for pandoc prior to version 2
41MARKDOWN = $(shell if [ `pandoc -v | head -n1 | cut -d" " -f2 | head -c1` = "2" ]; then echo markdown-smart; else echo markdown; fi)
42
da7f321e 43install: yt-dlp yt-dlp.1 completions
359d6d86 44 install -Dm755 yt-dlp $(DESTDIR)$(BINDIR)
45 install -Dm644 yt-dlp.1 $(DESTDIR)$(MANDIR)/man1
46 install -Dm644 completions/bash/yt-dlp $(DESTDIR)$(SHAREDIR)/bash-completion/completions/yt-dlp
47 install -Dm644 completions/zsh/_yt-dlp $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_yt-dlp
48 install -Dm644 completions/fish/yt-dlp.fish $(DESTDIR)$(SHAREDIR)/fish/vendor_completions.d/yt-dlp.fish
dce10884 49
a0ab29f8 50codetest:
dc9a441b 51 flake8 .
a0ab29f8 52
a7b5c8d6 53test:
060ac762 54 $(PYTHON) -m pytest
a0ab29f8
PH
55 $(MAKE) codetest
56
a0ab29f8 57offlinetest: codetest
060ac762 58 $(PYTHON) -m pytest -k "not download"
a7b5c8d6 59
7a5c1cfe 60yt-dlp: yt_dlp/*.py yt_dlp/*/*.py
305d99f0 61 mkdir -p zip
7a5c1cfe 62 for d in yt_dlp yt_dlp/downloader yt_dlp/extractor yt_dlp/postprocessor ; do \
305d99f0 63 mkdir -p zip/$$d ;\
c75c384f 64 cp -pPR $$d/*.py zip/$$d/ ;\
305d99f0 65 done
7a5c1cfe
P
66 touch -t 200001010101 zip/yt_dlp/*.py zip/yt_dlp/*/*.py
67 mv zip/yt_dlp/__main__.py zip/
68 cd zip ; zip -q ../yt-dlp yt_dlp/*.py yt_dlp/*/*.py __main__.py
305d99f0 69 rm -rf zip
7a5c1cfe
P
70 echo '#!$(PYTHON)' > yt-dlp
71 cat yt-dlp.zip >> yt-dlp
72 rm yt-dlp.zip
73 chmod a+x yt-dlp
dce10884 74
7a5c1cfe
P
75README.md: yt_dlp/*.py yt_dlp/*/*.py
76 COLUMNS=80 $(PYTHON) yt_dlp/__main__.py --help | $(PYTHON) devscripts/make_readme.py
4618f3da 77
e56190b3 78CONTRIBUTING.md: README.md
8639f89f 79 $(PYTHON) devscripts/make_contributing.py README.md CONTRIBUTING.md
e56190b3 80
7a5c1cfe 81issuetemplates: devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.md .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.md .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.md .github/ISSUE_TEMPLATE_tmpl/4_bug_report.md .github/ISSUE_TEMPLATE_tmpl/5_feature_request.md yt_dlp/version.py
eefa0f21
S
82 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/1_broken_site.md .github/ISSUE_TEMPLATE/1_broken_site.md
83 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/2_site_support_request.md .github/ISSUE_TEMPLATE/2_site_support_request.md
84 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/3_site_feature_request.md .github/ISSUE_TEMPLATE/3_site_feature_request.md
85 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/4_bug_report.md .github/ISSUE_TEMPLATE/4_bug_report.md
86 $(PYTHON) devscripts/make_issue_template.py .github/ISSUE_TEMPLATE_tmpl/5_feature_request.md .github/ISSUE_TEMPLATE/5_feature_request.md
7710bdf4 87
416c7fcb 88supportedsites:
b9650873 89 $(PYTHON) devscripts/make_supportedsites.py supportedsites.md
416c7fcb 90
cc51a7d4 91README.txt: README.md
af751350 92 pandoc -f $(MARKDOWN) -t plain README.md -o README.txt
cc51a7d4 93
7a5c1cfe
P
94yt-dlp.1: README.md
95 $(PYTHON) devscripts/prepare_manpage.py yt-dlp.1.temp.md
96 pandoc -s -f $(MARKDOWN) -t man yt-dlp.1.temp.md -o yt-dlp.1
97 rm -f yt-dlp.1.temp.md
cfcec693 98
359d6d86 99completions/bash/yt-dlp: yt_dlp/*.py yt_dlp/*/*.py devscripts/bash-completion.in
100 mkdir -p completions/bash
8639f89f 101 $(PYTHON) devscripts/bash-completion.py
23109d6a 102
359d6d86 103completions/zsh/_yt-dlp: yt_dlp/*.py yt_dlp/*/*.py devscripts/zsh-completion.in
104 mkdir -p completions/zsh
8639f89f 105 $(PYTHON) devscripts/zsh-completion.py
24f7fb5e 106
359d6d86 107completions/fish/yt-dlp.fish: yt_dlp/*.py yt_dlp/*/*.py devscripts/fish-completion.in
108 mkdir -p completions/fish
8639f89f 109 $(PYTHON) devscripts/fish-completion.py
56d1912f 110
7a5c1cfe
P
111_EXTRACTOR_FILES = $(shell find yt_dlp/extractor -iname '*.py' -and -not -iname 'lazy_extractors.py')
112yt_dlp/extractor/lazy_extractors.py: devscripts/make_lazy_extractors.py devscripts/lazy_load_template.py $(_EXTRACTOR_FILES)
779822d9
JMF
113 $(PYTHON) devscripts/make_lazy_extractors.py $@
114
804ca01c 115yt-dlp.tar.gz: all
da7f321e 116 @tar -czf $(DESTDIR)/yt-dlp.tar.gz --transform "s|^|yt-dlp/|" --owner 0 --group 0 \
039dc61b
PH
117 --exclude '*.DS_Store' \
118 --exclude '*.kate-swp' \
119 --exclude '*.pyc' \
120 --exclude '*.pyo' \
121 --exclude '*~' \
4f90d2ae 122 --exclude '__pycache__' \
814eed0e
PH
123 --exclude '.git' \
124 -- \
804ca01c 125 README.md supportedsites.md Changelog.md LICENSE \
126 CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
127 Makefile MANIFEST.in yt-dlp.1 README.txt completions \
128 setup.py setup.cfg yt-dlp yt_dlp requirements.txt \
129 devscripts test tox.ini pytest.ini
da7f321e 130
131AUTHORS: .mailmap
132 git shortlog -s -n | cut -f2 | sort > AUTHORS
133
134.mailmap:
135 git shortlog -s -e -n | awk '!(out[$$NF]++) { $$1="";sub(/^[ \t]+/,""); print}' > .mailmap