From af3103e25c87724907badee03ff0056939e9bd23 Mon Sep 17 00:00:00 2001 From: ChandanChainani Date: Mon, 10 Oct 2022 16:09:49 +0530 Subject: [PATCH] Migrate setup.py to pyproject.toml (#311) --- 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..6b81da9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "thoth-analyzer" +description = "Analyzer library for project Thoht." +authors = [ + { name="Fridolin Pokorny", email="fridolin@redhat.com" }, +] +license = {text = "GPLv3+"} +readme = "README.rst" +dynamic = ["version", "dependencies"] + +[tool.setuptools.dynamic] +version = {attr = "thoth.analyzer.__version__"} +dependencies = {file = ["requirements.txt"]} + +[tool.setuptools] +zip-safe = false +packages = ["thoth.analyzer"] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..fd48348 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[build_sphinx] +version = attr: thoth.analyzer.__version__ +release = attr: thoth.analyzer.__version__ diff --git a/setup.py b/setup.py deleted file mode 100644 index 578e2be..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Setup config for thoth-analyzer.""" - -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 version of thoth-analyzer.""" - with open(os.path.join("thoth", "analyzer", "__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="thoth-analyzer", - version=VERSION, - description="Analyzer library for project Thoht.", - long_description=Path("README.rst").read_text(), - author="Fridolin Pokorny", - author_email="fridolin@redhat.com", - license="GPLv3+", - packages=[ - "thoth.analyzer", - ], - zip_safe=False, - install_requires=get_install_requires(), - command_options={ - "build_sphinx": { - "version": ("setup.py", VERSION), - "release": ("setup.py", VERSION), - } - }, -)