#!/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