summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 26d8dc529cf162bdf49830d048374f3df747bb0a (plain)
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
#!/usr/bin/make -f
export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
export PYBUILD_NAME=pytorch
export PYBUILD_DISABLE_python2=1 # No more Python2 Packages
export PYBUILD_DISABLE=test

export DEB_BUILD_OPTIONS+=nocheck
export DEB_BUILD_OPTIONS+=noddebs

export USE_FBGEMM=0
export USE_CUDA=0
export USE_CUDNN=0
export USE_NUMPY=0
export USE_NCCL=0
export BUILD_DOCS=0
export BUILD_TEST=0
# Enable necessary items
export BUILD_CAFFE2_OPS=1
export BUILD_BINARY=1

# Disable QNNPACK for arm64 and armhf as it causes build timeout for both arch
ifneq ($(filter $(DEB_HOST_ARCH),arm64 armhf),)
export USE_MKLDNN=0
export USE_PYTORCH_QNNPACK=OFF
# export MAX_JOBS=1
endif

name = ${PYBUILD_NAME}
topdir = $(shell pwd)
buildroot = ${topdir}/debian/tmp
_libdir ?= /usr/lib
_includedir ?= /usr/include
_sharedir ?= /usr/share
packagingdir = ${topdir}/packaging

THP01=pybind11.tar.gz
THP02=cub.tar.gz
THP03=eigen.tar.gz
THP04=googletest.tar.gz
THP05=benchmark.tar.gz
THP06=protobuf.tar.gz
THP07=ios-cmake.tar.gz
THP08=NNPACK.tar.gz
THP09=gloo.tar.gz
THP10=pthreadpool.tar.gz
THP11=FXdiv.tar.gz
THP12=FP16.tar.gz
THP13=psimd.tar.gz
THP14=zstd.tar.gz
THP15=cpuinfo.tar.gz
THP16=python-enum.tar.gz
THP17=python-peachpy.tar.gz
THP18=python-six.tar.gz
THP19=onnx.tar.gz
THP20=onnx-tensorrt.tar.gz
THP21=sleef.tar.gz
THP22=ideep.tar.gz
THP23=nccl.tar.gz
THP24=gemmlowp.tar.gz
THP25=QNNPACK.tar.gz
THP26=neon2sse.tar.gz
THP27=fbgemm.tar.gz
THP28=fmt.tar.gz
THP29=miniz-2.0.8.tar.gz
THP30=tbb.tar.gz
THP31=tensorpipe.tar.gz
THP32=XNNPACK.tar.gz
THP33=foxi.tar.gz

## Pytorch requires python version >= 3.6.* for build
# Check if os is ubuntu and os-version is greater or equal to 18.04
MIN_OS_MAJOR_VER = 18
MIN_OS_MINOR_VER = 4
UBUNTU = "Ubuntu"
OS_NAME := $(shell sed -n -e '/\<DISTRIB_ID\>/ s/.*\= *//p' /etc/lsb-release)
OS_VER := $(shell sed -n -e '/\<DISTRIB_RELEASE\>/ s/.*\= *//p' /etc/lsb-release)
OS_MAJOR_VER := $(word 1, $(subst ., ,${OS_VER}))
OS_LT_18_04 := $(shell [ $(OS_MAJOR_VER) -lt $(MIN_OS_MAJOR_VER) ] && \
	[ $(OS_NAME) = $(UBUNTU) ] && \
	echo true)

# Default python versions for ubuntu 18.04 and higher is at least 3.6.*
GENCONTROL_PYTHON_VER = python3
PYTHON_VER_ARG =
ifneq ($(strip $(OS_LT_18_04)),)
	# Note: add a PPA which provides this python version
	GENCONTROL_PYTHON_VER = python3.6
	PYTHON_VER_ARG = -p 3.6
endif

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_gencontrol:
	dh_gencontrol -- -Vpython3:Depends=$(GENCONTROL_PYTHON_VER)

override_dh_python3:
	dh_python3 --no-ext-rename

override_dh_auto_clean:
	dh_auto_clean
	-find . -type d -name __pycache__ -exec rm -rf '{}' +

override_dh_auto_test:
	# no tests to be run
	echo "No tests to be run"

override_dh_test:
	# no tests to be run
	echo "No tests to be run"

override_dh_auto_configure:
	tar -xf ${packagingdir}/${THP01} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP02} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP03} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP04} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP05} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP06} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP07} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP08} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP09} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP10} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP11} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP12} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP13} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP14} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP15} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP16} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP17} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP18} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP19} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP20} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP21} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP22} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP23} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP24} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP25} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP26} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP27} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP28} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP29} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP30} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP31} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP32} -C ${topdir}/third_party/
	tar -xf ${packagingdir}/${THP33} -C ${topdir}/third_party/
	dh_testdir
	dh_auto_configure -- $(PYTHON_VER_ARG)

override_dh_auto_install:
	dh_auto_install -- $(PYTHON_VER_ARG)