forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (90 loc) · 4.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# Makefile to build css and js files, compile i18n messages and stamp
# version information
#
BUILD=static/build
PYBUNDLE_URL=http://www.archive.org/download/ol_vendor/openlibrary.pybundle
OL_VENDOR=http://www.archive.org/download/ol_vendor
SOLR_VERSION=apache-solr-1.4.0
ACCESS_LOG_FORMAT='%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s"'
GITHUB_EDITOR_WIDTH=127
# Use python from local env if it exists or else default to python in the path.
PYTHON=$(if $(wildcard env),env/bin/python,python)
.PHONY: all clean distclean git css js i18n lint
all: git css js i18n
css:
mkdir -p $(BUILD)
lessc -x static/css/page-admin.less $(BUILD)/page-admin.css
lessc -x static/css/page-book.less $(BUILD)/page-book.css
lessc -x static/css/page-edit.less $(BUILD)/page-edit.css
lessc -x static/css/page-form.less $(BUILD)/page-form.css
lessc -x static/css/page-home.less $(BUILD)/page-home.css
lessc -x static/css/page-lists.less $(BUILD)/page-lists.css
lessc -x static/css/page-plain.less $(BUILD)/page-plain.css
lessc -x static/css/page-subject.less $(BUILD)/page-subject.css
lessc -x static/css/page-user.less $(BUILD)/page-user.css
lessc -x static/css/js-all.less $(BUILD)/js-all.css
lessc -x static/css/page-book-widget.less $(BUILD)/page-book-widget.css
lessc -x static/css/page-design.less $(BUILD)/page-design.css
lessc -x static/css/page-dev.less $(BUILD)/page-dev.css
js:
mkdir -p $(BUILD)
bash static/js/vendor.jsh > $(BUILD)/vendor-v2.js
bash static/js/all.jsh > $(BUILD)/all.js
i18n:
$(PYTHON) ./scripts/i18n-messages compile
git:
git submodule init
git submodule sync
git submodule update
clean:
rm -rf $(BUILD)
distclean:
git clean -fdx
git submodule foreach git clean -fdx
venv:
@echo "** setting up virtualenv **"
mkdir -p var/cache/pip
virtualenv env
./env/bin/pip install --download-cache var/cache/pip $(OL_VENDOR)/openlibrary.pybundle
install_solr:
@echo "** installing solr **"
mkdir -p var/lib/solr var/cache usr/local
wget -c $(OL_VENDOR)/$(SOLR_VERSION).tgz -O var/cache/$(SOLR_VERSION).tgz
cd usr/local && tar xzf ../../var/cache/$(SOLR_VERSION).tgz && ln -fs $(SOLR_VERSION) solr
setup_coverstore:
@echo "** setting up coverstore **"
$(PYTHON) scripts/setup_dev_instance.py --setup-coverstore
setup_ol: git
@echo "** setting up openlibrary webapp **"
$(PYTHON) scripts/setup_dev_instance.py --setup-ol
@# When bootstrapping, PYTHON will not be env/bin/python as env dir won't be there when make is invoked.
@# Invoking make again to pick the right PYTHON.
make all
bootstrap: venv install_solr setup_coverstore setup_ol
run:
$(PYTHON) scripts/openlibrary-server conf/openlibrary.yml
load_sample_data:
@echo "loading sample docs from openlibrary.org website"
$(PYTHON) scripts/copydocs.py --list /people/anand/lists/OL1815L
curl http://localhost:8080/_dev/process_ebooks # hack to show books in returncart
destroy:
@echo Destroying the dev instance.
-dropdb coverstore
-dropdb openlibrary
rm -rf var usr env
reindex-solr:
psql openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/books/' | PYTHONPATH=$(PWD) xargs python openlibrary/solr/update_work.py -s http://0.0.0.0/ -c conf/openlibrary.yml --data-provider=legacy
psql openlibrary -t -c 'select key from thing' | sed 's/ *//' | grep '^/authors/' | PYTHONPATH=$(PWD) xargs python openlibrary/solr/update_work.py -s http://0.0.0.0/ -c conf/openlibrary.yml --data-provider=legacy
lint:
# stop the build if there are Python syntax errors or undefined names
$(PYTHON) -m flake8 . --count --exclude=./.*,scripts/20*,vendor/* --select=E901,E999,F822,F823 --show-source --statistics
# TODO: Add --select=F821 below into the line above as soon as the Undefined Name issues have been fixed
$(PYTHON) -m flake8 . --exit-zero --count --exclude=./.*,scripts/20*,vendor/* --select=F821 --show-source --statistics
ifndef CONTINUOUS_INTEGRATION
# exit-zero treats all errors as warnings, only run this in local dev while fixing issue, not CI as it will never fail.
$(PYTHON) -m flake8 . --count --exclude=./.*,scripts/20*,vendor*,node_modules/* --exit-zero --max-complexity=10 --max-line-length=$(GITHUB_EDITOR_WIDTH) --statistics
endif
test:
npm test
pytest openlibrary/tests openlibrary/mocks openlibrary/olbase openlibrary/plugins openlibrary/utils openlibrary/catalog openlibrary/coverstore