From 1d7a53625689f67a87755c6664471ad4b9fa883b Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Tue, 10 Dec 2024 10:46:03 -0300 Subject: [PATCH] Fix specfile build --- command_line_assistant/config.py | 1 - packaging/command-line-assistant.spec | 23 ++++++++++++----------- pyproject.toml | 26 +++++++++++++++----------- setup.py | 14 +++++++++++--- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/command_line_assistant/config.py b/command_line_assistant/config.py index 2b7c32d..b1b9b6a 100644 --- a/command_line_assistant/config.py +++ b/command_line_assistant/config.py @@ -13,7 +13,6 @@ except ImportError: import tomli as tomllib # pyright: ignore[reportMissingImports] - CONFIG_DEFAULT_PATH: Path = Path( "~/.config/command-line-assistant/config.toml" ).expanduser() diff --git a/packaging/command-line-assistant.spec b/packaging/command-line-assistant.spec index 85af10c..1995ab5 100644 --- a/packaging/command-line-assistant.spec +++ b/packaging/command-line-assistant.spec @@ -1,3 +1,6 @@ +%global python_package_src command_line_assistant +%global binary_name c + Name: command-line-assistant Version: 0.1.0 Release: 1%{?dist} @@ -11,20 +14,17 @@ BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3-setuptools -# Not needed after RHEL 10 as it is native in Python 3.11+ -%if 0%{?rhel} && 0%{?rhel} < 10 -BuildRequires: python3-tomli -%endif +BuildRequires: python3-wheel +BuildRequires: python3-pip Requires: python3-requests + # Not needed after RHEL 10 as it is native in Python 3.11+ %if 0%{?rhel} && 0%{?rhel} < 10 -Requires: python3-tomli +BuildRequires: python3-tomli +Requires: python3-tomli %endif -%global python_package_src command_line_assistant -%global binary_name c - %description A simple wrapper to interact with RAG @@ -32,16 +32,17 @@ A simple wrapper to interact with RAG %autosetup -n %{name}-%{version} %build -%py3_build +%py3_build_wheel %install -%py3_install +%py3_install_wheel %{python_package_src}-%{version}-py3-none-any.whl %files %doc README.md %license LICENSE %{python3_sitelib}/%{python_package_src}/ -%{python3_sitelib}/%{python_package_src}-*.egg-info/ +%{python3_sitelib}/%{python_package_src}-%{version}.dist-info/ + # Our binary is just called "c" %{_bindir}/%{binary_name} diff --git a/pyproject.toml b/pyproject.toml index 5cbe0d7..6a5b72d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,27 +18,31 @@ requires-python = ">=3.9" # RHEL 9 and 10 readme = "README.md" license = { file = "LICENSE" } classifiers = ["Programming Language :: Python :: 3"] - -[project.urls] -Repository = "https://github.com/rhel-lightspeed/command-line-assistant.git" -Issues = "https://github.com/rhel-lightspeed/command-line-assistant/issues" - -[project.scripts] -c = "command_line_assistant.__main__:main" +urls = { Repository = "https://github.com/rhel-lightspeed/command-line-assistant.git", Issues = "https://github.com/rhel-lightspeed/command-line-assistant/issues" } +scripts = { c = "command_line_assistant.__main__:main" } [build-system] # pdm build is not available in rhel baseos repositories requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" - [dependency-groups] -dev = ["pytest==8.3.4", "pytest-cov==6.0.0", "pytest-randomly==3.16.0", "coverage==7.6.8", "pytest-sugar==1.0.0", "pytest-clarity==1.0.1", "tox>=4.23.2", "tox-pdm>=0.7.2"] +dev = [ + "pytest==8.3.4", + "pytest-cov==6.0.0", + "pytest-randomly==3.16.0", + "coverage==7.6.8", + "pytest-sugar==1.0.0", + "pytest-clarity==1.0.1", + "tox>=4.23.2", + "tox-pdm>=0.7.2", +] # ----- Tooling specifics -[tool.setuptools] -packages = ["command_line_assistant"] +[tool.setuptools.packages.find] +include = ["command_line_assistant*"] +namespaces = false [tool.ruff] # Enable ruff rules to act like flake8 diff --git a/setup.py b/setup.py index 096e9e7..3aa09cc 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import sys -from setuptools import setup +from setuptools import find_packages, setup if sys.version_info >= (3, 11): import tomllib @@ -19,16 +19,24 @@ for script_name, script_path in pyproject_settings["project"]["scripts"].items(): entry_points["console_scripts"].append(f"{script_name} = {script_path}") +description = None +with open( + pyproject_settings["project"]["readme"], mode="r", encoding="utf-8" +) as handler: + description = handler.read() + setup( name=pyproject_settings["project"]["name"], version=pyproject_settings["project"]["version"], author=pyproject_settings["project"]["authors"][0]["name"], author_email=pyproject_settings["project"]["authors"][0]["email"], description=pyproject_settings["project"]["description"], - long_description=open(pyproject_settings["project"]["readme"]).read(), + long_description=description, long_description_content_type="text/markdown", url=pyproject_settings["project"]["urls"]["Repository"], - packages=pyproject_settings["tool"]["setuptools"]["packages"], + packages=find_packages( + include=pyproject_settings["tool"]["setuptools"]["packages"]["find"]["include"] + ), install_requires=pyproject_settings["project"]["dependencies"], entry_points=entry_points, classifiers=pyproject_settings["project"]["classifiers"],