Skip to content
Snippets Groups Projects
Commit dfd433e6 authored by tuhe's avatar tuhe
Browse files

Test package versions

parent 7e0f4ab9
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ url_install = "https://02465material.pages.compute.dtu.dk/02465public/informatio
sdir = os.path.dirname(__file__)
dry = False
if "02465public" in sdir and "tuhe" in sdir:
dry = True
print("-"*100)
......@@ -45,12 +46,52 @@ except ImportError as e:
print(f"See also {url_install}")
sys.exit(1) # Exit with error code 1
def musttypeok():
# print("Please type 'yes' followed by enter in the command line to continue.")
for k in range(10):
i = input("Please review the problem and type 'yes' followed by enter in the command line to continue regardless.")
if "y" in i or k > 4:
break
try:
import packaging
import numpy
import gymnasium
versions = [("numpy", "2.0.1", numpy.__version__), ("gymnasium", "1.0.0", gymnasium.__version__)]
from packaging.version import Version
for package, required_version, installed_version in versions:
if Version(installed_version) < Version(required_version):
print("!! Warning !!")
print(f"Warning {package} should be at least version {required_version} but I detected that you have {package}={installed_version} installed. Try to run\n")
print(f"conda install {package}>={required_version}")
print("\nIn a terminal to update this package.")
musttypeok()
except Exception as e:
print("Warning, I was unable to import packages that you should have installed on your system. To run the course software you need")
for package, required_version, installed_version in versions:
print(f"numpy>={required_version} (I detected that you have {installed_version} installed)")
print(e)
musttypeok()
except Exception as e:
print("The script was unable to locate an 'irlc' folder. The most likely reason this occurs is that you have moved the location of the script, or that you have deleted the irlc folder. ")
print("The current location of the script is:", sdir)
print("Make sure this folder contains an irlc folder. If you have deleted it, simply start over with the installation instructions. ")
def read_and_extract_zip(url):
# Download the zip file from the URL
base_dir = url.split("/main/")[-1].split(".zip")[0]
response = requests.get(url)
local_students_folder = os.path.dirname(os.path.dirname(__file__))
always_overwrite = ['irlc/update_files.py', 'irlc/__init__.py', 'irlc/tests/*', '**/unitgrade_data/*.pkl', 'irlc/car/*', 'irlc/gridworld/*', 'irlc/pacman/*', 'irlc/utils/*', '*_grade.py', '*/project*_tests.py']
always_overwrite = ['irlc/update_files.py', 'irlc/__init__.py', 'irlc/tests/*', '**/unitgrade_data/*.pkl', 'irlc/car/*', 'irlc/gridworld/*', 'irlc/pacman/*', 'irlc/utils/*', '*_grade.py', '*/project*_tests.py', 'irlc/lectures/*']
# Check if the request was successful (status code 200)
if response.status_code == 200:
zip_content = BytesIO(response.content)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment