-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (121 loc) · 6.52 KB
/
Makefile
File metadata and controls
155 lines (121 loc) · 6.52 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
######################################################################
# Rules for compiling python-rpn into a standalone package, for use outside
# the CMC network.
# See README.md for proper usage.
RPNPY_VERSION = 2.1-rc11
# Wheel files use slightly different version syntax.
RPNPY_VERSION_WHEEL = 2.1rc11
all: sdist wheels
# This rule bootstraps the build process to run in a docker container for each
# supported platform.
wheels: docker
$(MAKE) init && sudo docker run --rm -v $(PWD):/io -it rpnpy-windows-build bash -c 'cd /io && $(MAKE) _wheel PLATFORM=win32'
$(MAKE) init && sudo docker run --rm -v $(PWD):/io -it rpnpy-windows-build bash -c 'cd /io && $(MAKE) _wheel PLATFORM=win_amd64'
$(MAKE) init && sudo docker run --rm -v $(PWD):/io -it rpnpy-manylinux2010_x86_64-build bash -c 'cd /io && $(MAKE) _wheel PLATFORM=manylinux2010_x86_64'
# Rule for generating images from Dockerfiles.
# This sets up a clean build environment to reduce the likelihood that
# something goes wrong at build-time or run-time.
docker: dockerfiles/windows/Dockerfile dockerfiles/manylinux2010_x86_64-build/Dockerfile dockerfiles/test_from_wheel/Dockerfile dockerfiles/test_from_sdist/Dockerfile
sudo docker pull ubuntu:16.04
sudo docker build --tag rpnpy-windows-build dockerfiles/windows
sudo docker pull quay.io/pypa/manylinux2010_x86_64
sudo docker build --tag rpnpy-manylinux2010_x86_64-build dockerfiles/manylinux2010_x86_64-build
sudo docker build --tag rpnpy-test-from-wheel dockerfiles/test_from_wheel
sudo docker build --tag rpnpy-test-from-sdist dockerfiles/test_from_sdist
# Rule for generating a Dockerfile.
# Fills in userid/groupid information specific to the host system.
# This information is used to create an equivalent user within the docker
# container, so that any files copied out of the container have the correct
# permissions.
%/Dockerfile: %/Dockerfile.template
sed 's/$$GID/'`id -g`'/;s/$$GROUP/'`id -ng`'/;s/$$UID/'`id -u`'/;s/$$USER/'`id -nu`'/' $< > $@
clean-submodules:
git submodule foreach git clean -xdf .
git submodule foreach git reset --hard HEAD
fetch: clean-submodules
git submodule foreach git fetch --tags
clean: clean-submodules
rm -Rf wheelhouse/ dockerfiles/*/Dockerfile
rm -Rf build/
distclean: clean
rm -Rf cache/
# Rule for initializing the build process to do a fresh build.
init: clean-submodules
git submodule update --init --recursive
cd python-rpn && patch -p1 < $(PWD)/patches/python-rpn.patch
cd python-rpn/lib/rpnpy && ln -s ../../../python-rpn-libsrc _sharedlibs
touch $@
# Check PLATFORM to determine the build environment
ifeq ($(PLATFORM),manylinux2010_x86_64)
export CC = gcc
export FC = gfortran
else ifeq ($(PLATFORM),win_amd64)
export CC = x86_64-w64-mingw32-gcc
export FC = x86_64-w64-mingw32-gfortran
export FFLAGS = -lws2_32 -lpthread
export SHAREDLIB_SUFFIX = dll
else ifeq ($(PLATFORM),win32)
export CC = i686-w64-mingw32-gcc
export FC = i686-w64-mingw32-gfortran
export FFLAGS = -lws2_32 -lpthread
export SHAREDLIB_SUFFIX = dll
endif
.PHONY: all _wheel wheels sdist clean clean-submodules distclean docker native test _test fetch init
######################################################################
# Rule for building the wheel file.
RETAGGED_WHEEL = eccc_rpnpy-$(RPNPY_VERSION_WHEEL)-py2.py3-none-$(PLATFORM).whl
# Linux builds should be done in the manylinux containers.
ifneq (,$(findstring manylinux,$(PLATFORM)))
PYTHON=/opt/python/cp36-cp36m/bin/python
endif
PYTHON ?= python2
_wheel:
# Use setup.py to build the shared libraries and create the wheel file.
# Pass in any extra shared libraries needed for the wheel.
cd python-rpn && env EXTRA_LIBS="$(EXTRA_LIBS)" $(PYTHON) setup.py clean bdist_wheel --dist-dir $(PWD)/wheelhouse --plat-name $(PLATFORM)
# Build a native wheel file (using host OS, assuming it's Linux-based).
native: init
# Use setup.py to build the shared libraries and create the wheel file.
# Pass in any extra shared libraries needed for the wheel.
cd python-rpn && env EXTRA_LIBS="$(EXTRA_LIBS)" $(PYTHON) setup.py clean bdist_wheel --dist-dir $(PWD)/wheelhouse
######################################################################
# libgfortran and related libraries which are needed at runtime.
ifeq ($(PLATFORM),manylinux2010_x86_64)
EXTRA_LIBS = /usr/lib64/libgfortran.so.5 \
/usr/lib64/libquadmath.so.0
else ifeq ($(PLATFORM),win_amd64)
EXTRA_LIB_SRC1 = /usr/lib/gcc/x86_64-w64-mingw32/5.3-win32
EXTRA_LIB_SRC2 = /usr/x86_64-w64-mingw32/lib
EXTRA_LIBS = $(EXTRA_LIB_SRC1)/libgcc_s_seh-1.dll \
$(EXTRA_LIB_SRC1)/libgfortran-3.dll \
$(EXTRA_LIB_SRC1)/libquadmath-0.dll \
$(EXTRA_LIB_SRC2)/libwinpthread-1.dll
else ifeq ($(PLATFORM),win32)
EXTRA_LIB_SRC1 = /usr/lib/gcc/i686-w64-mingw32/5.3-win32
EXTRA_LIB_SRC2 = /usr/i686-w64-mingw32/lib
EXTRA_LIBS = $(EXTRA_LIB_SRC1)/libgcc_s_sjlj-1.dll \
$(EXTRA_LIB_SRC1)/libgfortran-3.dll \
$(EXTRA_LIB_SRC1)/libquadmath-0.dll \
$(EXTRA_LIB_SRC2)/libwinpthread-1.dll
endif
######################################################################
# Rules for generated a bundled source distribution.
sdist: init
cd python-rpn && $(PYTHON) setup.py clean sdist --formats=zip --dist-dir $(PWD)/wheelhouse/
######################################################################
# Rules for doing quick tests on the wheels.
test:
sudo docker run --rm -v $(PWD):/io -it rpnpy-test-from-wheel bash -c 'cd /io && $(MAKE) _test WHEEL=wheelhouse/eccc_rpnpy-$(RPNPY_VERSION_WHEEL)-py2.py3-none-manylinux2010_x86_64.whl PYTHON=python2'
sudo docker run --rm -v $(PWD):/io -it rpnpy-test-from-wheel bash -c 'cd /io && $(MAKE) _test WHEEL=wheelhouse/eccc_rpnpy-$(RPNPY_VERSION_WHEEL)-py2.py3-none-manylinux2010_x86_64.whl PYTHON=python3'
sudo docker run --rm -v $(PWD):/io -it rpnpy-test-from-sdist bash -c 'cd /io && $(MAKE) _test WHEEL=wheelhouse/eccc_rpnpy-$(RPNPY_VERSION_WHEEL).zip PYTHON=python2'
sudo docker run --rm -v $(PWD):/io -it rpnpy-test-from-sdist bash -c 'cd /io && $(MAKE) _test WHEEL=wheelhouse/eccc_rpnpy-$(RPNPY_VERSION_WHEEL).zip PYTHON=python3'
RPNPY_TESTS_WHEEL = wheelhouse/eccc_rpnpy_tests-$(RPNPY_VERSION_WHEEL).zip
# Test with reduced data from eccc-rpnpy-tests package.
_test: $(RPNPY_TESTS_WHEEL)
mkdir -p cache/py
virtualenv -p $(PYTHON) /tmp/myenv
/tmp/myenv/bin/pip install $(PWD)/$(WHEEL) --cache-dir=cache/py
/tmp/myenv/bin/pip install $(PWD)/$(RPNPY_TESTS_WHEEL) --cache-dir=cache/py
cd /tmp && /tmp/myenv/bin/rpy.tests
$(RPNPY_TESTS_WHEEL):
wget ftp://crd-data-donnees-rdc.ec.gc.ca/pub/CCMR/mneish/wheelhouse/$(notdir $@) -P $(dir $@)