Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packit config to build rpms in Copr #4

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
specfile_path: packaging/shellai.spec
upstream_package_name: shellai
downstream_package_name: shellai
upstream_project_url: https://github.com/rhel-lightspeed/shellai

srpm_build_deps: []

jobs:
# Build RPMs for each pull request
- job: copr_build
trigger: pull_request
owner: "@rhel-lightspeed"
project: shellai
targets:
- epel-8-x86_64
- epel-9-x86_64
- epel-10-x86_64
actions:
# do not get the version from a tag (git describe) but from the spec file
get-current-version:
- grep -oP '^Version:\s+\K\S+' packaging/shellai.spec

# Build RPMs for main branch
- job: copr_build
trigger: commit
branch: main
owner: "@rhel-lightspeed"
project: shellai
targets:
- epel-8-x86_64
- epel-9-x86_64
- epel-10-x86_64
actions:
# bump spec so we get release starting with 2 and hence all the default branch builds will
# have higher NVR than all the PR builds
post-upstream-clone:
- rpmdev-bumpspec --comment='latest upstream build' ./packaging/shellai.spec
# do not get the version from a tag (git describe) but from the spec file
get-current-version:
- grep -oP '^Version:\s+\K\S+' packaging/shellai.spec
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ clean: ## Clean project files
@find . -name '__pycache__' -exec rm -fr {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@rm -rf .pdm-build .ruff_cache .coverage .pdm-python
@rm -rf .pdm-build .ruff_cache .coverage .pdm-python dist
42 changes: 42 additions & 0 deletions packaging/shellai.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Name: shellai
Version: 0.1.0
Release: 1%{?dist}
Summary: A simple wrapper to interact with RAG

License: Apache-2.0
URL: https://github.com/rhel-lightspeed/shellai
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# noarch because there is no extension module for this package.
BuildArch: noarch

BuildRequires: python3-devel
BuildRequires: python3-setuptools
# Not need after RHEL 10 as it is native in Python 3.11+
%if 0%{?rhel} && 0%{?rhel} < 10
BuildRequires: python3-tomli
%endif

Requires: python3-requests
Requires: python3-pyyaml

%description
A simple wrapper to interact with RAG

%prep
%autosetup -n %{name}-%{version}

%build
%py3_build
r0x0d marked this conversation as resolved.
Show resolved Hide resolved

%install
# TODO(r0x0d): Create config file
%py3_install

%files
%doc README.md
%license LICENSE
%{python3_sitelib}/%{name}/
%{python3_sitelib}/%{name}-*.egg-info/
%{_bindir}/%{name}

%changelog
168 changes: 68 additions & 100 deletions pdm.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ maintainers = [
{ name = "Rodolfo Olivieri", email = "rolivier@redhat.com" },
{ name = "Major Hayden", email = "mhayden@redhat.com" },
]
dependencies = ["requests", "pyyaml"]
requires-python = ">=3.8,<=3.9"
dependencies = [
# tomli is only required below 3.11 as it is native after that version.
'tomli; python_version<"3.11"',
"requests",
"pyyaml",
]
requires-python = ">=3.9" # RHEL 9 and 10
readme = "README.md"
license = { file = "LICENSE" }
classifiers = ["Programming Language :: Python :: 3"]
Expand All @@ -23,11 +28,15 @@ Issues = "https://github.com/rhel-lightspeed/shellai/issues"
shellai = "shellai.__main__:main"

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
# pdm build is not available in rhel baseos repositories
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

# ----- Tooling specifics

[tool.setuptools]
packages = ["shellai"]

[tool.ruff]
# Enable ruff rules to act like flake8
lint.select = [
Expand Down
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Legacy setup.py used mainly for building the RPMs in RHEL 8 and 9.

import sys

from setuptools import setup

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

pyproject_settings = {}
with open("pyproject.toml", "rb") as f:
pyproject_settings = tomllib.load(f)

# We might not have a lot of console scripts in pyproject, but let's compose it as a loop in case we add more in the
# future.
entry_points = {"console_scripts": []}
for script_name, script_path in pyproject_settings["project"]["scripts"].items():
entry_points["console_scripts"].append(f"{script_name} = {script_path}")

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_content_type="text/markdown",
url=pyproject_settings["project"]["urls"]["Repository"],
packages=[pyproject_settings["project"]["name"]],
install_requires=pyproject_settings["project"]["dependencies"],
entry_points=entry_points,
classifiers=pyproject_settings["project"]["classifiers"],
python_requires=pyproject_settings["project"]["requires-python"],
)
3 changes: 2 additions & 1 deletion shellai/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def get_args():
args.history_clear,
args.record,
]
if not args.query_string and (input_data := read_stdin()):
input_data = read_stdin()
if not args.query_string and input_data:
logging.debug("stdin detected")
args.query_string = input_data.strip()

Expand Down
Empty file removed src/shellai/__init__.py
Empty file.