Skip to content

Commit f002bc9

Browse files
committed
Remake the build system from scratch.
1 parent a246bec commit f002bc9

8 files changed

+138
-150
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*.py[co]
22
/.coverage
3-
/build
43
/dist
54
/doc/*.1

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ install:
4848
- pip install $pyflakes
4949
- pip install docutils
5050
script:
51-
- nosetests --verbose
51+
- make test
5252
- py2diatra .
5353
- private/run-pyflakes
5454
- make -C doc check
5555
- make -C doc all
56-
- python setup.py install
56+
- make install PREFIX=$HOME/.local
5757
- cd /
5858
- djvu2hocr --version
5959
- hocr2djvused --version
6060
- ocrodjvu --version
61-
- export MANPATH="$VIRTUAL_ENV/share/man" MANWIDTH=80
61+
- export MANPATH="$HOME/.local/share/man" MANWIDTH=80
6262
- man 1 ocrodjvu | grep -A 10 -w OCRODJVU
6363
- man 1 djvu2hocr | grep -A 10 -w DJVU2HOCR
6464
- man 1 hocr2djvused | grep -A 10 -w HOCR2DJVUSED

Makefile

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright © 2012-2019 Jakub Wilk <[email protected]>
2+
#
3+
# This file is part of ocrodjvu.
4+
#
5+
# ocrodjvu is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License version 2 as
7+
# published by the Free Software Foundation.
8+
#
9+
# ocrodjvu is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
# for more details.
13+
14+
PYTHON = python
15+
16+
PREFIX = /usr/local
17+
DESTDIR =
18+
19+
bindir = $(PREFIX)/bin
20+
basedir = $(PREFIX)/share/ocrodjvu
21+
mandir = $(PREFIX)/share/man
22+
23+
.PHONY: all
24+
all: ;
25+
26+
python-exe = $(shell $(PYTHON) -c 'import sys; print(sys.executable)')
27+
28+
define install-script
29+
sed \
30+
-e "1 s@^#!.*@#!$(python-exe)@" \
31+
-e "s#^basedir = .*#basedir = '$(basedir)/'#" \
32+
$(1) > $(1).tmp
33+
install -d $(DESTDIR)$(bindir)
34+
install $(1).tmp $(DESTDIR)$(bindir)/$(1)
35+
rm $(1).tmp
36+
endef
37+
38+
define install-lib
39+
install -d $(DESTDIR)$(basedir)/lib/$(1)
40+
install -p -m644 lib/$(1)/*.py $(DESTDIR)$(basedir)/lib/$(1)
41+
endef
42+
43+
.PHONY: install
44+
install: ocrodjvu
45+
$(PYTHON) - < lib/__init__.py # Python version check
46+
$(call install-script,ocrodjvu)
47+
$(call install-script,hocr2djvused)
48+
$(call install-script,djvu2hocr)
49+
$(call install-lib)
50+
$(call install-lib,cli)
51+
$(call install-lib,engines)
52+
ifeq "$(DESTDIR)" ""
53+
umask 022 && $(PYTHON) -m compileall -q $(basedir)/lib/
54+
endif
55+
ifeq "$(wildcard doc/*.1)" ""
56+
# run "$(MAKE) -C doc" to build the manpages
57+
else
58+
install -d $(DESTDIR)$(mandir)/man1
59+
install -m644 doc/*.1 $(DESTDIR)$(mandir)/man1/
60+
endif
61+
62+
.PHONY: test
63+
test: ocrodjvu
64+
$(PYTHON) -c 'import nose; nose.main()' --verbose
65+
66+
.PHONY: clean
67+
clean:
68+
find . -type f -name '*.py[co]' -delete
69+
find . -type d -name '__pycache__' -delete
70+
rm -f .coverage
71+
rm -f *.tmp
72+
73+
.error = GNU make is required
74+
75+
# vim:ts=4 sts=4 sw=4 noet

djvu2hocr

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
#!/usr/bin/env python
2+
# encoding=UTF-8
3+
4+
# Copyright © 2009-2018 Jakub Wilk <[email protected]>
5+
#
6+
# This file is part of ocrodjvu.
7+
#
8+
# didjvu is free software; you can redistribute it and/or modify it
9+
# under the terms of the GNU General Public License version 2 as
10+
# published by the Free Software Foundation.
11+
#
12+
# didjvu is distributed in the hope that it will be useful, but WITHOUT
13+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
# for more details.
216

317
import sys
418

5-
from ocrodjvu.cli import djvu2hocr as _
19+
basedir = None
20+
if basedir is not None:
21+
sys.path[:0] = [basedir]
22+
23+
from lib.cli import djvu2hocr as cli
624

7-
_.main(sys.argv)
25+
cli.main(sys.argv)
826

927
# vim:ts=4 sts=4 sw=4 et

hocr2djvused

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
#!/usr/bin/env python
2+
# encoding=UTF-8
3+
4+
# Copyright © 2008-2018 Jakub Wilk <[email protected]>
5+
#
6+
# This file is part of ocrodjvu.
7+
#
8+
# didjvu is free software; you can redistribute it and/or modify it
9+
# under the terms of the GNU General Public License version 2 as
10+
# published by the Free Software Foundation.
11+
#
12+
# didjvu is distributed in the hope that it will be useful, but WITHOUT
13+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
# for more details.
216

317
import sys
418

5-
from ocrodjvu.cli import hocr2djvused as _
19+
basedir = None
20+
if basedir is not None:
21+
sys.path[:0] = [basedir]
22+
23+
from lib.cli import hocr2djvused as cli
624

7-
_.main(sys.argv)
25+
cli.main(sys.argv)
826

927
# vim:ts=4 sts=4 sw=4 et

ocrodjvu

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
#!/usr/bin/env python
2+
# encoding=UTF-8
3+
4+
# Copyright © 2008-2018 Jakub Wilk <[email protected]>
5+
#
6+
# This file is part of ocrodjvu.
7+
#
8+
# didjvu is free software; you can redistribute it and/or modify it
9+
# under the terms of the GNU General Public License version 2 as
10+
# published by the Free Software Foundation.
11+
#
12+
# didjvu is distributed in the hope that it will be useful, but WITHOUT
13+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
# for more details.
216

317
import sys
418

5-
from ocrodjvu.cli import ocrodjvu as _
19+
basedir = None
20+
if basedir is not None:
21+
sys.path[:0] = [basedir]
22+
23+
from lib.cli import ocrodjvu as cli
624

7-
_.main(sys.argv)
25+
cli.main(sys.argv)
826

927
# vim:ts=4 sts=4 sw=4 et

ocrodjvu.py

-25
This file was deleted.

setup.py

-115
This file was deleted.

0 commit comments

Comments
 (0)