This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 139
/
docker.make
110 lines (92 loc) · 3.68 KB
/
docker.make
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
# This makefile is executed from inside the docker container.
HERE = $(shell pwd)
PYTHON = $(shell which python)
PIP = $(shell which pip)
VENDOR = $(HERE)/vendor
TEST_DATA = $(HERE)/ichnaea/tests/data
DATAMAPS_COMMIT = 76e620adabbedabd6866b23b30c145b53bae751e
DATAMAPS_NAME = datamaps-$(DATAMAPS_COMMIT)
DATAMAPS_DIR = $(VENDOR)/$(DATAMAPS_NAME)
LIBMAXMIND_VERSION = 1.4.2
LIBMAXMIND_NAME = libmaxminddb-$(LIBMAXMIND_VERSION)
LIBMAXMIND_DIR = $(VENDOR)/$(LIBMAXMIND_NAME)
TESTS ?= ichnaea
ifeq ($(TESTS), ichnaea)
TEST_ARG = --cov-config=.coveragerc --cov=ichnaea ichnaea
else
TEST_ARG = $(TESTS)
endif
.PHONY: all build_datamaps build_libmaxmind build_deps \
build_python_deps build_ichnaea build_check \
docs
.PHONY: help
help: all
all:
@echo "Usage: make RULE"
@echo ""
@echo "make rules:"
@echo ""
@echo " build_deps - build datamaps and libmaxmind"
@echo " build_python_deps - install and check python dependencies"
@echo " build_geocalc - compile and install geocalclib"
@echo " check - check that C libraries are available to Python"
@echo " update_vendored - update libraries and test data"
@echo ""
@echo " build_datamaps - build datamaps binaries"
@echo " build_libmaxmind - build libmaxmind library"
@echo " update_datamaps - update datamaps source"
@echo " update_libmaxmind - update libmaxmind source"
@echo " update_test_data - update MaxMind DB test data"
@echo ""
@echo " help - see this text"
build_datamaps:
cd $(VENDOR); tar zxf $(DATAMAPS_NAME).tar.gz
cd $(DATAMAPS_DIR); make -s all
cp $(DATAMAPS_DIR)/encode /usr/local/bin/
cp $(DATAMAPS_DIR)/enumerate /usr/local/bin/
cp $(DATAMAPS_DIR)/merge /usr/local/bin/
cp $(DATAMAPS_DIR)/render /usr/local/bin/
rm -rf $(DATAMAPS_DIR)
build_libmaxmind:
cd $(VENDOR); tar xzf $(LIBMAXMIND_NAME).tar.gz
cd $(LIBMAXMIND_DIR); ./configure && make -s && make install
ldconfig
rm -rf $(LIBMAXMIND_DIR)
build_deps: build_datamaps build_libmaxmind
build_python_deps:
$(PIP) install --no-cache-dir --disable-pip-version-check --require-hashes --no-deps \
-r requirements.txt
$(PIP) check --disable-pip-version-check
build_geocalc:
@which cythonize
cythonize -f geocalclib/geocalc.pyx
cd geocalclib && $(PIP) install --no-cache-dir --disable-pip-version-check .
build_check:
@which encode enumerate merge render pngquant
$(PYTHON) -c "import sys; from shapely import speedups; sys.exit(not speedups.available)"
$(PYTHON) -c "import geocalc"
$(PYTHON) -c "import sys; from ichnaea.geoip import GeoIPWrapper; sys.exit(not GeoIPWrapper('ichnaea/tests/data/GeoIP2-City-Test.mmdb').check_extension())"
$(PYTHON) -c "import sys; from ichnaea.geocode import GEOCODER; sys.exit(not GEOCODER.region(51.5, -0.1) == 'GB')"
.PHONY: update_datamaps
update_datamaps:
cd $(VENDOR) && wget -q \
-O $(DATAMAPS_NAME).tar.gz \
https://github.com/ericfischer/datamaps/archive/$(DATAMAPS_COMMIT).tar.gz
.PHONY: update_libmaxmind
update_libmaxmind:
cd $(VENDOR) && wget -q \
-O $(LIBMAXMIND_NAME).tar.gz \
https://github.com/maxmind/libmaxminddb/releases/download/$(LIBMAXMIND_VERSION)/$(LIBMAXMIND_NAME).tar.gz
.PHONY: update_test_data
update_test_data:
cd $(TEST_DATA) && wget -q \
-O GeoIP2-City-Test.json \
https://raw.githubusercontent.com/maxmind/MaxMind-DB/main/source-data/GeoIP2-City-Test.json && \
wget -q \
-O GeoIP2-City-Test.mmdb \
https://github.com/maxmind/MaxMind-DB/raw/main/test-data/GeoIP2-City-Test.mmdb && \
wget -q \
-O GeoIP2-Connection-Type-Test.mmdb \
https://github.com/maxmind/MaxMind-DB/raw/main/test-data/GeoIP2-Connection-Type-Test.mmdb
.PHONY: update_vendored
update_vendored: update_datamaps update_libmaxmind update_test_data