Skip to content

Commit 246f621

Browse files
committed
Migrate to Cython 3
1 parent 27763ec commit 246f621

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cython
1+
cython>=3

pyamdgpuinfo/_pyamdgpuinfo.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ cdef struct poll_args_t:
8383
amdgpu_cy.amdgpu_device_handle* device_handle
8484

8585

86-
cdef void* poll_registers(void *arg) nogil:
86+
cdef void* poll_registers(void *arg) noexcept nogil:
8787
cdef:
8888
int index = 0
8989
poll_args_t *args
@@ -193,14 +193,11 @@ cpdef object get_gpu(int gpu_id):
193193
amdgpu_cy.amdgpu_device_handle device_handle
194194
uint32_t major_ver, minor_ver
195195
int drm_fd
196-
int index
197196
int amdgpu_index = 0
198-
dict gpu_info
199197
str gpu_path
200198
str drm_name
201199
devices = find_devices()
202-
for index, gpu_path in enumerate(devices):
203-
gpu_info = {}
200+
for gpu_path in devices:
204201
try:
205202
drm_fd = os.open(gpu_path, os.O_RDWR)
206203
except Exception:
@@ -301,7 +298,7 @@ cdef class GPUInfo:
301298
def __init__(self, device_path, gpu_id):
302299
cdef:
303300
amdgpu_cy.drm_amdgpu_info_vram_gtt vram_gtt
304-
char* device_name
301+
const char* device_name
305302
uint32_t major_ver, minor_ver
306303
self.gpu_id = gpu_id
307304
self.path = device_path

setup.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
"""Setup information"""
22
import setuptools
3-
from distutils.extension import Extension
43
from Cython.Build import cythonize
54

6-
with open("README.md", "r") as fh:
5+
with open("README.md", "r", encoding="utf-8") as fh:
76
LONG_DESCRIPTION = fh.read()
87

9-
EXTENSIONS = [Extension(name="pyamdgpuinfo._pyamdgpuinfo", sources=["pyamdgpuinfo/_pyamdgpuinfo.pyx"],
10-
include_dirs=["/usr/include/libdrm"], libraries=["drm_amdgpu"])]
8+
EXTENSIONS = [
9+
setuptools.Extension(
10+
name="pyamdgpuinfo._pyamdgpuinfo",
11+
sources=["pyamdgpuinfo/_pyamdgpuinfo.pyx"],
12+
include_dirs=["/usr/include/libdrm"],
13+
libraries=["drm_amdgpu"],
14+
)
15+
]
1116

1217
setuptools.setup(
1318
name="pyamdgpuinfo",
@@ -18,15 +23,15 @@
1823
long_description_content_type="text/markdown",
1924
url="https://github.com/mark9064/pyamdgpuinfo",
2025
packages=setuptools.find_packages(),
21-
python_requires='>=3.7',
22-
ext_modules=cythonize(EXTENSIONS, language_level=3),
26+
python_requires=">=3.7",
27+
ext_modules=cythonize(EXTENSIONS, language_level="3str"),
2328
zip_safe=False,
2429
classifiers=[
2530
"Programming Language :: Python :: 3",
2631
"Programming Language :: Cython",
2732
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
2833
"Operating System :: POSIX :: Linux",
29-
"Development Status :: 4 - Beta",
30-
"Natural Language :: English"
34+
"Development Status :: 5 - Production/Stable",
35+
"Natural Language :: English",
3136
],
3237
)

0 commit comments

Comments
 (0)