File: rules

package info (click to toggle)
pytorch 1.7.1-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 80,340 kB
  • sloc: cpp: 670,830; python: 343,991; ansic: 67,845; asm: 5,503; sh: 2,924; java: 2,888; xml: 266; makefile: 244; ruby: 148; yacc: 144; objc: 51; lex: 44
file content (159 lines) | stat: -rwxr-xr-x 6,889 bytes parent folder | download
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
155
156
157
158
159
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export LC_ALL=C.UTF-8
export PYBUILD_DISABLE_python2 = 1
export PYBUILD_NAME = torch
export SOVERSION = 1.7
export PATCH = 0

# [for debugging purpose]
#export CC=/usr/lib/ccache/gcc
#export CXX=/usr/lib/ccache/g++

# configurations
export CFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS) -gsplit-dwarf
export CXXFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CXXFLAGS) -gsplit-dwarf
export NO_CUDA = 1 # Will never build CUDA version. Use Anaconda/Pip please.
export ONNX_NAMESPACE = onnx
export REL_WITH_DEB_INFO = ON
export USE_CUDA = OFF
export USE_CUDNN = OFF
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el mips64el s390x))
export USE_DISTRIBUTED = ON
else
export USE_DISTRIBUTED = OFF
endif
export USE_FBGEMM = OFF
export USE_FFMPEG = ON
export USE_GFLAGS= ON
export USE_GLOG = ON
export USE_LEVELDB = ON
export USE_LMDB = ON
export USE_MIOPEN = OFF
export USE_MPI = OFF
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el))
export USE_MKLDNN = ON
else
export USE_MKLDNN = OFF
endif
ifneq (,$(filter $(DEB_HOST_ARCH),amd64))
export USE_PYTORCH_QNNPACK = ON
else
export USE_PYTORCH_QNNPACK = OFF
endif
export USE_NNPACK = OFF
export USE_OPENCV = ON
export USE_QNNPACK = OFF
export USE_REDIS = OFF
export USE_ROCM = OFF
export USE_SYSTEM_LIBS = ON
export USE_SYSTEM_NCCL = OFF
export USE_TENSORPIPE = ON
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64))
export USE_XNNPACK = ON
else
export USE_XNNPACK = OFF
endif
export USE_ZMQ = ON
export USE_ZSTD = ON

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
export MAX_JOBS := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

# Customization options (You may want to rebuild this package locally)
NATIVE :=
ifneq (,$(NATIVE))
export CFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS) -gsplit-dwarf -march=native
export CXXFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CXXFLAGS) -gsplit-dwarf -march=native
endif


%:
	dh $@ -Spybuild --with python3

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

override_dh_auto_configure:
	cd third_party/; rmdir googletest; ln -s /usr/src/googletest .

override_dh_auto_build:
	: # In order to avoid building everything twice.

override_dh_auto_test:
	:

override_dh_auto_install:
	$(shell py3versions -d) setup.py install --install-layout=deb \
		--root=$(shell pwd)/debian/python3-torch/
	# [python3-torch::headers -> libtorch-dev] move the headers out of the python package
	mkdir -pv debian/libtorch-dev/usr/include
	mv -v debian/python3-torch/usr/lib/python3*/dist-packages/torch/include/* \
		debian/libtorch-dev/usr/include/
	cd debian/python3-torch/usr/lib/python3*/dist-packages/torch/include/; \
		ln -sv /usr/include/torch . ;\
		ln -sv /usr/include/caffe2 . ;\
		ln -sv /usr/include/ATen . ;\
		ln -sv /usr/include/c10 . ;\
		ln -sv /usr/include/TH .
	# [python3-torch::shlibs -> libtorch$(SOVERSION)] move the (public) shared libs out of the python package
	mkdir -pv debian/libtorch$(SOVERSION)/usr/lib/$(DEB_HOST_MULTIARCH)/
	mv -v debian/python3-torch/usr/lib/python3*/dist-packages/torch/lib/*.so.* \
		debian/libtorch$(SOVERSION)/usr/lib/$(DEB_HOST_MULTIARCH)/
	cd debian/libtorch$(SOVERSION)/usr/lib/$(DEB_HOST_MULTIARCH)/; \
		ln -sfv libc10.so.$(SOVERSION).$(PATCH) libc10.so.$(SOVERSION) ;\
		ln -sfv libcaffe2_detectron_ops.so.$(SOVERSION).$(PATCH) libcaffe2_detectron_ops.so.$(SOVERSION) ;\
		ln -sfv libcaffe2_module_test_dynamic.so.$(SOVERSION).$(PATCH) libcaffe2_module_test_dynamic.so.$(SOVERSION) ;\
		ln -sfv libcaffe2_observers.so.$(SOVERSION).$(PATCH) libcaffe2_observers.so.$(SOVERSION) ;\
		ln -sfv libshm.so.$(SOVERSION).$(PATCH) libshm.so.$(SOVERSION) ;\
		ln -sfv libtorch_cpu.so.$(SOVERSION).$(PATCH) libtorch_cpu.so.$(SOVERSION) ;\
		ln -sfv libtorch_python.so.$(SOVERSION).$(PATCH) libtorch_python.so.$(SOVERSION) ;\
		ln -sfv libtorch.so.$(SOVERSION).$(PATCH) libtorch.so.$(SOVERSION) ;\
		ln -sfv libtorch_global_deps.so.$(SOVERSION).$(PATCH) libtorch_global_deps.so.$(SOVERSION)
	# [python3-torch::symlinks -> libtorch-dev] move the links to shared libs out of the python package
	mkdir -pv debian/libtorch-dev/usr/lib/$(DEB_HOST_MULTIARCH)/
	cd debian/python3-torch/usr/lib/python3*/dist-packages/torch/lib ; $(RM) -v *.so;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libc10.so.$(SOVERSION) libc10.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libcaffe2_detectron_ops.so.$(SOVERSION) libcaffe2_detectron_ops.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libcaffe2_module_test_dynamic.so.$(SOVERSION) libcaffe2_module_test_dynamic.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libcaffe2_observers.so.$(SOVERSION) libcaffe2_observers.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libshm.so.$(SOVERSION) libshm.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libtorch_cpu.so.$(SOVERSION) libtorch_cpu.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libtorch_python.so.$(SOVERSION) libtorch_python.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libtorch.so.$(SOVERSION) libtorch.so ;\
		ln -sv  ../../../../$(DEB_HOST_MULTIARCH)/libtorch_global_deps.so.$(SOVERSION) libtorch_global_deps.so
	cd debian/libtorch-dev/usr/lib/$(DEB_HOST_MULTIARCH)/; \
		ln -sfv libc10.so.$(SOVERSION) libc10.so ;\
		ln -sfv libcaffe2_detectron_ops.so.$(SOVERSION) libcaffe2_detectron_ops.so ;\
		ln -sfv libcaffe2_module_test_dynamic.so.$(SOVERSION) libcaffe2_module_test_dynamic.so ;\
		ln -sfv libcaffe2_observers.so.$(SOVERSION) libcaffe2_observers.so ;\
		ln -sfv libshm.so.$(SOVERSION) libshm.so ;\
		ln -sfv libtorch_cpu.so.$(SOVERSION) libtorch_cpu.so ;\
		ln -sfv libtorch_python.so.$(SOVERSION) libtorch_python.so ;\
		ln -sfv libtorch.so.$(SOVERSION) libtorch.so ;\
		ln -sfv libtorch_global_deps.so.$(SOVERSION) libtorch_global_deps.so
	# [python3-torch::cmake -> libtorch-dev] move the cmake files out of the python package
	mkdir -pv debian/libtorch-dev/usr/lib/$(DEB_HOST_MULTIARCH)/
	mv -v debian/python3-torch/usr/lib/python3*/dist-packages/torch/share/cmake \
		debian/libtorch-dev/usr/lib/$(DEB_HOST_MULTIARCH)/
	# [python3-torch::testbin -> libtorch-test] move the test binaries out of the python packaage
	mkdir -pv debian/libtorch-test/usr/lib/libtorch-test/
	mv -v debian/python3-torch/usr/lib/python3*/dist-packages/torch/test/* \
		debian/libtorch-test/usr/lib/libtorch-test/
	rmdir -v debian/python3-torch/usr/lib/python3*/dist-packages/torch/test
	cd debian/python3-torch/usr/lib/python3*/dist-packages/torch/ ;\
		ln -s /usr/lib/libtorch-test test


override_dh_python3:
	dh_python3 --requires=requirements.txt --no-ext-rename
	dh_numpy3

override_dh_auto_clean:
	-$(RM) -r build*
	-$(RM) -f third_party/googletest

override_dh_dwz:
	: # FTBFS