2019-11-07 13:07:13 +00:00
#
# spec file for package python-ctypeslib2
#
2023-04-26 09:19:01 +00:00
# Copyright (c) 2023 SUSE LLC
2019-11-07 13:07:13 +00:00
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
2020-05-27 15:14:25 +00:00
#
2019-11-07 13:07:13 +00:00
%ifarch %{ix86} x86_64
%bcond_without test
%else
%bcond_with test
%endif
2023-08-25 15:34:54 +00:00
2023-04-26 09:20:23 +00:00
%if 0%{suse_version} >= 1599
2023-04-26 09:19:01 +00:00
# Tumbleweed default 16 is not compatible
%define clangmajor 15
2023-08-25 15:34:54 +00:00
# Until python3-clang is converted to multiflavor, we have the primary flavor only
# Please keep the multiflavor macro usage in the specfile consistent.
%define pythons python3
# help in the rename from multiflavor to python3 only
%define primary_python3 python%{python3_version_nodots}
%else
%{?sle15_python_module_pythons}
2023-04-26 09:19:01 +00:00
%endif
2023-08-25 15:34:54 +00:00
2019-11-07 13:07:13 +00:00
Name : python-ctypeslib2
2023-04-26 09:19:01 +00:00
Version : 2.3.4
2019-11-07 13:07:13 +00:00
Release : 0
Summary : Python FFI toolkit using clang
2020-05-27 15:14:25 +00:00
License : MIT
2019-11-07 13:07:13 +00:00
Group : Development/Languages/Python
2020-05-27 15:14:25 +00:00
URL : https://github.com/trolldbois/ctypeslib
2023-04-26 09:19:01 +00:00
Source : https://github.com/trolldbois/ctypeslib/archive/refs/tags/%{version} .tar.gz#/ctypeslib2-%{version}-gh.tar.gz
# PATCH-FIX-OPENSUSE ctypeslib2-suse-remove-info-check.patch code@bnavigator.de, python3-clang does not provide dist- or egg-info, we do not use the unofficial pypi package there
Patch1 : ctypeslib2-suse-remove-info-check.patch
BuildRequires : %{python_module clang%{?clangmajor} >= 11}
BuildRequires : %{python_module pip}
2020-05-27 15:14:25 +00:00
BuildRequires : %{python_module pytest}
2023-08-25 15:34:54 +00:00
BuildRequires : %{python_module setuptools >= 57}
BuildRequires : %{python_module setuptools_scm >= 7}
2020-05-27 15:14:25 +00:00
BuildRequires : %{python_module testsuite}
2023-04-26 09:19:01 +00:00
BuildRequires : %{python_module wheel}
BuildRequires : clang%{?clangmajor} >= 11
2019-11-07 13:07:13 +00:00
BuildRequires : fdupes
2023-04-26 09:21:24 +00:00
%{?clangmajor:BuildRequires: llvm%{?clangmajor} -libclang13}
2022-06-15 11:29:36 +00:00
BuildRequires : python-rpm-macros >= 20220610
2023-04-26 09:19:01 +00:00
Requires : python-clang%{?clangmajor} >= 11
2020-05-27 15:14:25 +00:00
Requires(post) : update-alternatives
2021-04-25 15:02:48 +00:00
Requires(postun) : update-alternatives
Provides : %{primary_python3} -ctypeslib2 = %{version} -%{release}
Obsoletes : %{primary_python3} -ctypeslib2 < %{version} -%{release}
2019-11-07 13:07:13 +00:00
BuildArch : noarch
%python_subpackages
%description
Python FFI toolkit using clang.
%prep
2023-04-26 09:19:01 +00:00
%autosetup -p1 -n ctypeslib-%{version}
2021-02-19 04:59:03 +00:00
sed -i '1{/^#!/d}' ctypeslib/clang2py.py
2019-11-07 13:07:13 +00:00
%build
2023-04-26 09:19:01 +00:00
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_wheel
2019-11-07 13:07:13 +00:00
%install
2023-04-26 09:19:01 +00:00
%pyproject_install
2020-05-27 15:14:25 +00:00
%python_clone -a %{buildroot} %{_bindir} /clang2py
2019-11-07 13:07:13 +00:00
%python_expand %fdupes %{buildroot} %{$python_sitelib}
%if %{with test}
%check
2022-10-14 01:44:15 +00:00
CFLAGS=" - W a l l - W e x t r a - W e r r o r - W n o - s t r i c t - p r o t o t y p e s - s t d = c 9 9 - p e d a n t i c - f p i c "
2021-02-19 04:59:03 +00:00
LDFLAGS=" - s h a r e d "
2021-04-25 15:02:48 +00:00
clang $CFLAGS $LDFLAGS -o test/data/test-callbacks.so test/data/test-callbacks.c
2021-02-19 04:59:03 +00:00
2023-04-26 09:19:01 +00:00
%python_flavored_alternatives
2019-11-07 13:07:13 +00:00
export LANG=en_US.UTF-8
2021-04-25 15:02:48 +00:00
export CPATH=$(clang -print-resource-dir)/include
if [ $(getconf LONG_BIT) -eq 32 ]; then
# not for 32-bit (looks for gnu/stubs-64.h)
sed -i 's/test_includes/_&/' test/test_fast_clang.py
# c_long != c_int -- https://github.com/trolldbois/ctypeslib/issues/61
sed -i 's/test_extern_function_pointer_multiarg/_&/' test/test_types_values.py
fi
2023-04-26 09:19:01 +00:00
%python_expand PYTHONPATH=%{buildroot} %{$python_sitelib} clang2py --version
%pyunittest -v test.alltests
2019-11-07 13:07:13 +00:00
%endif
2020-05-27 15:14:25 +00:00
%post
%python_install_alternative clang2py
%postun
%python_uninstall_alternative clang2py
2019-11-07 13:07:13 +00:00
%files %{python_files}
%doc README.md
%license LICENSE.txt
2020-05-27 15:14:25 +00:00
%python_alternative %{_bindir} /clang2py
2021-04-25 15:02:48 +00:00
%{python_sitelib} /ctypeslib
%{python_sitelib} /ctypeslib2-%{version} *-info
2019-11-07 13:07:13 +00:00
%changelog