From 162b0ca34513afec6728a3196479071e9bcbd6ad Mon Sep 17 00:00:00 2001 From: Patrik Kopkan Date: Tue, 2 Jul 2019 12:41:04 +0200 Subject: [PATCH] initial import (#1717389) --- .gitignore | 0 LICENSE | 7 +++++++ README.md | 41 +++++++++++++++++++++++++++++++++++++-- macros.pyproject | 18 +++++++++++++++++ pyproject-rpm-macros.spec | 41 +++++++++++++++++++++++++++++++++++++++ sources | 0 6 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 macros.pyproject create mode 100644 pyproject-rpm-macros.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4be62ae --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 03b8558..3898942 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/macros.pyproject b/macros.pyproject new file mode 100644 index 0000000..db479f3 --- /dev/null +++ b/macros.pyproject @@ -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 +} diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec new file mode 100644 index 0000000..f2e38fb --- /dev/null +++ b/pyproject-rpm-macros.spec @@ -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 - 0-1 +- created package diff --git a/sources b/sources new file mode 100644 index 0000000..e69de29