diff --git a/src/bsk_rl/__init__.py b/src/bsk_rl/__init__.py index ccb89ef8..cd711e48 100644 --- a/src/bsk_rl/__init__.py +++ b/src/bsk_rl/__init__.py @@ -1,5 +1,7 @@ from gymnasium.envs.registration import register +from bsk_rl.check_bsk_version import check_bsk_version + register(id="SimpleEOS-v0", entry_point="bsk_rl.envs.simple_eos.gym_env:SimpleEOS") register( @@ -33,3 +35,6 @@ id="SingleSatelliteTasking-v1", entry_point="bsk_rl.envs.general_satellite_tasking.gym_env:SingleSatelliteTasking", ) + + +check_bsk_version() diff --git a/src/bsk_rl/bsk_version_req.txt b/src/bsk_rl/bsk_version_req.txt new file mode 100644 index 00000000..cb47f847 --- /dev/null +++ b/src/bsk_rl/bsk_version_req.txt @@ -0,0 +1 @@ +2.2.1b0 \ No newline at end of file diff --git a/src/bsk_rl/check_bsk_version.py b/src/bsk_rl/check_bsk_version.py new file mode 100644 index 00000000..0669aceb --- /dev/null +++ b/src/bsk_rl/check_bsk_version.py @@ -0,0 +1,35 @@ +import os +from warnings import warn + +from pkg_resources import ( + DistributionNotFound, + VersionConflict, + get_distribution, + require, +) + + +def check_bsk_version(): + f = open( + os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "bsk_version_req.txt", + ), + "r", + ) + BSK_VERSION = f.read().strip() + try: + require(f"Basilisk>={BSK_VERSION}") + except VersionConflict: + warn( + f"Basilisk>={BSK_VERSION} is required for full functionality. " + f"Currently installed: {get_distribution('Basilisk').version}", + # ImportWarning, + ) + except DistributionNotFound as e: + e._template = ( + "The '{self.req}' distribution was not found " + "and is required by {self.requirers_str}. Install from " + "http://hanspeterschaub.info/basilisk/." + ) + raise e diff --git a/src/bsk_rl/finish_install.py b/src/bsk_rl/finish_install.py index 41f5e8aa..be45eaec 100644 --- a/src/bsk_rl/finish_install.py +++ b/src/bsk_rl/finish_install.py @@ -6,6 +6,8 @@ import requests +from bsk_rl.check_bsk_version import check_bsk_version + def pck_install(): subprocess.check_call( @@ -29,3 +31,5 @@ def pck_install(): / "scenario" / "simplemaps_worldcities" ) + + check_bsk_version()