diff --git a/.gitignore b/.gitignore index 057bf5b2..7f4f29ac 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ opencv.zip settings.yaml .setupdevenv __pycache__ +*.snap diff --git a/snap/local/usr/lib/python3.6/sitecustomize.py b/snap/local/usr/lib/python3.6/sitecustomize.py new file mode 100644 index 00000000..de2fc656 --- /dev/null +++ b/snap/local/usr/lib/python3.6/sitecustomize.py @@ -0,0 +1,22 @@ +import site +import os + +snap_dir = os.getenv("SNAP") +snapcraft_stage_dir = os.getenv("SNAPCRAFT_STAGE") +snapcraft_part_install = os.getenv("SNAPCRAFT_PART_INSTALL") + +# Do not include snap_dir during builds as this will include +# snapcraft's in-snap site directory. +if snapcraft_stage_dir is not None and snapcraft_part_install is not None: + site_directories = [snapcraft_stage_dir, snapcraft_part_install] +else: + superbuild_dir = os.path.join(snap_dir, 'odm/SuperBuild/install') + site_directories = [snap_dir, superbuild_dir] + +for d in site_directories: + if d: + site_dir = os.path.join(d, "lib/python3.6/site-packages") + site.addsitedir(site_dir) + +if snap_dir: + site.ENABLE_USER_SITE = False \ No newline at end of file diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..6e496d43 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,262 @@ +name: opendronemap +adopt-info: odm +grade: devel +confinement: strict +base: core18 + +summary: Command line toolkit for processing aerial drone imagery +description: > + An open source command line toolkit for processing aerial drone imagery. ODM turns simple 2D images into: + + * Classified Point Clouds + * 3D Textured Models + * Georeferenced Orthorectified Imagery + * Georeferenced Digital Elevation Models + + The application is available for Windows, Mac and Linux and it works from the command line, making it ideal for power users, scripts and for integration with other software. + +# The UbuntuGIS PPA only has i386 and amd64 packages so we can't build any +# other architectures. Therefore let's limit to those here. +architectures: + - build-on: i386 + run-on: i386 + - build-on: amd64 + run-on: amd64 + +# Requires snapcraft to be called with --enable-experimental-package-repositories +# until the feature is released +package-repositories: + - type: apt + ppa: ubuntugis/ubuntugis-unstable + +parts: + odm: + source: . + plugin: nil # We will script everything ourselves + build-environment: + # Set Python location to build host's system so that we can + # use system libraries while building the Snap Package + - PYTHONHOME: /usr + # Set the location for pip to install requirements into inside + # the Snap package + - PYTHONUSERBASE: $SNAPCRAFT_PART_INSTALL + override-build: | + snapcraftctl set-version $(cat VERSION) + + pip3 install --user -r requirements.txt + + # Build the SuperBuild libraries + mkdir -p SuperBuild/build + cd SuperBuild/build + cmake -G Ninja .. + cmake --build . --parallel 1 + + # Build the main ODM project + cd $SNAPCRAFT_PART_BUILD + mkdir -p build + cd build + cmake -G Ninja .. + cmake --build . --parallel $SNAPCRAFT_PARALLEL_BUILD_COUNT + + rsync -av --exclude .git \ + $SNAPCRAFT_PART_BUILD/ $SNAPCRAFT_PART_INSTALL/odm/ + chmod -R u=rwX,go=rX $PYTHONUSERBASE/lib/python* + stage: + # include the libraries and execuables from debian packages + - bin + - lib + - share + - usr/bin + - usr/lib + - usr/share + + # remove deb-based numpy because it conflicts with our pip-installed version + - -usr/lib/python3/dist-packages/numpy + + # include the odm directory ... + - odm + # ... but strip the temporary build files and sources + - -odm/SuperBuild/build/opencv + - -odm/SuperBuild/download + - -odm/SuperBuild/src/ceres + - -odm/SuperBuild/src/entwine + - -odm/SuperBuild/src/gflags + - -odm/SuperBuild/src/hexer + - -odm/SuperBuild/src/lastools + - -odm/SuperBuild/src/laszip + - -odm/SuperBuild/src/mvstexturing + - -odm/SuperBuild/src/opencv + - -odm/SuperBuild/src/opengv + - -odm/SuperBuild/src/pcl + - -odm/SuperBuild/src/pdal + - -odm/SuperBuild/src/zstd + prime: + # remove any static-libraries + - -**/*.a + # remove any header files + - -**/*.h + # remove any left-over temporary compiled 'object' files + - -**/*.o + build-snaps: + - cmake + build-packages: + - build-essential + - gdal-bin + - git + - grass-core + - libboost-log-dev + - libgdal-dev + - libgeotiff-dev + - libjsoncpp-dev + - libssl-dev + - libusb-dev + - ninja-build + - python3-gdal + - python3-pip + - python3-setuptools + - python3-wheel + - rsync + - swig3.0 + # OpenCV + - libavcodec-dev + - libavformat-dev + - libeigen3-dev + - libflann-dev + - libgtk2.0-dev + - libjpeg-dev + - liblapack-dev + - libpng-dev + - libproj-dev + - libswscale-dev + - libtbb-dev + - libtbb2 + - libtiff-dev + - libvtk6-dev + - libxext-dev + - python3-dev + # OpenSfM + - libboost-date-time-dev + - libboost-filesystem-dev + - libboost-iostreams-dev + - libboost-python-dev + - libboost-regex-dev + - libboost-thread-dev + - libgoogle-glog-dev + - libsuitesparse-dev + stage-packages: + - gdal-bin + - grass-core + - libaec0 + - libamd2 + - libasn1-8-heimdal + - libavcodec57 + - libavformat57 + - libboost-filesystem1.65.1 + - libboost-iostreams1.65.1 + - libboost-system1.65.1 + - libboost-thread1.65.1 + - libcamd2 + - libccolamd2 + - libcfitsio5 + - libcharls1 + - libcholmod3 + - libcolamd2 + - libcurl3-gnutls + - libcxsparse3 + - libdap25 + - libdapclient6v5 + - libepsilon1 + - libflann1.9 + - libfontconfig1 + - libfreetype6 + - libfreexl1 + - libfyba0 + - libgdal26 + - libgeos-3.8.0 + - libgeos-c1v5 + - libgeotiff5 + - libgflags2.2 + - libgif7 + - libgomp1 + - libgoogle-glog0v5 + - libgssapi3-heimdal + - libhcrypto4-heimdal + - libhdf4-0-alt + - libhdf5-100 + - libheimbase1-heimdal + - libheimntlm0-heimdal + - libhwloc5 + - libhx509-5-heimdal + - libicu60 + - libjbig0 + - libjpeg-turbo8 + - libjsoncpp1 + - libkmlbase1 + - libkmldom1 + - libkmlengine1 + - libkrb5-26-heimdal + - liblcms2-2 + - libldap-2.4-2 + - libltdl7 + - libmetis5 + - libminizip1 + - libmysqlclient20 + - libnetcdf-c++4 + - libnetcdf13 + - libnghttp2-14 + - libnspr4 + - libnss3 + - libnuma1 + - libodbc1 + - libogdi4.1 + - libopenjp2-7 + - libopenmpi2 + - libpng16-16 + - libpoppler73 + - libpq5 + - libproj19 + - libpsl5 + - libqhull7 + - libroken18-heimdal + - librtmp1 + - libsasl2-2 + - libspatialite7 + - libspqr2 + - libsuitesparseconfig5 + - libsz2 + - libtbb2 + - libtiff5 + - libunwind8 + - liburiparser1 + - libvtk6.3 + - libwebp6 + - libwind0-heimdal + - libxerces-c3.2 + - libxml2 + - odbcinst1debian2 + - procps + - python3-gdal + - python3-setuptools + + snap-specifics: + source: snap/local + plugin: dump + + snapcraft-preload: + source: https://github.com/sergiusens/snapcraft-preload.git + plugin: cmake + build-packages: + - on amd64: + - gcc-multilib + - g++-multilib + +apps: + opendronemap: + command: odm/run.sh + command-chain: + - bin/snapcraft-preload # Fixes multiprocessing python module + plugs: + - home + - network + - network-bind + - removable-media