Skip to content

Commit 30a3db1

Browse files
committed
Add spec file
1 parent 7d99833 commit 30a3db1

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

python-pytest-dependency.spec

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
%bcond_without tests
2+
%global distname pytest-dependency
3+
4+
%if 0%{?sle_version} >= 150500
5+
%global pythons python3 python311
6+
%else
7+
%{?!python_module:%define python_module() python3-%{**}}
8+
%define skip_python2 1
9+
%endif
10+
11+
Name: python-%{distname}
12+
Version: $version
13+
Release: 0
14+
Summary: $description
15+
License: Apache-2.0
16+
URL: $url
17+
Group: Development/Languages/Python
18+
Source: https://github.com/RKrahl/pytest-dependency/releases/download/%{version}/%{distname}-%{version}.tar.gz
19+
BuildRequires: %{python_module base >= 3.4}
20+
BuildRequires: %{python_module setuptools}
21+
BuildRequires: fdupes
22+
BuildRequires: python-rpm-macros
23+
%if %{with tests}
24+
BuildRequires: %{python_module distutils-pytest}
25+
BuildRequires: %{python_module pytest >= 3.7}
26+
%endif
27+
Requires: python-pytest >= 3.7
28+
BuildArch: noarch
29+
%python_subpackages
30+
31+
%description
32+
$long_description
33+
34+
35+
%prep
36+
%setup -q -n %{distname}-%{version}
37+
38+
39+
%build
40+
%python_build
41+
42+
43+
%install
44+
%python_install
45+
%fdupes %{buildroot}%{python_sitelib}
46+
47+
48+
%if %{with tests}
49+
%check
50+
%python_expand $$python setup.py test
51+
%endif
52+
53+
54+
%files %{python_files}
55+
%license LICENSE.txt
56+
%doc README.rst
57+
%{python_sitelib}/*
58+
59+
60+
%changelog

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import distutils.command.sdist
1212
import distutils.file_util
1313
from distutils import log
14+
from glob import glob
1415
import os
1516
from pathlib import Path
1617
from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE
@@ -100,6 +101,16 @@ class sdist(copy_file_mixin, distutils.command.sdist.sdist):
100101
def run(self):
101102
self.run_command('meta')
102103
super().run()
104+
subst = {
105+
"version": self.distribution.get_version(),
106+
"url": self.distribution.get_url(),
107+
"description": docstring.split("\n")[0],
108+
"long_description": docstring.split("\n", maxsplit=2)[2].strip(),
109+
}
110+
for spec in glob("*.spec"):
111+
with Path(spec).open('rt') as inf:
112+
with Path(self.dist_dir, spec).open('wt') as outf:
113+
outf.write(string.Template(inf.read()).substitute(subst))
103114

104115
class build_py(copy_file_mixin, setuptools.command.build_py.build_py):
105116
def run(self):

0 commit comments

Comments
 (0)