diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 126e386c..83a5aefe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,20 +12,21 @@ on: jobs: build: - name: ${{ matrix.config.os }} ${{ matrix.config.arch }} + name: ${{ matrix.config.os }} ${{ matrix.config.arch }} with Python ${{ matrix.config.python-version }} runs-on: ${{ matrix.config.os }} strategy: + fail-fast: false matrix: config: [ - {os: ubuntu-latest}, + {os: ubuntu-latest, python-version: "3.8"}, + {os: ubuntu-latest, python-version: "3.9"}, + {os: ubuntu-latest, python-version: "3.10"}, ] env: COMPILER_CACHE_VERSION: 1 COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache CCACHE_BASEDIR: ${{ github.workspace }} - # For faster builds in PRs, skip all but the latest Python versions. - PULL_REQUEST_CIBW_BUILD: cp39-{manylinux}* steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -64,18 +65,54 @@ jobs: libunwind-dev \ xvfb + - name: Set up Python ${{ matrix.config.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.config.python-version }} + - name: Install Python dependencies run: | git submodule update --init --recursive python -m pip install --upgrade pip python -m pip install setuptools - python -m pip install -r requirements.txt # If you have a requirements file - name: Build - run: | - python -m pip install -v . + run: python -m pip install -v . - name: Run Python tests + run: python -c "import limap; print(limap.__version__)" + + - name: Build wheels run: | - python -c "import limap; print(limap.__version__)" + python -m pip install wheel + python setup.py bdist_wheel + env: + CIBW_ARCHS_MACOS: ${{ matrix.config.arch }} + - name: Upload wheel files as artifacts + uses: actions/upload-artifact@v4 + with: + name: limap-${{ matrix.config.os }}-${{ matrix.config.arch }}-cp${{ matrix.config.python-version }} + path: dist/*.whl + + pypi-publish: + name: Publish wheels to PyPI + needs: build + runs-on: ubuntu-latest + # We publish the wheel to pypi when a new tag is pushed, + # either by creating a new GitHub release or explictly with `git tag` + if: ${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags') }} + steps: + - name: Download wheels + uses: actions/download-artifact@v4 + with: + path: ./artifacts/ + - name: Move wheels + run: mkdir ./wheelhouse && mv ./artifacts/**/*.whl ./wheelhouse/ + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + packages-dir: ./wheelhouse/ diff --git a/.gitmodules b/.gitmodules index 98e7cd09..7344c97b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "third-party/pybind11"] path = third-party/pybind11 url = https://github.com/pybind/pybind11.git -[submodule "third-party/Hierarchical-Localization"] - path = third-party/Hierarchical-Localization - url = https://github.com/cvg/Hierarchical-Localization.git [submodule "third-party/RansacLib"] path = third-party/RansacLib url = https://github.com/B1ueber2y/RansacLib.git @@ -11,15 +8,6 @@ [submodule "third-party/HighFive"] path = third-party/HighFive url = https://github.com/B1ueber2y/HighFive.git -[submodule "third-party/pytlsd"] - path = third-party/pytlsd - url = https://github.com/iago-suarez/pytlsd.git -[submodule "third-party/DeepLSD"] - path = third-party/DeepLSD - url = https://github.com/cvg/DeepLSD.git -[submodule "third-party/GlueStick"] - path = third-party/GlueStick - url = https://github.com/cvg/GlueStick.git [submodule "third-party/libigl"] path = third-party/libigl url = https://github.com/libigl/libigl.git diff --git a/README.md b/README.md index 5302048f..fb2d775a 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,9 @@ In this project, we provide interfaces for various geometric operations on 2D/3D ## Installation **Install the dependencies as follows:** +* Python 3.8/9/10 * CMake >= 3.17 -* All dependencies for third-party: COLMAP (will be installed with FetchContent). From [[official guide](https://colmap.github.io/install.html)] +* The following dependencies (many of which are for the third-party COLMAP from its [[official guide](https://colmap.github.io/install.html)]): ```bash sudo apt-get install \ git \ @@ -43,23 +44,13 @@ sudo apt-get install \ qtbase5-dev \ libqt5opengl5-dev \ libcgal-dev \ - libceres-dev -``` -* HDF5 -```bash -sudo apt-get install libhdf5-dev -``` -* Python >= 3.9 + required packages -```bash -git submodule update --init --recursive - -# Refer to https://pytorch.org/get-started/previous-versions/ to install pytorch compatible with your CUDA -python -m pip install torch==1.12.0 torchvision==0.13.0 -python -m pip install -r requirements.txt + libceres-dev \ + libhdf5-dev ``` To install the LIMAP Python package: ``` +git submodule update --init --recursive python -m pip install -Ive . ``` To double check if the package is successfully installed: diff --git a/requirements.txt b/requirements.txt index c038eeac..37bfd734 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ pycolmap ruff==0.6.7 clang-format==19.1.0 -./third-party/pytlsd -./third-party/Hierarchical-Localization -./third-party/DeepLSD -./third-party/GlueStick +pytlsd @ git+https://github.com/iago-suarez/pytlsd.git@37ac583 +hloc @ git+https://github.com/cvg/Hierarchical-Localization.git@abb2520 +deeplsd @ git+https://github.com/cvg/DeepLSD.git@88c589d +gluestick @ git+https://github.com/cvg/GlueStick.git@0f28efd diff --git a/setup.py b/setup.py index f8c5ac3e..14bc8566 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import subprocess import sys -from setuptools import Extension, setup +from setuptools import Extension, find_packages, setup from setuptools.command.build_ext import build_ext # Cores used for building the project @@ -62,17 +62,40 @@ def build_extension(self, ext): ) +# Read requirements from requirements.txt +def parse_requirements_for_limap(filename): + requirements = [] + with open(filename) as f: + requirements = [ + line.strip() + for line in f + if line.strip() + and not line.startswith("#") + and not line.startswith(".") + ] + return requirements + + # The information here can also be placed in setup.cfg - better separation of # logic and declaration, and simpler if you include description/version in # one file. setup( name="limap", version="1.0.0", - author="B1ueber2y", + packages=find_packages(), + python_requires=">=3.8, < 3.11", + install_requires=parse_requirements_for_limap("requirements.txt"), + author="Shaohui Liu", author_email="b1ueber2y@gmail.com", description="A toolbox for mapping and localization with line features", long_description="", ext_modules=[CMakeExtension("_limap")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, + classifiers=[ + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Operating System :: OS Independent", + ], ) diff --git a/third-party/DeepLSD b/third-party/DeepLSD deleted file mode 160000 index 88c589df..00000000 --- a/third-party/DeepLSD +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 88c589dfdd824a94051131cd5bce88588009bebb diff --git a/third-party/GlueStick b/third-party/GlueStick deleted file mode 160000 index 0a6a1ae4..00000000 --- a/third-party/GlueStick +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a6a1ae4569164d8fd1e4d24755d4dec6d9d7d60 diff --git a/third-party/Hierarchical-Localization b/third-party/Hierarchical-Localization deleted file mode 160000 index abb25208..00000000 --- a/third-party/Hierarchical-Localization +++ /dev/null @@ -1 +0,0 @@ -Subproject commit abb252080282e31147db6291206ca102c43353f7 diff --git a/third-party/pytlsd b/third-party/pytlsd deleted file mode 160000 index 37ac5833..00000000 --- a/third-party/pytlsd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 37ac583341cbca74c2bbb1e07b82e1447f7cdf5f