From 749712868395e646203eea45dca3aef4122cb1c5 Mon Sep 17 00:00:00 2001 From: u Date: Jan 02 2025 16:07:30 +0000 Subject: update --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8018c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.osc* + diff --git a/obs-service-py_build.spec b/obs-service-py_build.spec new file mode 100644 index 0000000..06fff17 --- /dev/null +++ b/obs-service-py_build.spec @@ -0,0 +1,41 @@ +Name: obs-service-py_build +Version: 0.0.2 +Release: 0 +Summary: Obs service that will run python -m build +License: GPL-3.0-or-later +URL: https://github.com/huakim-tyk/%{name} +Group: Development/Tools/Building +BuildArch: noarch +BuildRequires: rpm_macro(_obs_service_dir) +Requires: obs-service-run +Requires: python3-build +Requires: python3-hatchling +Requires: python3-setuptools +Requires: python3-setuptools_scm +Requires: python3-toml +Requires: python3-wheel +Requires: python3-poetry +Requires: python3-pdm +Requires: python3-hatch_vcs +Requires: python3-flit-core +Source0: py_build +Source1: py_build.service +%description +%{summary}. + +%install +%define file %{_obs_service_dir}/py_build +%define script %{buildroot}%{file} +mkdir -p %{buildroot}%{_obs_service_dir} + +cp %{SOURCE0} %{script} +cp %{SOURCE1} %{script}.service + +%post +%postun + +%files +%attr(755, root, root) %{file} +%attr(644, root, root) %{file}.service + +%changelog diff --git a/py_build b/py_build new file mode 100644 index 0000000..9b27aef --- /dev/null +++ b/py_build @@ -0,0 +1,33 @@ +#!/usr/bin/python3 +from build.__main__ import main +import argparse +import sys +from pathlib import Path +from os import getcwd +import glob +parser_generate = argparse.ArgumentParser(description='generate RPM spec or DEB dsc file from a package') +parser_generate.add_argument('--source', help='source directory (defaults to current directory)', default=getcwd()) +parser_generate.add_argument('--outdir', help='source directory (defaults to current directory)', default=getcwd()) +parser_generate.add_argument('--version', help='package version (optional)', default='disable', choices=['enable', 'disable']) +parser_generate.add_argument('--noop', default='disable', choices=['enable', 'disable'], help='do nothing') +parser_generate.add_argument('--sdist', default='enable', choices=['enable', 'disable'], help='build a source distribution (disables the default behavior)') +parser_generate.add_argument('--wheel', default='enable', choices=['enable', 'disable'], help='build a wheel (disables the default behavior)') +parser_generate.add_argument('--no-isolation', default='enable', choices=['enable', 'disable'], help='Build the project in an isolated virtual environment') +parser_generate.add_argument('--config-setting', action='append', help='KEY[=VALUE] - settings to pass to the backend. Multiple settings can be provided. Settings beginning with a hyphen will erroneously be interpreted as options to build if separated by a space character; use ``--config-setting=--my-setting -C--my-other-setting``') + +args = parser_generate.parse_args(sys.argv[1:]) +if (args.noop == 'enable') or (args.wheel == args.sdist == 'disable'): + exit(0) + +outdir = str(Path(args.outdir or '.').resolve()) +try: + source = glob.glob(args.source)[0] +except Exception: + raise FileNotFoundError(args.source) + +arg_list = [ '--' + i.replace('_','-') for i in ['sdist', 'wheel', 'no_isolation', 'version'] if getattr(args, i) == 'enable' ] + [ '--config-setting='+i for i in (args.config_setting or []) ] + [ '--outdir', outdir, source ] + +try: + main(arg_list, __file__) +except NameError: + main(arg_list, '@commandline') diff --git a/py_build.service b/py_build.service new file mode 100644 index 0000000..f5fb17c --- /dev/null +++ b/py_build.service @@ -0,0 +1,40 @@ + + Use of the python -m build command + Generate an tar ball + + source directory (defaults to current directory) + + + build a source distribution (disables the default behavior) + enable + disable + + + show program's version number and exit + enable + disable + + + build a wheel (disables the default behavior) + enable + disable + + + do not check that build dependencies are installed + enable + disable + + + Build the project in an isolated virtual environment + enable + disable + + + Do nothing + enable + disable + + + KEY[=VALUE] - settings to pass to the backend. Multiple settings can be provided. Settings beginning with a hyphen will erroneously be interpreted as options to build if separated by a space character; use ``--config-setting=--my-setting -C--my-other-setting`` + +