import tomlkit import pathlib def load_project_settings(project_root): print(project_root) # Read the pyproject.toml file with open(pathlib.Path.joinpath(project_root, "pyproject.toml"), "r") as f: pyproject_content = f.read() # Parse the toml content pyproject = tomlkit.parse(pyproject_content) # Access project settings return { "name": pyproject["tool"]["poetry"]["name"], "version": pyproject["tool"]["poetry"]["version"], "description": pyproject["tool"]["poetry"]["description"], "authors": pyproject["tool"]["poetry"]["authors"], "readme": pyproject["tool"]["poetry"]["authors"], "licence": pyproject["tool"]["poetry"]["license"], "organization": pyproject["project"]["organization"], "classifiers": pyproject["tool"]["poetry"]["classifiers"], "copyright": pyproject["project"]["copyright"], "repository": pyproject["tool"]["poetry"]["repository"], } _root = pathlib.Path(__file__).parent.parent _infodict = load_project_settings(_root) NAME = _infodict["name"] VERSION = _infodict["version"] AUTHORS = _infodict["authors"] COPYRIGHT = _infodict["copyright"] HOMEPAGE = _infodict["repository"] CLASSIFIERS = _infodict["classifiers"] DESCRIPTION = _infodict["description"] ORGANIZATION = _infodict["organization"]