Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: python3-pillow-heif #1396

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From 36e9ceb4bc3977533f52d7cdcbfe8867dc5243dc Mon Sep 17 00:00:00 2001
From: madonuko <[email protected]>
Date: Mon, 1 Jul 2024 12:14:13 +0800
Subject: [PATCH] Use env-var PILLOW_HEIF_VERSION to get version

Somehow upstream uses horrible python code to dynamically run the
_version.py file to get the version.
---
setup.py | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/setup.py b/setup.py
index b3bf0ce..e5365b0 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Script to build wheel."""
+
import os
import re
import subprocess
@@ -24,9 +25,7 @@ class RequiredDependencyException(Exception):

def get_version():
"""Returns version of the project."""
- version_file = "pillow_heif/_version.py"
- exec(compile(Path(version_file).read_text(encoding="utf-8"), version_file, "exec")) # pylint: disable=exec-used
- return locals()["__version__"]
+ os.environ["PILLOW_HEIF_VERSION"]


def _cmd_exists(cmd: str) -> bool:
@@ -50,15 +49,11 @@ def _pkg_config(name):
libs = re.split(
r"(^|\s+)-L",
subprocess.check_output(command_libs, stderr=stderr).decode("utf8").strip(),
- )[
- ::2
- ][1:]
+ )[::2][1:]
cflags = re.split(
r"(^|\s+)-I",
subprocess.check_output(command_cflags).decode("utf8").strip(),
- )[
- ::2
- ][1:]
+ )[::2][1:]
return libs, cflags
except Exception: # noqa # pylint: disable=broad-exception-caught
pass
--
2.45.2

5 changes: 5 additions & 0 deletions anda/langs/python/pillow-heif/anda.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project pkg {
rpm {
spec = "python3-pillow-heif.spec"
}
}
120 changes: 120 additions & 0 deletions anda/langs/python/pillow-heif/python3-pillow-heif.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
%global py3_incdir %(RPM_BUILD_ROOT= %{python3} -Ic 'import sysconfig; print(sysconfig.get_path("include"))')

%global srcname pillow-heif

# Dependencies are missing to build the documentation
%bcond_with doc

Name: python-%{srcname}
Version: 0.16.0
Release: 1%{?dist}
Summary: Python library for working with HEIF images and plugin for Pillow

License: BSD-3-Clause
URL: https://github.com/bigcat88/pillow_heif
Source0: https://github.com/bigcat88/pillow_heif/archive/refs/tags/v%{version}/pillow-heif-%{version}.tar.gz
Source1: test.py
Patch0: 0001-Use-env-var-PILLOW_HEIF_VERSION-to-get-version.patch

BuildRequires: gcc
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-pillow-devel
BuildRequires: libheif-devel
%if %{with doc}
BuildRequires: make
BuildRequires: python%{python3_pkgversion}-sphinx
BuildRequires: python%{python3_pkgversion}-sphinx-copybutton
BuildRequires: python%{python3_pkgversion}-sphinx-issues
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
%endif

%description
Python library for working with HEIF images and plugin for Pillow

There are two subpackages: devel (development) and doc (documentation).

%package -n python%{python3_pkgversion}-%{srcname}
Summary: Python library for working with HEIF images and plugin for Pillow
Requires: python%{python3_pkgversion}-pillow
Requires: libheif
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

%description -n python%{python3_pkgversion}-%{srcname}
Python library for working with HEIF images and plugin for Pillow

There are two subpackages: devel (development) and doc (documentation).

%package -n python%{python3_pkgversion}-%{srcname}-devel
Summary: Development files for %{srcname}
Requires: python%{python3_pkgversion}-devel, libheif-devel
Requires: python%{python3_pkgversion}-%{srcname}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}-devel}

%description -n python%{python3_pkgversion}-%{srcname}-devel
Development files for %{srcname}.


%package -n python%{python3_pkgversion}-%{srcname}-doc
Summary: Documentation for %{srcname}
BuildArch: noarch
Requires: python%{python3_pkgversion}-%{srcname} = %{version}-%{release}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}-doc}

%description -n python%{python3_pkgversion}-%{srcname}-doc
Documentation for %{srcname}.


%prep
%autosetup -p1 -n pillow_heif-%{version}


%build
export SETUPTOOLS_SCM_PRETEND_VERSION=%version
export PILLOW_HEIF_VERSION=%version
# Native build
%py3_build

# Doc build
%if %{with doc}
PYTHONPATH=$(echo $PWD/build/lib.linux-*) make -C docs html BUILDDIR=_build_py3 SPHINXBUILD=sphinx-build-%python3_version
rm -f docs/_build_py3/html/.buildinfo
%endif


%install
export SETUPTOOLS_SCM_PRETEND_VERSION=%version
export PILLOW_HEIF_VERSION=%version
# Native build
%py3_install

# hack…? but how did this even happen in the first place
%dnl mv %buildroot%python3_sitearch/pillow_heif-0.0.0-py%python3_version.egg-info %buildroot%python3_sitearch/pillow_heif-%version-py%python3_version.egg-info || true

%check
# Check Python 3 modules
cp %{SOURCE1} $(echo $PWD/build/lib.linux-*)/
pushd build/lib.linux-*
PYTHONPATH=$PWD %{__python3} test.py
pytest pillow_heif && echo "Test done"
popd

%files -n python%{python3_pkgversion}-%{srcname}
%doc README.md CHANGELOG.md
%license LICENSE.txt
%{python3_sitearch}/pillow_heif/
%{python3_sitearch}/pillow_heif-%{version}-py%{python3_version}.egg-info/
%{python3_sitearch}/_pillow_heif.*.so

%files -n python%{python3_pkgversion}-%{srcname}-devel

%if %{with doc}
%files -n python%{python3_pkgversion}-%{srcname}-doc
%doc docs/_build_py3/html
%endif

%changelog
* Thu Jun 27 2024 Trung Lê <[email protected]> - 0.16.0-1
- Initial RPM package
2 changes: 2 additions & 0 deletions anda/langs/python/pillow-heif/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pillow_heif;
print(pillow_heif.libheif_info());
1 change: 1 addition & 0 deletions anda/langs/python/pillow-heif/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rpm.version(pypi("pillow-heif"));
Loading