<p><a href="https://github.com/proyvind/rpm/blob/pyspec/python/rpm/generate.py">https://github.com/proyvind/rpm/blob/pyspec/python/rpm/generate.py</a></p>
<p>I'm using it in the python module spec generator (dependent on rpminterp PR, pyspec branch depends on _specfile which is why a new branch were created), where the python script reads the spec file to determine what sections etc. that is defined in the spec or not.</p>
<p>This allows for overriding defaults from the generated spec easily as a regular spec without having to pass extra arguments to the pyspec() function generating the spec.</p>
<p>Default pyspec() example:<br>
$ cat ~/rpmbuild/SPECS/python-pyliblzma.spec<br>
%{python:pyspec("pyliblzma")}</p>
<p>$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec<br>
Name:           python-pyliblzma<br>
Version:        0.5.3<br>
Release:        1<br>
Summary:        Python bindings for liblzma<br>
Source0:        <a href="https://pypi.python.org/packages/17/48/5292ade507dafe573360560ba53783395587dc42eb32b347feb2ac70fc6b/pyliblzma-0.5.3.tar.bz2">https://pypi.python.org/packages/17/48/5292ade507dafe573360560ba53783395587dc42eb32b347feb2ac70fc6b/pyliblzma-0.5.3.tar.bz2</a><br>
License:        LGPLv3<br>
Group:          Development/Python<br>
Url:            <a href="https://launchpad.net/pyliblzma">https://launchpad.net/pyliblzma</a><br>
BuildRequires:  pkgconfig(python-2.7) python-setuptools</p>
<p>%description<br>
PylibLZMA provides a python interface for the liblzma library.<br>
to read and write data that has been compressed or can be decompressed<br>
by Lasse Collin's xz / lzma utils.</p>
<p>%prep<br>
%setup -qDTn pyliblzma-0.5.3</p>
<p>%build<br>
CFLAGS='-O2 -g' python2 setup.py  build --executable='python2 -s'</p>
<p>%install<br>
CFLAGS='-O2 -g' python2 setup.py  install -O1 --skip-build --root /home/peroyvind/rpmbuild/BUILDROOT/python-pyliblzma-0.5.3-1.x86_64</p>
<p>%check<br>
python2 setup.py test</p>
<p>%files<br>
%doc COPYING<br>
%doc NEWS<br>
%doc THANKS<br>
/usr/lib64/python2.7/site-packages/liblzma.py*<br>
/usr/lib64/python2.7/site-packages/lzma.so<br>
/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info</p>
<p>Example with custom sections:<br>
cat ~/rpmbuild/SPECS/python-pyliblzma.spec<br>
Patch0: somepatch.patch<br>
Version: 0.5.2<br>
Release: 2</p>
<p>%{python:pyspec("pyliblzma")}</p>
<p>%build<br>
whoopidoopidoo</p>
<p>%install<br>
somestufff</p>
<p>%check<br>
someotherstuff</p>
<p>$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec<br>
Patch0: somepatch.patch<br>
Version: 0.5.2<br>
Release: 2</p>
<p>Name:           python-pyliblzma<br>
Summary:        Python bindings for liblzma<br>
Source0:        <a href="https://pypi.python.org/packages/79/d7/2ca6de56df030a6be411b664e48cee3a3feaf1312bfa9556fd9abab4dcd1/pyliblzma-0.5.2.tar.bz2">https://pypi.python.org/packages/79/d7/2ca6de56df030a6be411b664e48cee3a3feaf1312bfa9556fd9abab4dcd1/pyliblzma-0.5.2.tar.bz2</a><br>
License:        LGPLv3<br>
Group:          Development/Python<br>
Url:            <a href="https://launchpad.net/pyliblzma">https://launchpad.net/pyliblzma</a><br>
BuildRequires:  pkgconfig(python-2.7) python-setuptools</p>
<p>%description<br>
PylibLZMA provides a python interface for the liblzma library.<br>
to read and write data that has been compressed or can be decompressed<br>
by Lasse Collin's xz / lzma utils.</p>
<p>%prep<br>
%setup -qDTn pyliblzma-0.5.2<br>
/bin/cat /home/peroyvind/rpmbuild/SOURCES/somepatch.patch |<br>
/bin/patch -p1 -s --fuzz=0 -s -U</p>
<p>%files<br>
%doc COPYING<br>
%doc NEWS<br>
%doc THANKS<br>
/usr/lib64/python2.7/site-packages/liblzma.py*<br>
/usr/lib64/python2.7/site-packages/lzma.so<br>
/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info</p>
<p>%build<br>
whoopidoopidoo</p>
<p>%install<br>
somestufff</p>
<p>%check<br>
someotherstuff</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/rpm-software-management/rpm/pull/202#issuecomment-297088253">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ANb800Xc4rCVkBhWc__5NXJ21BEDXKyGks5rziBogaJpZM4NCSFg">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ANb80-xLjhzagHNQmLwwcF0HvYHt_K2Oks5rziBogaJpZM4NCSFg.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/rpm-software-management/rpm/pull/202#issuecomment-297088253"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/rpm-software-management/rpm","title":"rpm-software-management/rpm","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/rpm-software-management/rpm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@proyvind in #202: https://github.com/proyvind/rpm/blob/pyspec/python/rpm/generate.py\r\n\r\nI'm using it in the python module spec generator (dependent on rpminterp PR, pyspec branch depends on _specfile which is why a new branch were created), where the python script reads the spec file to determine what sections etc. that is defined in the spec or not.\r\n\r\nThis allows for overriding defaults from the generated spec easily as a regular spec without having to pass extra arguments to the pyspec() function generating the spec.\r\n\r\nDefault pyspec() example:\r\n$ cat ~/rpmbuild/SPECS/python-pyliblzma.spec \r\n%{python:pyspec(\"pyliblzma\")}\r\n\r\n$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec \r\nName:           python-pyliblzma\r\nVersion:        0.5.3\r\nRelease:        1\r\nSummary:        Python bindings for liblzma\r\nSource0:        https://pypi.python.org/packages/17/48/5292ade507dafe573360560ba53783395587dc42eb32b347feb2ac70fc6b/pyliblzma-0.5.3.tar.bz2\r\nLicense:        LGPLv3\r\nGroup:          Development/Python\r\nUrl:            https://launchpad.net/pyliblzma\r\nBuildRequires:  pkgconfig(python-2.7) python-setuptools\r\n\r\n%description\r\nPylibLZMA provides a python interface for the liblzma library.\r\n        to read and write data that has been compressed or can be decompressed\r\n        by Lasse Collin's xz / lzma utils.\r\n\r\n%prep\r\n%setup -qDTn pyliblzma-0.5.3\r\n\r\n%build\r\nCFLAGS='-O2 -g' python2 setup.py  build --executable='python2 -s'\r\n\r\n%install\r\nCFLAGS='-O2 -g' python2 setup.py  install -O1 --skip-build --root /home/peroyvind/rpmbuild/BUILDROOT/python-pyliblzma-0.5.3-1.x86_64\r\n\r\n%check\r\npython2 setup.py test\r\n\r\n%files\r\n%doc COPYING\r\n%doc NEWS\r\n%doc THANKS\r\n/usr/lib64/python2.7/site-packages/liblzma.py*\r\n/usr/lib64/python2.7/site-packages/lzma.so\r\n/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info\r\n\r\nExample with custom sections:\r\ncat ~/rpmbuild/SPECS/python-pyliblzma.spec \r\nPatch0: somepatch.patch\r\nVersion: 0.5.2\r\nRelease: 2\r\n\r\n%{python:pyspec(\"pyliblzma\")}\r\n\r\n\r\n%build\r\nwhoopidoopidoo\r\n\r\n%install\r\nsomestufff\r\n\r\n%check\r\nsomeotherstuff\r\n\r\n$ rpmspec -P ~/rpmbuild/SPECS/python-pyliblzma.spec\r\nPatch0: somepatch.patch\r\nVersion: 0.5.2\r\nRelease: 2\r\n\r\nName:           python-pyliblzma\r\nSummary:        Python bindings for liblzma\r\nSource0:        https://pypi.python.org/packages/79/d7/2ca6de56df030a6be411b664e48cee3a3feaf1312bfa9556fd9abab4dcd1/pyliblzma-0.5.2.tar.bz2\r\nLicense:        LGPLv3\r\nGroup:          Development/Python\r\nUrl:            https://launchpad.net/pyliblzma\r\nBuildRequires:  pkgconfig(python-2.7) python-setuptools\r\n\r\n%description\r\nPylibLZMA provides a python interface for the liblzma library.\r\n        to read and write data that has been compressed or can be decompressed\r\n        by Lasse Collin's xz / lzma utils.\r\n\r\n%prep\r\n%setup -qDTn pyliblzma-0.5.2\r\n/bin/cat /home/peroyvind/rpmbuild/SOURCES/somepatch.patch | \r\n/bin/patch -p1 -s --fuzz=0 -s -U\r\n\r\n%files\r\n%doc COPYING\r\n%doc NEWS\r\n%doc THANKS\r\n/usr/lib64/python2.7/site-packages/liblzma.py*\r\n/usr/lib64/python2.7/site-packages/lzma.so\r\n/usr/lib64/python2.7/site-packages/pyliblzma*.egg-info\r\n\r\n\r\n%build\r\nwhoopidoopidoo\r\n\r\n%install\r\nsomestufff\r\n\r\n%check\r\nsomeotherstuff\r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/rpm-software-management/rpm/pull/202#issuecomment-297088253"}}}</script>