CoolFace
Modelpublic

beverley-gorry/colmap-vslamlab

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
build_windows_app.py103 linesDownload Raw Back to python
1# Copyright (c), ETH Zurich and UNC Chapel Hill.2# All rights reserved.3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions are met:6#7#     * Redistributions of source code must retain the above copyright8#       notice, this list of conditions and the following disclaimer.9#10#     * Redistributions in binary form must reproduce the above copyright11#       notice, this list of conditions and the following disclaimer in the12#       documentation and/or other materials provided with the distribution.13#14#     * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of15#       its contributors may be used to endorse or promote products derived16#       from this software without specific prior written permission.17#18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28# POSSIBILITY OF SUCH DAMAGE.29 30 31import argparse32import glob33import os34import shutil35 36 37def parse_args():38    parser = argparse.ArgumentParser()39    parser.add_argument(40        "--install_path",41        required=True,42        help="The installation prefix, e.g., build/__install__",43    )44    parser.add_argument(45        "--app_path",46        required=True,47        help="The application path, e.g., build/COLMAP-dev-windows",48    )49    args = parser.parse_args()50    return args51 52 53def mkdir_if_not_exists(path):54    assert os.path.exists(os.path.dirname(os.path.abspath(path)))55    if not os.path.exists(path):56        os.makedirs(path)57 58 59def main():60    args = parse_args()61 62    mkdir_if_not_exists(args.app_path)63    mkdir_if_not_exists(os.path.join(args.app_path, "bin"))64    mkdir_if_not_exists(os.path.join(args.app_path, "lib"))65    mkdir_if_not_exists(os.path.join(args.app_path, "lib/platforms"))66 67    # Copy batch scripts to app directory.68    shutil.copyfile(69        os.path.join(args.install_path, "COLMAP.bat"),70        os.path.join(args.app_path, "COLMAP.bat"),71    )72    shutil.copyfile(73        os.path.join(args.install_path, "RUN_TESTS.bat"),74        os.path.join(args.app_path, "RUN_TESTS.bat"),75    )76 77    # Copy executables to app directory.78    exe_files = glob.glob(os.path.join(args.install_path, "bin/*.exe"))79    for exe_file in exe_files:80        shutil.copyfile(81            exe_file,82            os.path.join(args.app_path, "bin", os.path.basename(exe_file)),83        )84 85    # Copy shared libraries to app directory.86    dll_files = glob.glob(os.path.join(args.install_path, "lib/*.dll"))87    for dll_file in dll_files:88        shutil.copyfile(89            dll_file,90            os.path.join(args.app_path, "lib", os.path.basename(dll_file)),91        )92    shutil.copyfile(93        os.path.join(args.install_path, "lib/platforms/qwindows.dll"),94        os.path.join(args.app_path, "lib/platforms/qwindows.dll"),95    )96 97    # Create zip archive for deployment.98    shutil.make_archive(args.app_path, "zip", root_dir=args.app_path)99 100 101if __name__ == "__main__":102    main()103