aports/community/py3-hidapi/cython3.patch
2024-04-12 11:59:22 +02:00

161 lines
4.1 KiB
Diff

From 7dad82b125fdca5df83c00fc711151c35aaa5125 Mon Sep 17 00:00:00 2001
From: Shawn Hoffman <godisgovernment@gmail.com>
Date: Mon, 11 Sep 2023 17:27:52 -0700
Subject: [PATCH 1/4] use pyxdep file to locate chid.pxd
---
hid.pyxdep | 1 +
setup.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
create mode 100644 hid.pyxdep
diff --git a/hid.pyxdep b/hid.pyxdep
new file mode 100644
index 0000000..7480bc8
--- /dev/null
+++ b/hid.pyxdep
@@ -0,0 +1 @@
+chid.pxd
diff --git a/setup.py b/setup.py
index 4c311ba..73066b0 100755
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@
hidapi_include = os.path.join(hidapi_topdir, "hidapi")
system_hidapi = 0
libs = []
-src = ["hid.pyx", "chid.pxd"]
+src = ["hid.pyx"]
def hidapi_src(platform):
@@ -42,7 +42,7 @@ def hidapi_src(platform):
)
)
libs = ["udev", "rt"]
- src = ["hidraw.pyx", "chid.pxd"]
+ src = ["hidraw.pyx"]
if system_hidapi == 1:
libs.append("hidapi-hidraw")
else:
From 4c78f61c7815d1005023d69c42ae777cfee021c1 Mon Sep 17 00:00:00 2001
From: Shawn Hoffman <godisgovernment@gmail.com>
Date: Mon, 11 Sep 2023 17:28:33 -0700
Subject: [PATCH 2/4] specify language_level for cython
---
setup.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 73066b0..6a3e0af 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
from setuptools import setup, Extension
+from Cython.Build import cythonize
import os
import sys
import subprocess
From d73b4cc6706d4220d28df866504e989ab616616a Mon Sep 17 00:00:00 2001
From: Shawn Hoffman <godisgovernment@gmail.com>
Date: Mon, 11 Sep 2023 17:31:37 -0700
Subject: [PATCH 3/4] use pyproject.toml allow using recent cython the
expectation is that one would use the `build` tool instead of invoking
setup.py.
---
pyproject.toml | 3 +++
requirements.txt | 1 -
setup.py | 1 -
3 files changed, 3 insertions(+), 2 deletions(-)
create mode 100644 pyproject.toml
delete mode 100644 requirements.txt
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..c07b1d3
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools", "Cython"]
+build-backend = "setuptools.build_meta"
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index f71bba2..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-Cython>=0.24
diff --git a/setup.py b/setup.py
index 6a3e0af..9dcdb0e 100755
--- a/setup.py
+++ b/setup.py
@@ -136,7 +136,6 @@ def find_version():
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
- ext_modules=modules,
- setup_requires=["Cython"],
+ ext_modules=cythonize(modules, language_level=3),
install_requires=["setuptools>=19.0"],
)
From 7a7088356c089c52ef1b38861356653e5477cb65 Mon Sep 17 00:00:00 2001
From: Shawn Hoffman <godisgovernment@gmail.com>
Date: Mon, 11 Sep 2023 17:32:02 -0700
Subject: [PATCH 4/4] README: git clone can get the submodule too
---
README.rst | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/README.rst b/README.rst
index ca7fe29..02c1a84 100644
--- a/README.rst
+++ b/README.rst
@@ -44,14 +44,10 @@ Build from source
1. Download cython-hidapi archive::
- $ git clone https://github.com/trezor/cython-hidapi.git
+ $ git clone --recursive https://github.com/trezor/cython-hidapi.git
$ cd cython-hidapi
-2. Initialize hidapi submodule::
-
- $ git submodule update --init
-
-3. Build cython-hidapi extension module::
+2. Build cython-hidapi extension module::
$ python setup.py build
@@ -59,7 +55,7 @@ Build from source
$ python setup.py build --without-libusb
-4. Install cython-hidapi module into your Python distribution::
+3. Install cython-hidapi module into your Python distribution::
$ sudo python setup.py install
@@ -67,13 +63,13 @@ Build from source
$ pip install -e .
-5. Test install::
+4. Test install::
$ python
>>> import hid
>>>
-6. Try example script::
+5. Try example script::
$ python try.py