17
0

Accepting request 873595 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/873595
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-ctypeslib2?expand=0&rev=3
This commit is contained in:
2021-02-19 22:44:32 +00:00
committed by Git OBS Bridge
5 changed files with 94 additions and 12 deletions

57
clang-version.patch Normal file
View File

@@ -0,0 +1,57 @@
From 98060fe704f7195356d754a78c67c6fd4756daa7 Mon Sep 17 00:00:00 2001
From: Loic Jaquemet <loic.jaquemet+github@gmail.com>
Date: Tue, 16 Feb 2021 18:14:32 -0700
Subject: [PATCH] add an helpful helper for clang python & .so in -version
---
ctypeslib/__init__.py | 8 +++++++-
ctypeslib/clang2py.py | 3 ++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ctypeslib/__init__.py b/ctypeslib/__init__.py
index a332e9e..c8fabfd 100644
--- a/ctypeslib/__init__.py
+++ b/ctypeslib/__init__.py
@@ -23,7 +23,10 @@
try:
from ctypes.util import find_library
# debug for python-haystack travis-ci
- for version in ["libclang", "clang", "clang-11", "clang-5.0", "clang-4.0", "clang-3.9", "clang-3.8", "clang-3.7"]:
+ v1 = ["clang-%d" % _ for _ in range(14, 6, -1)]
+ v2 = ["clang-%f" % _ for _ in range(6, 3, -1)]
+ v_list = v1 + v2 + ["clang-3.9", "clang-3.8", "clang-3.7"]
+ for version in ["libclang", "clang"] + v_list:
if find_library(version) is not None:
from clang import cindex
cindex.Config.set_library_file(find_library(version))
@@ -33,6 +36,9 @@
# On darwin, consider that Xcode should be installed in its default path.
from clang import cindex
cindex.Config.set_library_file('/Applications/Xcode.app/Contents/Frameworks/libclang.dylib')
+
+ def ctypes_version():
+ return cindex.Config.library_file
except ImportError as e:
print(e)
diff --git a/ctypeslib/clang2py.py b/ctypeslib/clang2py.py
index 611cc0d..465df84 100755
--- a/ctypeslib/clang2py.py
+++ b/ctypeslib/clang2py.py
@@ -13,6 +13,7 @@
from ctypeslib.codegen import typedesc
from ctypeslib.codegen.codegenerator import generate_code
from ctypeslib.library import Library
+from ctypeslib import ctypes_version
################################################################
windows_dll_names = """\
@@ -175,7 +176,7 @@ def windows_dlls(option, opt, value, parser):
default=False)
parser.add_argument('-V', '--version',
action='version',
- version="%(prog)s version " + version)
+ version="%(prog)s version " + version + " clang: " + ctypes_version())
parser.add_argument("-w",
action="store",

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9510aceddc1445f9814510939c59f4e4fa2a9aa02a744ee9fe99afc78ffda3c5
size 76248

3
ctypeslib2-2.2.3.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:79d021879191d2c63e19e5b9c35b1fc6a8c58a9ba67e8be90c2c40a815d94560
size 63975

View File

@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Fri Feb 19 02:18:14 UTC 2021 - John Vandenberg <jayvdb@gmail.com>
- Switch to PyPI source
- Skip python3.6 on Tumbleweed due to missing python36-clang
- Add clang-version.patch to support more clang versions
- Update to v2.2.3
* See https://github.com/trolldbois/ctypeslib/compare/2.2.2...2.2.3
-------------------------------------------------------------------
Wed May 27 13:21:25 UTC 2020 - Petr Gajdos <pgajdos@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-ctypeslib2
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,6 +18,7 @@
# No python2-clang
%define skip_python2 1
%define skip_python36 1
%define oldpython python
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%ifarch %{ix86} x86_64
@@ -26,20 +27,22 @@
%bcond_with test
%endif
Name: python-ctypeslib2
Version: 2.2.2
Version: 2.2.3
Release: 0
Summary: Python FFI toolkit using clang
License: MIT
Group: Development/Languages/Python
URL: https://github.com/trolldbois/ctypeslib
Source: https://github.com/trolldbois/ctypeslib/archive/%{version}.tar.gz#/ctypeslib2-%{version}.tar.gz
BuildRequires: %{python_module clang}
Source: https://files.pythonhosted.org/packages/source/c/ctypeslib2/ctypeslib2-%{version}.tar.gz
Patch0: https://github.com/trolldbois/ctypeslib/commit/98060fe704f7195356d754a78c67c6fd4756daa7.patch#/clang-version.patch
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module testsuite}
BuildRequires: fdupes
BuildRequires: gcc
BuildRequires: python-rpm-macros
Requires: python-clang
BuildRequires: python3-clang
Requires: python3-clang
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
@@ -53,13 +56,22 @@ Conflicts: %{oldpython}-ctypeslib
Python FFI toolkit using clang.
%prep
%setup -q -n ctypeslib-%{version}
%setup -q -n ctypeslib2-%{version}
%patch0 -p1
sed -i '1{/^#!/d}' ctypeslib/clang2py.py
# https://github.com/trolldbois/ctypeslib/issues/60
sed -i 's/test_variable/_test_variable/' test/test_clang2py.py
sed -Ei 's/(test_class|test_macro|test_variable)/_\1/' test/test_clang2py.py
# Skipped on master
# https://github.com/trolldbois/ctypeslib/commit/ef141bb04ef1f9f50774a52195d75a71d55b2749#diff-056c7a7f3e89754296c5f3478ac0ad54630c347a1dc5bf22311ca059cde0ccde
sed -i 's/test_unicode_cpp11/_test_unicode_cpp11/' test/test_types_values.py
sed -i 's/test_unicode/_test_unicode/' test/test_types_values.py
# https://github.com/trolldbois/ctypeslib/issues/61
sed -i 's/test_extern_function_pointer_multiarg/_test_extern_function_pointer_multiarg/' test/test_types_values.py
sed -i 's/test_callbacks/_test_callbacks/' test/test_callbacks.py
# https://github.com/trolldbois/ctypeslib/issues/62
sed -i 's/test_includes/_test_includes/' test/test_fast_clang.py
@@ -73,14 +85,18 @@ sed -i 's/test_includes/_test_includes/' test/test_fast_clang.py
%if %{with test}
%check
CFLAGS="-Wall -Wextra -Werror -std=c99 -pedantic -fpic"
LDFLAGS="-shared"
gcc $CFLAGS $LDFLAGS -o test/data/test-callbacks.so test/data/test-callbacks.c
export LANG=en_US.UTF-8
export PYTHONDONTWRITEBYTECODE=1
%{python_expand \
bin_dir=bin-%{$python_version}
mkdir $bin_dir
ln -s %{buildroot}%{_bindir}/clang2py-%{$python_version} $bin_dir/clang2py
export PATH=$PATH:`pwd`/$bin_dir
export PYTHONPATH=:test:./build/lib:%{buildroot}%{$python_sitearch}
export PYTHONDONTWRITEBYTECODE=1
export PYTHONPATH=:test/:%{buildroot}%{$python_sitelib}
$python -m unittest discover -s test/ -v
}
%endif