Skip to content

Commit

Permalink
add requirements.txt and check.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Jun 8, 2024
1 parent 3dc2bce commit 7d174c0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
raccoonlab-tools>=0.1.0
autopilot-tools>=0.4.2
wget>=3.2
44 changes: 44 additions & 0 deletions scripts/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
# This program is free software under the GNU General Public License v3.
# See <https://www.gnu.org/licenses/> for details.
# Author: Dmitry Ponomarev <[email protected]>
"""
This script checks whether the project is ready for use:
- check submodules are initialized
- check python dependencies are installed
"""
import os
import sys
import logging
from pathlib import Path
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import pkg_resources

REPO_DIR = Path(os.path.dirname(os.path.realpath(__file__))).parent.absolute()
BUILD_DIR = os.path.join(REPO_DIR, "build")
SUBMODULE_DIR = os.path.join(REPO_DIR, "uav_dynamics", "uav_hitl_dynamics")

def check_folder_exist_and_not_empty(dir) -> bool:
return os.path.isdir(dir) and os.listdir(dir)

def check_python_requirements(requirements_file='requirements.txt') -> None:
try:
with open(requirements_file, 'r') as f:
requirements = f.read().splitlines()
pkg_resources.require(requirements)
except pkg_resources.DistributionNotFound as e:
logging.error(e)
sys.exit(1)
except pkg_resources.VersionConflict as e:
logging.error(e)
sys.exit(1)

def check_submodules() -> None:
if not check_folder_exist_and_not_empty(SUBMODULE_DIR):
logging.error("submodules not exist. Run: 'git submodule update --init --recursive'")
sys.exit(1)

if __name__ == "__main__":
check_python_requirements()
check_submodules()

0 comments on commit 7d174c0

Please sign in to comment.