Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dependencies and made easier docker build #1057

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ launch.json
# Ignore generated files
/build
/cmake_build
/third_party_install
/third_party_build
/doc/build
/dist
/OpenSfM.egg-info
.cache
.pytest_cache
eval
/.env

# Viewer
node_modules
Expand Down
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[submodule "opensfm/src/third_party/pybind11"]
path = opensfm/src/third_party/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "opensfm/src/third_party/gflags"]
path = opensfm/src/third_party/gflags
url = https://github.com/gflags/gflags.git
[submodule "opensfm/src/third_party/glog"]
path = opensfm/src/third_party/glog
url = https://github.com/google/glog.git
[submodule "opensfm/src/third_party/eigen"]
path = opensfm/src/third_party/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "opensfm/src/third_party/ceres-solver"]
path = opensfm/src/third_party/ceres-solver
url = https://github.com/ceres-solver/ceres-solver.git
[submodule "opensfm/src/third_party/SuiteSparse"]
path = opensfm/src/third_party/SuiteSparse
url = https://github.com/DrTimothyAldenDavis/SuiteSparse.git
[submodule "opensfm/src/third_party/tbb"]
path = opensfm/src/third_party/tbb
url = https://github.com/oneapi-src/oneTBB.git
171 changes: 154 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,168 @@
#FROM quay.io/pypa/manylinux2014_x86_64
FROM ubuntu:20.04

ENV PLAT=manylinux_2_31_x86_64
ARG DEBIAN_FRONTEND=noninteractive
ARG TWINE_USERNAME
ARG TWINE_PASSWORD
ENV TWINE_USERNAME=$TWINE_USERNAME
ENV TWINE_PASSWORD=$TWINE_PASSWORD

#RUN apt-get update \
# && apt-get install -y \
# build-essential \
# cmake \
# git \
# libeigen3-dev \
# libopencv-dev \
# libceres-dev \
# python3-dev \
# python3-numpy \
# python3-opencv \
# python3-pip \
# python3-pyproj \
# python3-scipy \
# python3-yaml \
# curl \
# && apt-get clean \
# && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \


#RUN yum install -y opencv opencv-devel \
# blas-devel \
# lapack-devel \
# metis-devel \
# tbb-devel \
# wget \
# openblas-devel \
# atlas-devel \
# suitesparse-devel

# Install apt-getable dependencies
RUN apt-get update \
&& apt-get install -y \
build-essential \
cmake \
git \
libeigen3-dev \
libopencv-dev \
libceres-dev \
python3-dev \
python3-numpy \
python3-opencv \
python3-pip \
python3-pyproj \
python3-scipy \
python3-yaml \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
libblas-dev \
liblapack-dev \
libmetis-dev \
libtbb-dev \
wget \
libopenblas-dev \
libatlas-base-dev \
git \
cmake \
build-essential \
libsuitesparse-dev \
curl

RUN mkdir /source
WORKDIR /source
RUN git clone https://github.com/gflags/gflags.git
WORKDIR /source/gflags/
RUN git checkout tags/v2.2.2
RUN mkdir /source/gflags/build/
WORKDIR /source/gflags/build/
RUN cmake -DCMAKE_CXX_FLAGS="-fPIC" ..
RUN make -j8
RUN make install

WORKDIR /source
RUN git clone https://github.com/google/glog.git
WORKDIR /source/glog
RUN git checkout tags/v0.6.0
RUN mkdir /source/glog/build/
WORKDIR /source/glog/build/
RUN cmake ..
RUN make -j8
RUN make install

WORKDIR /source
RUN git clone https://gitlab.com/libeigen/eigen.git
WORKDIR /source/eigen/
RUN git checkout tags/3.4.0
RUN mkdir build
WORKDIR /source/eigen/build/
RUN cmake ..
RUN make install

#RUN yum install -y lzip
#WORKDIR /source
#RUN wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.lz
#RUN tar -xf gmp-6.3.0.tar.lz
#WORKDIR /source/gmp-6.3.0
#RUN ./configure
#RUN make
#RUN make install
#
#WORKDIR /source
#RUN wget https://www.mpfr.org/mpfr-current/mpfr-4.2.1.tar.xz
#RUN tar -xf mpfr-4.2.1.tar.xz
#WORKDIR /source/mpfr-4.2.1
#RUN ./configure
#RUN make
#RUN make install

#WORKDIR /source
#RUN git clone https://github.com/DrTimothyAldenDavis/SuiteSparse.git
#WORKDIR /source/SuiteSparse
#RUN git checkout tags/v7.7.0
#WORKDIR /source/SuiteSparse/build/
#RUN cmake .. -DBLAS_LIBRARIES=/usr/lib64/libopenblas.so -DLAPACK_LIBRARIES=/usr/lib64/liblapack.so
#RUN cmake --build .
#RUN cmake install

#WORKDIR /source
#RUN git clone https://github.com/google/googletest.git
#WORKDIR /source/googletest
#RUN git checkout tags/release-1.8.1
#RUN mkdir build
#WORKDIR /source/googletest/build
#RUN cmake ..
#RUN make -j4
#RUN make install

WORKDIR /source
RUN git clone https://github.com/ceres-solver/ceres-solver.git
WORKDIR /source/ceres-solver
RUN git checkout tags/2.0.0
RUN mkdir build
WORKDIR /source/ceres-solver/build/
RUN cmake ..
RUN make -j8
RUN make install

WORKDIR /source
RUN git clone https://github.com/NixOS/patchelf.git
WORKDIR /source/patchelf/
RUN git checkout tags/0.16.0
RUN ./bootstrap.sh
RUN ./configure
RUN make
RUN make install


RUN apt-get install -y liblzma-dev libssl-dev libopencv-dev
RUN apt-get install -y libncurses-dev libffi-dev libreadline6-dev libbz2-dev libsqlite3-dev

COPY . /source/OpenSfM
WORKDIR $SFM_DIR
RUN curl https://pyenv.run | bash
RUN /root/.pyenv/bin/pyenv install 3.9.9
RUN /root/.pyenv/bin/pyenv global 3.9.9
ENV PATH=$PATH:/root/.pyenv/versions/3.9.9/bin/
RUN python -m pip install --upgrade pip

WORKDIR /source/OpenSfM
ENV WHEEL_DIR=/source/wheelhouse
ENV SFM_DIR=/source/OpenSfM
COPY . $SFM_DIR

RUN pip3 install -r requirements.txt && \
python3 setup.py build
WORKDIR $SFM_DIR
RUN rm -rf cmake_build
RUN /root/.pyenv/versions/3.9.9/bin/pip install -r requirements.txt
RUN /root/.pyenv/versions/3.9.9/bin/pip wheel $SFM_DIR --no-deps -w $WHEEL_DIR
RUN ls /source/wheelhouse/*.whl | xargs -n 1 -I {} auditwheel repair {} --plat $PLAT -w $WHEEL_DIR
RUN cd ${WHEEL_DIR} && rm -rf *-linux*whl
RUN /root/.pyenv/versions/3.9.9/bin/pip install opensfm --no-index -f $WHEEL_DIR
RUN python -c "import opensfm"
RUN ls /source/wheelhouse/*.whl | xargs -n 1 -I {} python -m twine upload --repository-url "http://pypi.artichoke-labs.ai" {}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ OpenSfM is a Structure from Motion library written in Python. The library serves

Checkout this [blog post with more demos](http://blog.mapillary.com/update/2014/12/15/sfm-preview.html)

## MacOS Install
`brew install qt pyqt boost`

## Getting Started

Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.9'

services:
opensfm:
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile
args:
- TWINE_USERNAME
- TWINE_PASSWORD
image: artichoke/opensfm
environment:
- TWINE_USERNAME
- TWINE_PASSWORD
4 changes: 4 additions & 0 deletions opensfm/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ endif()

# For compiling VLFeat
add_definitions(-DVL_DISABLE_AVX)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# message(STATUS "Detected ARM architecture")
add_definitions( -DVL_DISABLE_SSE2 )
endif()

# Use the version of vlfeat in ./src/third_party/vlfeat
add_definitions(-DINPLACE_VLFEAT)
Expand Down
1 change: 1 addition & 0 deletions opensfm/src/third_party/SuiteSparse
Submodule SuiteSparse added at 24e8e2
1 change: 1 addition & 0 deletions opensfm/src/third_party/ceres-solver
Submodule ceres-solver added at 399cda
1 change: 1 addition & 0 deletions opensfm/src/third_party/eigen
Submodule eigen added at eeac81
1 change: 1 addition & 0 deletions opensfm/src/third_party/gflags
Submodule gflags added at e171aa
1 change: 1 addition & 0 deletions opensfm/src/third_party/glog
Submodule glog added at b33e3b
1 change: 1 addition & 0 deletions opensfm/src/third_party/tbb
Submodule tbb added at 427c25
27 changes: 15 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
cloudpickle==0.4.0
exifread==2.1.2
flask==2.3.2
fpdf2==2.4.6
joblib==0.14.1
cloudpickle>=0.4.0
exifread>=2.1.2
flask>=2.3.2
fpdf2>=2.4.6
joblib>=0.14.1
matplotlib
networkx==2.5
numpy>=1.19
numpy
Pillow>=8.1.1
pyproj>=1.9.5.1
pytest==3.0.7
pytest>=3.0.7
python-dateutil>=2.7
pyyaml==5.4
scipy>=1.10.0
Sphinx==4.2.0
pyyaml>=6.0
scipy
sphinx==4.2.0
six
xmltodict==0.10.2
xmltodict>=0.10.2
wheel
opencv-python==4.5.1.48 ; sys_platform == "win32"
opencv-python>=4.10.0 ; sys_platform == "win32"
opencv-python ; sys_platform == "linux"
twine
sphinx
auditwheel==6.0.0
Loading
Loading