From e9b081f56c04bd7f8187f086ba0b51e0dcec6e50 Mon Sep 17 00:00:00 2001 From: Prathamesh Lohakare Date: Thu, 27 Oct 2022 00:15:21 +0530 Subject: [PATCH] migrated project from setup.py to pyproject.toml --- pyproject.toml | 21 +++++++++++++++++++++ setup.cfg | 3 +++ setup.py | 48 ------------------------------------------------ 3 files changed, 24 insertions(+), 48 deletions(-) create mode 100644 pyproject.toml create mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7549148 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "aicoe-hello-world" +description = "Hello World module of AICoE" +readme = "README.rst" +authors = [ + { name = "Harshad Reddy Nalla", email = "hnalla@redhat.com" } +] +license = { text = "GPLv3+" } +dynamic = [ "version", "dependencies" ] + +[tool.setuptools] +zip-safe = false +packages = ["aicoe.hello_world"] + +[tool.setuptools.dynamic] +version = {attr = "aicoe.hello_world.__version__"} +dependencies = { file = ["requirements.txt"] } diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..7866130 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[build_sphinx] +version = attr: aicoe.hello_world.__version__ +release = attr: aicoe.hello_world.__version__ \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 1f441a5..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Setup for hello world module.""" - -import os - -from setuptools import setup -from pathlib import Path - - -def get_install_requires(): - """Get requirements from requirements.txt.""" - with open("requirements.txt", "r") as requirements_file: - # TODO: respect hashes in requirements.txt file - res = requirements_file.readlines() - return [req.split(" ", maxsplit=1)[0] for req in res if req] - - -def get_version(): - """Get package version.""" - with open(os.path.join("aicoe", "hello_world", "__init__.py")) as f: - content = f.readlines() - - for line in content: - if line.startswith("__version__ ="): - # dirty, remove trailing and leading chars - return line.split(" = ")[1][1:-2] - raise ValueError("No version identifier found") - - -VERSION = get_version() -setup( - name="aicoe-hello-world", - version=VERSION, - description="Hello World module of AICoE", - long_description=Path("README.rst").read_text(), - long_description_content_type="text/x-rst", - author="Harshad Reddy Nalla", - author_email="hnalla@redhat.com", - license="GPLv3+", - packages=["aicoe.hello_world"], - zip_safe=False, - install_requires=get_install_requires(), - command_options={ - "build_sphinx": { - "version": ("setup.py", VERSION), - "release": ("setup.py", VERSION), - } - }, -)