initial import (#1717389)

This commit is contained in:
Patrik Kopkan 2019-07-02 12:41:04 +02:00
parent 044c83788e
commit 162b0ca345
6 changed files with 105 additions and 2 deletions

0
.gitignore vendored Normal file
View File

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright 2019 pyproject-rpm-macros contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,3 +1,40 @@
# pyproject-rpm-macros pyproject RPM macros
====================
This is a provisional implementation of pyproject RPM macros for Fedora 30+.
These macros are useful for packaging Python projects that use the [PEP 517] `pyproject.toml` file, which specifies the package's build dependencies (including the build system, such as setuptools, flit or poetry).
[PEP 517]: https://www.python.org/dev/peps/pep-0517/
Usage
-----
If your upstream sources include `pyproject.toml` and you want to use these macros, BuildRequire them:
BuildRequires: pyproject-rpm-macros
This will bring in python3-devel, so you don't need to require python3-devel explicitly.
Then, build a wheel in %build:
%build
%pyproject_wheel
And install the wheel in %install:
%install
%pyproject_install
Limitations
-----------
`%pyproject_install` currently installs all wheels in `%_builddir`. We are working on a more explicit solution.
This macro changes shebang lines of every Python script in `%{buildroot}%{_bindir}` to `#! %{__python3} %{py3_shbang_opt}` (`#! /usr/bin/python -s`).
We plan to preserve exisiting Python flags in shebangs, but the work is not yet finished.
Currently, the macros do not automatically generate BuildRequires. We are working on that as well.
The pyproject-rpm-macros package

18
macros.pyproject Normal file
View File

@ -0,0 +1,18 @@
%pyproject_wheel() %{expand:\\\
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
%{__python3} -m pip wheel --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --progress-bar off --verbose .
}
%pyproject_install() %{expand:\\\
%{__python3} -m pip install --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed ./*.whl
if [ -e %{buildroot}%{_bindir} ]
then
pathfix.py -pni "%{__python3} %{py3_shbang_opts}" %{buildroot}%{_bindir}/*
fi
if [ -e %{buildroot}%{python3_sitelib}]
sed -i -e 's/pip/rpm/g' %{buildroot}%{python3_sitelib}/*.dist-info/INSTALLER
fi
if [ -e %{buildroot}{python3_sitearch}]
sed -i -e 's/pip/rpm/g' %{buildroot}%{python3_sitearch}/*.dist-info/INSTALLER
}

41
pyproject-rpm-macros.spec Normal file
View File

@ -0,0 +1,41 @@
Name: pyproject-rpm-macros
Version: 0
Release: 1%{?dist}
License: MIT
Source0: macros.pyproject
Source1: README.md
Source2: LICENSE
BuildArch: noarch
Summary: RPM macros for PEP 517 Python packages
Requires: python3-pip >= 19
Requires: python3-devel
%description
This is a provisional implementation of pyproject RPM macros for Fedora 30+.
These macros are useful for packaging Python projects that use the PEP 517
pyproject.toml file, which specifies the package's build dependencies
(including the build system, such as setuptools, flit or poetry).
%prep
cp -p %{SOURCE1} %{_builddir}
cp -p %{SOURCE2} %{_builddir}
%build
# nothing to do, sources are not buildable
%install
mkdir -p %{buildroot}/%{_rpmmacrodir}
install -m 644 %{SOURCE0} %{buildroot}/%{_rpmmacrodir}/
%files
%{_rpmmacrodir}/macros.pyproject
%doc README.md
%license LICENSE
%changelog
* Fri Jun 28 2019 Patrik Kopkan <pkopkan@redhat.com> - 0-1
- created package

0
sources Normal file
View File