From e5f44a5160e8845d460a87b7c8fde7a774dd540d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 24 Mar 2019 10:36:33 +0100 Subject: [PATCH] add Makefile; include manpage&completion in setup.py (#150) --- Makefile | 39 +++++++++++++++++++ scripts/bash_completion.py | 2 +- scripts/release.sh | 2 +- ...ld_supportedsites.py => supportedsites.py} | 0 setup.py | 4 ++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Makefile rename scripts/{build_supportedsites.py => supportedsites.py} (100%) diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f8f8e2e1 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ + +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +MANDIR ?= $(PREFIX)/man +SHAREDIR ?= $(PREFIX)/share +PYTHON ?= /usr/bin/env python3 + +# set SYSCONFDIR to /etc if PREFIX=/usr or PREFIX=/usr/local +SYSCONFDIR = $(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi) + +all: gallery-dl.1 gallery-dl.bash_completion docs/supportedsites.rst + +clean: + $(RM) gallery-dl.1 gallery-dl.bash_completion + $(RM) -r build/ + +install: gallery-dl.1 gallery-dl.bash_completion + $(PYTHON) setup.py install + install -d $(DESTDIR)$(MANDIR)/man1 + install -m 644 youtube-dl.1 $(DESTDIR)$(MANDIR)/man1 + install -d $(DESTDIR)$(SYSCONFDIR)/bash_completion.d + install -m 644 youtube-dl.bash_completion $(DESTDIR)$(SYSCONFDIR)/bash_completion.d/youtube-dl + +release: docs/supportedsites.rst + scripts/release.sh + +test: + scripts/run_tests.sh + +.PHONY: all clean install release test + +docs/supportedsites.rst: gallery_dl/*/*.py scripts/supportedsites.py + $(PYTHON) scripts/supportedsites.py + +gallery-dl.1: gallery_dl/option.py scripts/man.py + $(PYTHON) scripts/man.py + +gallery-dl.bash_completion: gallery_dl/option.py scripts/bash_completion.py + $(PYTHON) scripts/bash_completion.py diff --git a/scripts/bash_completion.py b/scripts/bash_completion.py index 64ab6e32..9108cdc7 100755 --- a/scripts/bash_completion.py +++ b/scripts/bash_completion.py @@ -51,7 +51,7 @@ for action in option.build_parser()._actions: opts.append(opt) -PATH = os.path.join(ROOTDIR, "gallery-dl.bash-completion") +PATH = os.path.join(ROOTDIR, "gallery-dl.bash_completion") with open(PATH, "w", encoding="utf-8") as file: file.write(TEMPLATE % { "opts" : " ".join(opts), diff --git a/scripts/release.sh b/scripts/release.sh index 689ab62a..1e8272b8 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -98,7 +98,7 @@ supportedsites() { cd "${ROOTDIR}" echo Checking if "${SUPPORTEDSITES}" is up to date - ./scripts/build_supportedsites.py + ./scripts/supportedsites.py if ! git diff --quiet "${SUPPORTEDSITES}"; then echo "updated ${SUPPORTEDSITES} contains changes" exit 4 diff --git a/scripts/build_supportedsites.py b/scripts/supportedsites.py similarity index 100% rename from scripts/build_supportedsites.py rename to scripts/supportedsites.py diff --git a/setup.py b/setup.py index 227b4966..eabd613d 100644 --- a/setup.py +++ b/setup.py @@ -90,6 +90,10 @@ setup( "gallery_dl.downloader", "gallery_dl.postprocessor", ], + data_files = [ + ('etc/bash_completion.d', ['gallery-dl.bash-completion']), + ('share/man/man1' , ['gallery-dl.1']), + ], keywords="image gallery downloader crawler scraper", classifiers=[ "Development Status :: 5 - Production/Stable",