diff --git a/Changelog.md b/Changelog.md index 7999de6b..8d3aa6af 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented here. ## [unreleased] +- Update python, pyta and jupyter testers to allow a requirements file (#580) ## [v2.6.0] - Update python versions in docker file (#568) diff --git a/server/autotest_server/testers/jupyter/settings_schema.json b/server/autotest_server/testers/jupyter/settings_schema.json index 74b98425..f425b1bc 100644 --- a/server/autotest_server/testers/jupyter/settings_schema.json +++ b/server/autotest_server/testers/jupyter/settings_schema.json @@ -25,6 +25,10 @@ "pip_requirements": { "title": "Package requirements", "type": "string" + }, + "pip_requirements_file": { + "title": "Package requirements file", + "type": "string" } } }, diff --git a/server/autotest_server/testers/jupyter/setup.py b/server/autotest_server/testers/jupyter/setup.py index 2f77cace..56bfbb36 100644 --- a/server/autotest_server/testers/jupyter/setup.py +++ b/server/autotest_server/testers/jupyter/setup.py @@ -11,7 +11,11 @@ def create_environment(settings_, env_dir, _default_env_dir): requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt") pip = os.path.join(env_dir, "bin", "pip") subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True) - subprocess.run([pip, "install", "-r", requirements, *pip_requirements], check=True) + pip_install_command = [pip, "install", "-r", requirements, *pip_requirements] + if env_data.get("pip_requirements_file"): + pip_install_command.append("-r") + pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file"))) + subprocess.run(pip_install_command, check=True) return {"PYTHON": os.path.join(env_dir, "bin", "python3")} diff --git a/server/autotest_server/testers/py/settings_schema.json b/server/autotest_server/testers/py/settings_schema.json index dfb9bb2b..b5e1f381 100644 --- a/server/autotest_server/testers/py/settings_schema.json +++ b/server/autotest_server/testers/py/settings_schema.json @@ -25,6 +25,10 @@ "pip_requirements": { "title": "Package requirements", "type": "string" + }, + "pip_requirements_file": { + "title": "Package requirements file", + "type": "string" } } }, diff --git a/server/autotest_server/testers/py/setup.py b/server/autotest_server/testers/py/setup.py index 2f77cace..56bfbb36 100644 --- a/server/autotest_server/testers/py/setup.py +++ b/server/autotest_server/testers/py/setup.py @@ -11,7 +11,11 @@ def create_environment(settings_, env_dir, _default_env_dir): requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt") pip = os.path.join(env_dir, "bin", "pip") subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True) - subprocess.run([pip, "install", "-r", requirements, *pip_requirements], check=True) + pip_install_command = [pip, "install", "-r", requirements, *pip_requirements] + if env_data.get("pip_requirements_file"): + pip_install_command.append("-r") + pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file"))) + subprocess.run(pip_install_command, check=True) return {"PYTHON": os.path.join(env_dir, "bin", "python3")} diff --git a/server/autotest_server/testers/pyta/settings_schema.json b/server/autotest_server/testers/pyta/settings_schema.json index 3983c486..f73ac004 100644 --- a/server/autotest_server/testers/pyta/settings_schema.json +++ b/server/autotest_server/testers/pyta/settings_schema.json @@ -26,6 +26,10 @@ "title": "Package requirements", "type": "string" }, + "pip_requirements_file": { + "title": "Package requirements file", + "type": "string" + }, "pyta_version": { "title": "PyTA version", "type": "string", diff --git a/server/autotest_server/testers/pyta/setup.py b/server/autotest_server/testers/pyta/setup.py index 535e0ceb..4747273a 100644 --- a/server/autotest_server/testers/pyta/setup.py +++ b/server/autotest_server/testers/pyta/setup.py @@ -17,7 +17,11 @@ def create_environment(settings_, env_dir, _default_env_dir): requirements = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt") pip = os.path.join(env_dir, "bin", "pip") subprocess.run([f"python{python_version}", "-m", "venv", "--clear", env_dir], check=True) - subprocess.run([pip, "install", "-r", requirements, *env_properties], check=True) + pip_install_command = [pip, "install", "-r", requirements, *env_properties] + if env_data.get("pip_requirements_file"): + pip_install_command.append("-r") + pip_install_command.append(os.path.join(env_dir, "../", "files", env_data.get("pip_requirements_file"))) + subprocess.run(pip_install_command, check=True) return {"PYTHON": os.path.join(env_dir, "bin", "python3")}