Files
AutoGPT/classic/original_autogpt/scripts/check_requirements.py
Swifty ef7cfbb860 refactor: AutoGPT Platform Stealth Launch Repo Re-Org (#8113)
Restructuring the Repo to make it clear the difference between classic autogpt and the autogpt platform:
* Move the "classic" projects `autogpt`, `forge`, `frontend`, and `benchmark` into a `classic` folder
  * Also rename `autogpt` to `original_autogpt` for absolute clarity
* Rename `rnd/` to `autogpt_platform/`
  * `rnd/autogpt_builder` -> `autogpt_platform/frontend`
  * `rnd/autogpt_server` -> `autogpt_platform/backend`
* Adjust any paths accordingly
2024-09-20 16:50:43 +02:00

39 lines
1.2 KiB
Python

import contextlib
import os
import sys
from importlib.metadata import version
try:
import poetry.factory # type: ignore # noqa
except ModuleNotFoundError:
os.system(f"{sys.executable} -m pip install 'poetry>=1.6.1,<2.0.0'")
from poetry.core.constraints.version.version import Version # type: ignore
from poetry.factory import Factory # type: ignore
def main():
poetry_project = Factory().create_poetry()
dependency_group = poetry_project.package.dependency_group("main")
missing_packages = []
for dep in dependency_group.dependencies:
if dep.is_optional():
continue
# Try to verify that the installed version is suitable
with contextlib.suppress(ModuleNotFoundError):
installed_version = version(dep.name) # if this fails -> not installed
if dep.constraint.allows(Version.parse(installed_version)):
continue
# If the above verification fails, mark the package as missing
missing_packages.append(str(dep))
if missing_packages:
print("Missing packages:")
print(", ".join(missing_packages))
sys.exit(1)
if __name__ == "__main__":
main()